Skip to content

Commit

Permalink
fix:zero vector normalized bug
Browse files Browse the repository at this point in the history
  • Loading branch information
limuy2022 committed Jun 8, 2024
1 parent a5d2e18 commit 59fa968
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
14 changes: 7 additions & 7 deletions gdrust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion gdrust/src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl ICharacterBody2D for Player {
0.0,
);
self.base_mut().move_and_collide(
vel.normalized() * Self::RUSH_SPEED as f32 * delta as f32 * down_rate as f32,
vel.normalized() * Self::RUSH_SPEED as f32 * delta as f32 * down_rate,
);
return;
}
Expand Down Expand Up @@ -107,6 +107,9 @@ impl ICharacterBody2D for Player {
if input_obj.is_action_pressed(MOVE_DOWN.into()) {
vel.y += 1.0;
}
if vel == Vector2::ZERO {
return;
}
let res = self
.base_mut()
.move_and_collide(vel.normalized() * Self::SPEED as f32 * down_rate * delta as f32);
Expand Down

0 comments on commit 59fa968

Please sign in to comment.