I have a capsule defined by two end points and a radius. I would like to query the scene for any collisions with this capsule and retrieve the collision point and normal.
Physics.CapsuleCastAll (p1,q1, Radius, Vector3.zero); Does not produce any hits.
Physics.CapsuleCastAll (p1,q1, Radius, Vector3.up, 0); Doesn’t produce any hits.
This appears to be erroneous as a capsule has a defined volume and whether or not I’ve dragged it through space shouldn’t be relevant to if it intersects things.
I’d rather not write capsule tests for all the shapes in Unity and manually test the scene. So how do I query Unity for this information?
Motivations for my approach:
I’m implementing thread simulation via position based dynamics. I have a thread composed of nodes which each have a mass and velocity, position, and torsion. I solve a set of constraint equations to make the thread behave as one would expect. The space between two connected nodes forms a capsule shape. Since the thread has radius, and two nodes have two points I get a capsule. I handle self-collisions internally but in order to integrate it into unity’s physics I need to get collision data for these capsules.
Why I can’t use a GameObject:
If I wanted to use a GameObject I would have to create an object for each space inbetween nodes. I would have to use a non-kinematic rigidbody for this intermediary spaces between nodes (Or else I wouldn’t get collisions against static shapes). Which in lies the first problem, the capsules aren’t rigid they change size every frame. I’d have to update a rigid body each frame with approximated values for velocity, mass, inertial tensor, etc… The capsules don’t behave that way. I’d be forming a bridge which would introduce further error into the simulation. I can’t have that messing with my thread. I need a way to query the scene for the data to handle the collisions myself. How do I accomplish this?