Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | jubi |
I have been following along with the tutorial in the documentation 1 however, when I tried to implement their method of collision detection, it appears that the if collision.collider.is_in_group()
condition is never met. I’ve added some print statements to the test to see what stages it’s going through, and it does test collisions when I place the code on either the collectable object or the player, is_in_group()
just always returns false. Is there a different way I can do this? I’ve attached the code I’ve been using. The “Player” and “Item” objects are both KinematicBodies set to the appropriate layers defined in the project settings, with CollisionShapes and MeshInstances.
collision
for index in range(get_slide_count()):
print("TESTING COLLISION")
var collision = get_slide_collision(index)
print(collision.collider.is_in_group("items"))
if collision.collider.is_in_group("items"):
var item = collision.collider
print("ITEM COLLISION")
item.pick_up()
`