Search Unity

Get collision event callback from ECS unity physics, to MonoBehaviour?

Discussion in 'Physics for ECS' started by Querke, Oct 13, 2019.

  1. Querke

    Querke

    Joined:
    Feb 21, 2013
    Posts:
    54
    Hey all!

    I am making a game, and replicating the movement in Quake and (Valve) Source games. And the main problem in replicating it is the collisions with Physx (PhysX likes to register ghost collisions with edges of meshes, so u get stuck on edges that is seemingly flat).
    I tried Unity Physics, similar problems there. Then I tried Havok, and turned on "Contact Point Welding". And it solved my problems.

    However. My game is really far along, and I dont necessarily want to rewrite a bunch of stuff. So I want to get a hybrid thing going.
    Currently, I use Physics.ComputePenetration in order to check what to collide with. And I had the idea, maybe I could just swap out that method with a collision event callback from ECS Unity Physics (Havok)?

    My idea is: In my monobehaviour, every fixed update, I check for collision in the ECS physics world. And get a callback with results of the collision. Similar to BoxCast or OverlapBox.

    Is this possible? Can I manually trigger such a check? Maybe create an entity, with physics shape, and physics body. Set body to kinematic. And via monobehaviour code, set the position of the entity to the gameobject. Check for collisions. Get the (ecs) ICollisionEventsJob callback, send that info the MonoBehaviour.

    I just started looking at ECS today, and I am not that experienced with it. So I wanted to run this with you guys before I start on trying to get it to work.