+2 votes

When I cast a ray that begins within a collision shape, no collision is reported, but when I cast a ray that starts outside the collision shape, a collision is reported. If possible, how do I get a collision to occur in the event that a ray is cast from within a collision shape?
(I'm using Godot 3.2.1 c# version)

in Engine by (37 points)

2 Answers

+1 vote
Best answer

I Found the solution here.

I was trying to check for potential overlap between collision shapes by casting an intersect_ray() to ensure that if I spawn collision shapes at that location, there would be no other collision shape overlapping it.

Unexpectedly though, collisions wouldn't be reported unless the start of the raycast was outside the collision shape. Using intersect_point() gives me the functionality I was looking for.

by (37 points)
edited by
0 votes

Make the raycast a child of the body with the collisionshape and make sure Exclude Parent is true. If that is not possible for any reason, set the body's collision layer different to the raycast's collision masks

by (3,257 points)

In my case the raycast cannot be a child of the body and even when I set the body's collision layer different to the raycast's collision mask, no collision is read if the ray cast starts within the other body's collision shape.

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.