Ignore Collision for certain bodies

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By tiernich
:warning: Old Version Published before Godot 3 was released.

Hey guys, there is a way to do a selective collision detection?

Something like: If those bodies colliding have the variable IgnoreColl, ignore collision?(same as check trigger for the collision shape)

about what? area? rigidbody? raycast? 2d? 3d? Collision layer?

Gokudomatic2 | 2016-05-06 13:49

@Goku Rigidibody2D. Just figured out, changing the collision layers and masks solved the problem. Thanks for the fast reply!

tiernich | 2016-05-06 13:53

:bust_in_silhouette: Reply From: tiernich

Just figured out. Changing the Collision layers and Collision mask do the trick!

More info on collision layers and masks - What's the difference between Collision layers and Collision masks? - Archive - Godot Forum

Collision masks and its propper uses - Archive - Godot Forum

Consider it the following way: a physics object belongs to some layers, and collides with other objects specified by its collision mask.

jarlowrey | 2017-05-05 17:03

:bust_in_silhouette: Reply From: luislodosm

Also you can use:

body.add_collision_exception_with(another_body)

body and another_body are type PhysicsBody2D (KinematicBody2D, RigidBody2D, StaticBody2D)