You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Bevy, we use Vec3 for both 3D and 2D translations. The additional z value is useful as a z-index in 2D, so we want to keep that around in some way or another. However, the basic functions that you get with Vec3 (length(), distance(), etc.) use the z value as another dimension rather than a z-index, so two entities with the same x and y values but different z values are considered to be in different positions, when you would expect them to be in the exact same position working in 2D.
The solution is to create our own type for working in 2D that just uses the Vec2 from the standard library:
An alternative is to manually implement 2D math functions for Vec3. I imagine we could just append _2d to the names of the functions so that we get length_2d() and distance_2d() functions. The downside is that we'd have to manually re-implement them all, and the idea of maintaining our own copy of standard functionality doesn't sound good.
The text was updated successfully, but these errors were encountered:
This is a common point of frustration / confusion, and a slightly controversial idea. Though it seems like we are trending towards consensus on "the 2d split."
See #1275 and #7876 for discussion about 2d transform APIs, and #2548 for 2d-ergonomics-for-3d-transforms.
In Bevy, we use
Vec3
for both 3D and 2D translations. The additional z value is useful as a z-index in 2D, so we want to keep that around in some way or another. However, the basic functions that you get with Vec3 (length()
,distance()
, etc.) use the z value as another dimension rather than a z-index, so two entities with the same x and y values but different z values are considered to be in different positions, when you would expect them to be in the exact same position working in 2D.The solution is to create our own type for working in 2D that just uses the
Vec2
from the standard library:An alternative is to manually implement 2D math functions for
Vec3
. I imagine we could just append_2d
to the names of the functions so that we getlength_2d()
anddistance_2d()
functions. The downside is that we'd have to manually re-implement them all, and the idea of maintaining our own copy of standard functionality doesn't sound good.The text was updated successfully, but these errors were encountered: