bonsairobo / smooth-bevy-cameras

Bevy camera controllers with buttery, exponential smoothing.
MIT License
286 stars 55 forks source link

Does this crate support 2d well? #22

Closed bayou-brogrammer closed 1 year ago

bayou-brogrammer commented 2 years ago

All the examples are using 3D, but I was trying to get it to support 2D as well. It seems i have to manipulate the eye as well to keep the player in the center of the screen, but it makes for a jagged movement

bonsairobo commented 2 years ago

It wasn't designed for 2D. But I think it should work in theory, if you make the player the target and the camera the eye, much like a 3rd person perspective in 3D.

I think in practice you will just set eye = target = player position for 2D. With smoothing, the camera transform will converge towards the player.

aldanor commented 2 years ago

Was trying to make it work with 2D as well, but scratching my head re: how exactly to do it... wonder, would any of you mind sharing a quick snippet? (or maybe it should be added to examples/?)

musjj commented 1 year ago

It works fine for me. Just query your target position, then set LookTransform's eye and target to the position. Of course since it's 2d you'll have to convert the Vec2 to Vec3, but there's a nice helper method for doing that: .extend().

bonsairobo commented 1 year ago

Going to close this since @musjj confirmed it works as expected.