Fix: apply thrust input properly
All checks were successful
Basic checks / Basic build-and-test supertask (push) Successful in 7m11s
All checks were successful
Basic checks / Basic build-and-test supertask (push) Successful in 7m11s
Yay for funny coordinate spaces. I was, again, using the wrong operations to get the 2D Cartesian angle and apply force to the ship.
This commit is contained in:
@@ -249,13 +249,12 @@ fn input_ship_thruster(
|
|||||||
panic!("There should be exactly one player ship! Instead, there seems to be {count}.");
|
panic!("There should be exactly one player ship! Instead, there seems to be {count}.");
|
||||||
};
|
};
|
||||||
|
|
||||||
let rotation = transform.rotation;
|
|
||||||
let thrusters = children
|
let thrusters = children
|
||||||
.first()
|
.first()
|
||||||
.expect("Couldn't find first child, which should be the thruster");
|
.expect("Couldn't find first child, which should be the thruster");
|
||||||
|
|
||||||
if keyboard_input.pressed(KeyCode::KeyW) {
|
if keyboard_input.pressed(KeyCode::KeyW) {
|
||||||
velocity.0 += Vec2::from_angle(rotation.z) * SHIP_THRUST;
|
velocity.0 += (transform.rotation * Vec3::X).xy() * SHIP_THRUST;
|
||||||
commands
|
commands
|
||||||
.entity(*thrusters)
|
.entity(*thrusters)
|
||||||
.insert(MeshMaterial2d(game_assets.thruster_mat_active()));
|
.insert(MeshMaterial2d(game_assets.thruster_mat_active()));
|
||||||
|
|||||||
Reference in New Issue
Block a user