I'm trying to use Bevy 0.3, and I'm able to use the built-in transforms easily with Camera2dComponents::default()
.
This is top-down 2D.
The issue is trying to synchronise the player's rotation to the mouse:
for event in evreader.iter(&cursor_moved_events) {
println!("{:?}", transform);
transform.look_at(Vec3::new(event.position.x(), event.position.y(), 0.0), Vec3::new(0.0, 0.0, 1.0));
println!("{:?}", transform);
}
In this transform is my player's Transform, of course. Here's what this outputs:
Transform { translation: Vec3(0.0, 0.0, 0.0), rotation: Quat(0.0, 0.0, 0.0, 1.0), scale: Vec3(1.0, 1.0, 1.0) }
Transform { translation: Vec3(0.0, 0.0, 0.0), rotation: Quat(0.5012898, -0.49870682, -0.49870682, 0.5012898), scale: Vec3(1.0, 1.0, 1.0) }
I'm a bit confused by what up
is in look_at in 2D, but I tried a few different values and the result is always the same: as soon as that look_at runs, the player disappears from view.
Why is the camera not seeing the player anymore after that, and what am I doing wrong with this look_at?