Two instances of KinematicBody (3D) collide, but they are on different layers

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By aron137

I have a Player placed in the scene:

extends KinematicBody

func _ready():
    collision_layer = 3

and a Projectile which is instantiated via script:

extends KinematicBody

func _init():
    collision_layer = 2

Player uses move_and_slide and Projectile uses move_and_collide to get around.

I expect them not to collide since their collision_mask is 1 by default and they are on layer 2 and 3, but whenever a Projectile is instantiated (at the Player’s position), it causes a spaz to the Player’s position, which I assume is a collision between them.

I create the collision shape for the Projectile programmatically, without changing anything:

var collision_shape = CollisionShape.new()
collision_shape.shape = SphereShape.new()
self.add_child(collision_shape)

And for the Player I set it in the editor to a CapsuleShape, without changing anything as well.


I am using v3.2.stable.official (Steam).

It seems only moveandslide (Player) detects collision, moveandcollide (Projectile) does not.

aron137 | 2020-02-02 17:17