Godot Version
v4.2.2.stable.official [15073afe3]
Question
I have a CharacterBody2D (representing a bug) and a RigidBody2D (representing a bird) that need to detect collisions with each other. The CharacterBody2D has the following physics process function:
func _physics_process(delta):
var collision
if position.distance_to(targetPosition) < 10:
queue_free()
else:
collision = move_and_collide(velocity * delta)
if collision:
bugEaten.emit()
queue_free()
However, while collision seems to be properly detected most of the time, there are occasional moments where the CharacterBody2D will not execute any code in the “if collision” branch, but will still react to the collision by being pushed to the side or by stopping the RigidBody2D’s movement. This is shown in the following video:
I have tried messing with the collision settings on both the CharacterBody2D and the RigidBody2D, but it hasn’t helped. Is there something in the physics process code that is causing this?