Vector2 vs Two Floats

Is there anything wrong with using a Vector2 to store something like the mouse position over two floats? I assume the Vector2 will use more memory since it comes with extra functionality, but that would be a pretty minor optimization point to look at.

Does it just come down to preference, or would there be a reason to use one method over the other?

No, it’s a struct. It provides the most simplest structure with the most minimal overhead imaginable.


A struct is a nice, compact way of expressing data related to a single entity. It also has many useful methods (which don’t pose any performance impact at all), rather than using two floats.