I have built a minimal example and I can't get it to work with RigidBody2D nodes. It will report collisions with StaticBody2Ds and other KinematicBody2Ds
have a bullet that is on collision layer 2, with mask on 3
func _physics_process(delta):
var movement = direction * speed * delta
var collision = move_and_collide(movement)
if collision:
print(collision.collider.name)
I have set up 3 targets, all on collision layer 3, a Rigidbody2D a StaticBody2D and a KinematicBody2D.
If I fire at each of them in turn the bullet stops at both the Static and Kinematic and move_and_collide()
returns a KinematicCollision2D object. In the case of the Rigidbody, the bullet hits and moves the RigidBody2D but move_and_collide()
returns nothing.
Am I right in saying that move_and_collide()
should return something when colliding with a RigidBody2D? The docs are not entirely clear on this point.