Clear angular velocity when snapping.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
4357a5838a
commit
52d8e8db3b
|
@ -222,7 +222,14 @@ fn snap<S, A: 'static>(
|
|||
input: Res<InputMap<A>>,
|
||||
config: Res<NavigationConfig<S, A>>,
|
||||
mut snapping: ResMut<Snapping>,
|
||||
mut position: Query<(&mut RigidBodyPositionComponent, &CardinalDirection), With<Player>>,
|
||||
mut query: Query<
|
||||
(
|
||||
&mut RigidBodyPositionComponent,
|
||||
&mut RigidBodyVelocityComponent,
|
||||
&CardinalDirection,
|
||||
),
|
||||
With<Player>,
|
||||
>,
|
||||
) -> Result<(), Box<dyn Error>>
|
||||
where
|
||||
S: bevy::ecs::component::Component + Clone + Debug + Eq + Hash,
|
||||
|
@ -230,7 +237,7 @@ where
|
|||
{
|
||||
if let Some(action) = config.action_snap_left.clone() {
|
||||
if input.just_active(action) {
|
||||
for (mut position, direction) in position.iter_mut() {
|
||||
for (mut position, mut velocity, direction) in query.iter_mut() {
|
||||
**snapping = true;
|
||||
position.position.rotation = UnitComplex::new(match direction {
|
||||
CardinalDirection::North => PI,
|
||||
|
@ -238,12 +245,13 @@ where
|
|||
CardinalDirection::South => 0.,
|
||||
CardinalDirection::West => PI * 1.5,
|
||||
});
|
||||
velocity.angvel = 0.;
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(action) = config.action_snap_right.clone() {
|
||||
if input.just_active(action) {
|
||||
for (mut position, direction) in position.iter_mut() {
|
||||
for (mut position, mut velocity, direction) in query.iter_mut() {
|
||||
**snapping = true;
|
||||
position.position.rotation = UnitComplex::new(match direction {
|
||||
CardinalDirection::North => 0.,
|
||||
|
@ -251,25 +259,28 @@ where
|
|||
CardinalDirection::South => PI,
|
||||
CardinalDirection::West => PI / 2.,
|
||||
});
|
||||
velocity.angvel = 0.;
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(action) = config.action_snap_cardinal.clone() {
|
||||
if input.just_active(action) {
|
||||
for (mut position, direction) in position.iter_mut() {
|
||||
for (mut position, mut velocity, direction) in query.iter_mut() {
|
||||
**snapping = true;
|
||||
let yaw: Angle = direction.into();
|
||||
let yaw = yaw.radians();
|
||||
position.position.rotation = UnitComplex::new(yaw);
|
||||
velocity.angvel = 0.;
|
||||
tts.speak(direction.to_string(), true)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(action) = config.action_snap_reverse.clone() {
|
||||
if input.just_active(action) {
|
||||
for (mut position, _) in position.iter_mut() {
|
||||
for (mut position, mut velocity, _) in query.iter_mut() {
|
||||
**snapping = true;
|
||||
position.position.rotation *= UnitComplex::new(PI);
|
||||
velocity.angvel = 0.;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user