0 votes

Hey everyone, i just wanna know how can i use the "add_exception" method from a RayCast2D node, and how does it work. I couldn't find much stuff about it, so i wanna know from you guys.

Thanks in advance.

Godot version v.3.3.2
in Engine by (46 points)

1 Answer

0 votes

While I've never used it, the docs seem pretty straight-forward. Really, it just provides a way for you to define a set of nodes that a given RayCast2D instance should not interact with.

So, for example, if your scene has a tree in it that you want your raycast to ignore, you can simply add the tree to the ignore list. So, assuming $RayCast2D and $Tree are valid node references in your scene, something like this:


With that, the raycast will not detect collisions with the tree. And, obviously, you can add as many objects as you want to the exception collection.

You can do similar things with collision layers or type masks. The add_exception() method is just another option.

by (19,292 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 Frequently asked questions and 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 [email protected] with your username.