Question is off-topic or not relevant, Question can't be answered.
PhysX: GeometryQueries - Is there a reason for why this haven't been fully exposed?
As the title suggests, my question is: Why haven't this been exposed?
As the description of this function suggests, it takes two geometries along with their respective positions and then it calculates a displacement vector (direction * depth) which can be used to separate the 2 geometries via a translation.
Why would this be helpful, you may ask? Here's why:
In Unity(3D) there's about 2 viable options for you to have collision in your game. One is a rigidbody and the other is a CharacterController component. Both of these are good at what they do but they're by no means a universal solution and having the right parts of PhysX exposed in Unity would allow us to be a bit more creative with what we can achieve. Think custom character controller, this is quite a hot topic and at the moment and have been for quite a while too. See forum posts by @fholm, @IronWarrior, and @PhilSA.
I do not need newtonian physics in my game and for this reason, the rigidbody is not a good option. I also must be able to rotate the collider geometry of my character and for this reason, the axis-aligned CharacterController is also, not a good option.
I'm aware of ContactPoint which contains the separation and the normal, which in turn translates to what I posted above(The PhysX docs link), e.g. direction(normal) and depth(separation) but this is useless because you can only access it once a collision has already occured(which requires you to use a rigidbody / CC) and this is what I want to avoid.
Exposing this method as is, would mean that we could do something like this!
void Update()
{
foreach (Collider col in Physics.OverlapCapsule()) {
Vector3 direction = Vector3.zero;
float depth = 0f;
if (Mathf.CheckPrimitivePenetration(playerCollider, col,
playerCollider.transform.position, col.transform.position,
out direction, out depth)) {
//Move away from the other collider just enough to lick the surface of it
transform.Translate(direction * depth);
//Perform a raycast in -direction to get the point of collision
//Store collision data in your own collision struct
}
}
}
This would allow us to resolve our own collisions with ease and not reinvent the wheel, e.g. add our own engine like features because we just wanted some more accessibility(which in my opinion should have existed from day 1).
Hacking the rigidbody to make it behave like you want shouldn't be needed and it pains me to see this over and over again.
Now, allow me to repeat myself: Is there a partical reason for why we don't have this right now and will it be implemented any time soon?
Thank you for reading.
EDIT: Changed the indentation because it looked weird.
I'm sorry that you put that much efford into writing this post, but this is not a question that the community can answer. You should post things like that on Unity feedback.
It seems you already did that, so i'm confused what kind of answer you would expect from the community?
Anyways, since the question can't be answered i'm going to close it.
If you're making a game now, and have a specific problem, I think asking here for a work-around or a close-enough would be fine.
Follow this Question
Related Questions
CapsuleCollider check if grounded 1 Answer
How to Make A Character Stop At Wall? 0 Answers
problem with tilemap collider and composite collider 1 Answer
Animator and collision issues 0 Answers
Adding different values to randomly created objects 0 Answers