Godot Version
4.3
Question
I’m implementing bounce logic and character facing.
But changing rotation when it collide make it infinitely collide and again and again.
Actually I can fix this problem by changing the rotation after collide frame.
But why this happens? is there better solution?
Not working code
func _physics_process(delta):
var collision = move_and_collide(velocity * delta)
if collision:
velocity = velocity.bounce(collision.get_normal())
if collision.get_collider().has_method("hit"):
collision.get_collider().hit()
queue_redraw()
Working code
func _physics_process(delta):
var collision = move_and_collide(velocity * delta)
if collision:
velocity = velocity.bounce(collision.get_normal())
if collision.get_collider().has_method("hit"):
collision.get_collider().hit()
queue_redraw()
else:
rotation = velocity.angle()