Ability to add CollisionShape to exceptions for Raycast and Shapecast. #11686
Ale3ex
started this conversation in
Engine Core
Replies: 1 comment
-
This might be complicated to achieve depending on the details, as many of the operations in the physics engine doesn't operate on individual shapes but on the whole combined But the example is IMO a bit niche, and I think other solutions might be better in this kind of case, especially the last suggestion of a whole room being a single collision object seems not recommended, if you are wanting to deal with each individual part separately, I'd say that's a good reason to not have them be a single object |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Godot already has an add_exception function, but it only allows adding the entire CollisionObject, including all of its child CollisionShapes.
For CollisionObject with compound collider of multiple CollisionShape, we may need to add a specific CollisionShape to the exceptions rather than the entire object, so that RayCast and ShapeCast can continue to collide with the rest of the child CollisionShape nodes of that physics body, ignoring just one of them.
Example of usage:
For example, we have a table that has 5 child CollisionShape3D:
All CollisionShape3D have BoxShape3D primitives as their shape.
I'm writing a system where bullets can pass through obstacles. Bullets are made with ShapeCast3D.
When a bullet hits a tabletop that is one of the composite CollisionShape3Ds, we get the impact point, update the bullet's velocity and deflection, and then create a new ShapeCast from the impact point to continue the bullet's flight.
To avoid causing a repeated collision with the same tabletop from a composite table collider, we need to be able to add a specific CollisionShape3D tabletop node to exceptions.
For example, it might look like this:
The problem is that at the moment we can add the entire table (CollisionObject3D) with all its colliders to add_exception. In this case, for the second ShapeCast3D, all other child colliders of the table will also be excluded. The result of this will be that the legs of the table will no longer be able to interact with the bullet.
The situation will be even worse if we make the whole room one CollisionObject3D, and the walls are composed of child colliders with BoxShape3D. After hitting the first wall and adding the room to add_exception, all subsequent collisions with other walls will be ignored.
Beta Was this translation helpful? Give feedback.
All reactions