-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Raycast ignores RigidBody's children when colliding with bodies #83732
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This is not a problem, collider is directly under the RigidBody3D. The issue is that raycast is not detecting it, but can only detect Areas. |
Does it work if you change The |
After updating the layers to be correct it works fine for me |
I tried differant combinations. If they metch like you wrote the RigidBody is detected. |
What children layers? The detection is the body, not the collision shapes. You can access the shape index, but the target is the body, not the shape See the documentation, it states that it collides with a However to get access to the shape you can do: var target = raycast.get_collider()
var shape_id = raycast.get_collider_shape()
var shape = target.shape_owner_get_owner(shape_id) |
The specifics here could be documented more clearly, but there's no bug here |
Ok thank you! The code you provided is working, so it's not a bug. I didn't know that CollisionShape3D is not recognized as a body. Can I add any other node inside the RigidBody that will be recognized as a body? |
You can, but it kind of defeats the purpose, you are colliding with bodies, will make a documentation update to help with this. |
So, for example if I'm shooting RigidBody3D car and I want to know that I hit the "door", not just a "car" I have to use your 3 lines of code and there is no other simpler way? Sorry I'm coming from Unity3D, maybe I'm thinking too much from the Unity user prespective :) |
That's the simple way :) We could add a method to the ray cast to access this directly, but it's very specific use, most of the time you'd use the physics server part to do ray-casts |
You can open a proposal if one isn't opened already to suggest adding this method to |
Correction, the full code is: var target = raycast.get_collider()
var shape_id = raycast.get_collider_shape()
var owner_id = target.shape_find_owner(shape_id)
var shape = target.shape_owner_get_owner(owner_id) largely the same I believe, but to be fully clear |
Great, thank you again for your time and all the help! |
No worries! It brought to attention the limited documentation |
Godot version
4.1.1
System information
WIndows 11
Issue description
I have a rigid body with multiple child nodes - each od them has mash and collider.
I am using a raycast to detect a child inside that rigid body.
But, it only detects the rigid body (parent) and ignores its children.
I tried to change raycast collision mask and children’s collision layer, but it didn’t work - it works if I set “Collide with: Areas”, but it doesn’t work on “Collide with: Bodies”. I think that is a bug.
Steps to reproduce
Minimal reproduction project
CollisionIssue.zip
The text was updated successfully, but these errors were encountered: