Search Unity

Kinematic body following another

Discussion in 'Physics for ECS' started by snacktime, Jun 22, 2021.

  1. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    Maybe I'm missing something obvious but this seems next to impossible.

    Body A is dynamic. Body B is kinematic with a local position to A. Body C is kinematic with a local position to B.

    B's local to A varies as it has some buoyancy logic. C's local to B is constant. So C cannot follow A.
     
  2. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    481
    DOTS Physics set the Translation and Rotation components of dynamic bodies in World Space. If B is parented to A (and C to B) then you will get strange movement. B and C should be at the root.
     
  3. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,356
    There is no parenting. B is connected to A with a limited DOF joint, and moved/rotated with PhysicsVelocity.CalculateVelocityToTarget. I did have C connected to B with a fixed joint and that moves correctly but somehow the velocity isn't transferred through in a way where the Rival character controller can interact (and I don't want to turn on dynamic body interaction in Rival).

    So what works good enough is just let C lag behind B. It's imprecise box colliders anyways. The rendering for C is completely separate so I can just use the current interpolated values of B there and it's all good.