Search Unity

Unity ECS Physics Only Dynamic Bodies Collides Correctly

Discussion in 'Entity Component System' started by Opeth001, Apr 18, 2019.

  1. Opeth001

    Opeth001

    Joined:
    Jan 28, 2017
    Posts:
    1,117
    Hey,
    I'm using the new Unity ECS Physics to simulate physics in a pure way into my game.( Movements, Collisions, bullets hit detections ... )
    My players are moving using the PhysicsVelocity ComponentData but im having a strange behavior only dynamic bodies are interacting with all bodies.
    kinematic bodies are walking through kinematic & static bodies, which do not make sense for me, a player walking through walls and other players.

    Need help thanks
     
  2. andynayrb

    andynayrb

    Joined:
    Feb 28, 2019
    Posts:
    25
    Do you have both a rigidbody and a collider on you player? It is my understanding that you need both to handle all collision situations. Just a guess. Other than that I got nothing.
     
  3. james_unity988

    james_unity988

    Joined:
    Aug 10, 2018
    Posts:
    71
    We already discussed this in a separate thread. A Kinematic body is one where the developer/the code sets the position. It does NOT react to the environment. It does not get stopped by obstacles. It doesn't have velocity or gravity. This is normal, and it works exactly the same way in classic MonoBehaviors also.
     
  4. Chris-Herold

    Chris-Herold

    Joined:
    Nov 14, 2011
    Posts:
    116
    It does not behave like MonoBehaviour physics. That's the whole point of this thread.
    MonoBehaviour Kinematic bodies are not affected by forces, but they do push other colliders.
    Passing through static colliders certainly sounds like they either changed this paradigm or the implementation is unfinished (which it probably is)
     
  5. Opeth001

    Opeth001

    Joined:
    Jan 28, 2017
    Posts:
    1,117
    Yes I added the PhysicsBody & PhysicsShape to my player entities, changing the PhysicsBody from kinematic to dynamic make them colliding correctly. I don't know if it's a bug or something im not understanding.
     
  6. Opeth001

    Opeth001

    Joined:
    Jan 28, 2017
    Posts:
    1,117
    Im moving the Kinematic bodies by changing their linearVelocity within the code.
     
  7. james_unity988

    james_unity988

    Joined:
    Aug 10, 2018
    Posts:
    71
    https://docs.unity3d.com/Manual/CollidersOverview.html

    Scroll to the bottom of this page. Kinematic rigidbodies do NOT interact with static colliders. The motion of a kinematic rigidbody is a function of position and excludes all external forces. If you lookup the definition of "kinematic" this is precisely what it means.

    Once again: if you want the motion of your bodies to be affected by other colliders, then they can NOT be kinematic. You must make them non-kinematic. This is not a bug or something specific to DOTS physics or something that has changed or ever will change, it's by definition.