Hello !
I’ve got an asset processing a sphere cast. The sphere cast is detecting if the player is falling or not. This behaviour is working correctly, returning true to SphereCast meanings a spherecast with a collider exists.
When i add a gameObject in a subscene, adding a rigidbody to create a physics object in ecs world, the sphere cast is not working anymore ( not returning anymore hits ).
This is not my code, but this is happening with this line
sphereHasDetectedHit = Physics.SphereCast(origin, sphereCastRadius, direction, out groundHit, castDistance - sphereCastRadius, groundLayer, QueryTriggerInteraction.Ignore); // Ground layer is 0 ( Default layer )
if (sphereHasDetectedHit)
{
// define IsFalling regarding distance to floor...
}
I’ve tried to change the layer of the Rigidbody converted cube, but the sphere is still not returning true anymore.
Is it a Unity Physics bug ? ( What i want to achieve is mixing MonoBehaviour Physics and Entities Physics )
Thanks for your support
What are the exact steps you took to verify the functionality works in specific cases?
What are the exact steps you took that led to functionality not working as expected?
Code would be good where relevant.
Note that runtime mixing of PhysX and Unity Physics / Havok is not supported. Objects in either one will not interact with objects in the other.
is returning false => expected to return true, there is still a floor collider, the only thing that has changed is now the scene is containing a gameobject/entity in subscene to convert with a rigidbody component associated and a box collider ( basic physics cube ). I’ve debugged the third party asset code, all values are unchanged in both cases. ( the input values for the Physics.SphereCast() are the same )
That also includes queries. You can’t use PhysX queries to get Unity Physics / Havok colliders. Use one or the other if you need to perform queries, not both.
how a converted gameobject with collider and rigidbody can affect a sphereCast ? why it is happening only when a rigidbody is attached to it ? why the mono behaviour sphereCast is not anymore returning true even nothing has changed in MonoBehaviour world ?
Yes. So the cube will not be present in the PhysX world because it was baked in a subscene. If you want something to collide in PhysX, you need to do something else. Have an object outside the subscene in the same place or have the entity spawn a GameObject or something. The current way you have things set up is not expected to work, and this is not a bug.
Can you just explain me why WorldFloorPlane is not anymore considered in Physics.SphereCast function in the second case ? ( with a subscene containing the converted rigidbody cube ). How and why the cube affects the Physics.SphereCast result ? Thanks
Could be because the subscene is open for editing. PhysX simulation gets disabled if any open subscenes have physics bodies because they would otherwise start moving around in play mode while you’re trying to edit them.
Uncheck the subscene in the Hierarchy to close it, and try again.