Jump to content
  • Advertisement
Sign in to follow this  
calculemus1988

Unity Should I constrain myself to XZ plane and use Vector2?

This topic is 2512 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am working on RTS game and so far I am working in the XZ plane as if you would in XY plane. I am using Vector3 class in Unity for all operations and I set y to 0. I started using Vector3 and not Vector2, because I thought later in the game I "might" need some movement of the units in y. But let's say I have only ground units, should I use Vector2? I might get some performance gain, I mean Vector3 is used a loooot, so cutting down a dimension I suppose will improve performance... and also will make coding simpler since I wont have to worry about setting y to 0 anymore...

Give me some opinions guys, thanks

Share this post


Link to post
Share on other sites
Advertisement
Well, I highly doubt you'd see any noticeable performance gains by switching form Vector3 to Vector2. If that's your main worry, then I wouldn't concern myself. If, however, you want to switch to Vector2 because it's easier to work with, and it make more sense in your game, then, yes, I'd change it.

However, you might want to use that 3rd dimension if you ever have flying units. It'd be a simple way of denoting if the unit is ground based or air based.

Share this post


Link to post
Share on other sites
I would also add that any artillery units, missiles, etc would likely be best to use the 3rd dimension for their ballistic shells/missiles/etc. I can almost guarantee you will want that 3rd dimension at some point and would be very frustrated if you'd cut it out early on.

Share this post


Link to post
Share on other sites

Another reason why a game design is very important before even writing down the first line of code.


Not especially. While one should have some idea of technical requirements before they begin, the better approach is usually to be reasonably flexible in early stages, and to become more specialized over time as the actual needs of the design become self-apparent. It is essentially impossible to create a perfect design up front -- this isn't engineering a car or building, where there are physically-bound constraints, but game design, where the ultimate "good-ness" of the product is defined by abstract goals such as "fun", "balance", and "wow-factor". In other words, the direction that a game takes is often very fluid and opportunistic. Its critical that the early phases don't paint you into a corner later, or else you might not be able to pursue that really fun thing later.

I say leave vector3 in -- vector2 isn't likely be perform much better, if at all, and if does, it will only do so under very specific circumstances that you won't fully grok until closer to the end of development.

Share this post


Link to post
Share on other sites

While one should have some idea of technical requirements before they begin, the better approach is usually to be reasonably flexible in early stages, and to become more specialized over time as the actual needs of the design become self-apparent. It is essentially impossible to create a perfect design up front -- this isn't engineering a car or building, where there are physically-bound constraints, but game design, where the ultimate "good-ness" of the product is defined by abstract goals such as "fun", "balance", and "wow-factor".

The spirit of this is good but beware of feature creep. Set end goals in the design document so there is a defined end to work towards. It may well be that you need to add to the game once you have met your design goals to make it feel polished but a defined set of goals will help you feel like progress is being made and will help you determine when you are done. Well with the first iteration at least... :)

Share this post


Link to post
Share on other sites

The spirit of this is good but beware of feature creep. Set end goals in the design document so there is a defined end to work towards. It may well be that you need to add to the game once you have met your design goals to make it feel polished but a defined set of goals will help you feel like progress is being made and will help you determine when you are done. Well with the first iteration at least... :)


Exactly!

Share this post


Link to post
Share on other sites
I'd say keep the third dimension. As previously noted, there shouldn't be much of a performance difference between the two, and writing "0," in every Vector3 instead of not writing it in every Vector2 doesn't seem like it's really worth the problems you may end up witnessing if you switched to Vector2s.

Also, if you're not entirely sure about your design just yet, you might even end up having objects walk up cliffs and ramps and such, which would mean that third dimension would come in handy.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!