Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MoverTopDown2D.gd #51

Merged
merged 1 commit into from
Sep 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions scripts/actor/MoverTopDown2D.gd
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ func _physics_process(delta:float)->void:
acceleration = delta * actor_stats_resource.acceleration
character_body.velocity = character_body.velocity.move_toward(target_velocity, acceleration)

if character_body.velocity.length_squared() > 0.01:
# Bug workaround
character_body.move_and_slide()
# Bug workaround
if character_body.velocity.length_squared() < 0.01:
return

var collided:bool = character_body.move_and_slide()
# Weird, this should happen with nove_and_slilde by it self
if collided:
character_body.velocity = Vector2.ZERO

## Adds an impulse to velocity, like a kickback
func add_impulse(impulse:Vector2)->void:
Expand Down