Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question ApplyAngularImpulse around a point

Discussion in 'Physics for ECS' started by slushieboy99, Oct 7, 2022.

  1. slushieboy99


    Aug 29, 2014
    Hi all, I'm trying to apply an angular impulse not around the center of mass, but around a different point. Does anyone know the math to make this work?

    I found @steveeHavok replied to this thread with some answers, but I'm having trouble getting that code to work. I don't know if ApplyAngularImpulse is now in world space instead of inertia space, but I have success rotating around the center of mass just fine until I implement this code (with point set to (0,0,0)) and get very unexpected behavior and spinning.

    Below is my current code which rotates around the center of mass. I'm essentially trying to keep certain entities upright.

    Code (CSharp):
    1. quaternion upQuat = QuaternionFunctions.FromToRotation(ltw.Up, new float3(0, 1, 0));
    2.                 float3 upVec =;
    3.                 float force = physicsParams.keepUprightAcceleration * (1 / physicsMass.InverseMass);
    4.                 float3 dirVec = upVec * force * deltaTime;
    5.                 Debug.Log(dirVec);
    7.                 physicsVelocity.ApplyAngularImpulse(physicsMass, dirVec);
    Last edited: Oct 7, 2022