+1 vote

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)

in Engine by (425 points)

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

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

2 Answers

+1 vote

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

by (425 points)

More info on collision layers and masks - https://godotengine.org/qa/4010/whats-difference-between-collision-layers-collision-masks

https://godotengine.org/qa/3020/collision-masks-and-its-propper-uses

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

0 votes

Also you can use:

body.add_collision_exception_with(another_body)

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

https://docs.godotengine.org/en/stable/classes/class_physicsbody2d.html#class-physicsbody2d-method-remove-collision-exception-with

by (211 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.