Search Unity

How to apply Torque away from grenade?

Discussion in 'Physics' started by TKDHayk, Jan 9, 2019.

  1. TKDHayk

    TKDHayk

    Joined:
    Dec 22, 2015
    Posts:
    131
    Hello, im working on a throwable grenade for my Oculus VR game.

    When the grenade detonates, enemies become ragdolls and fly away from the explosion.

    I also want to add torque to the enemies as they fly away.

    My question how do I get the ends to torque Away from the explosion ? In other words, if the explosion is to the left of a rigidbody, I need it to rotate clockwose (so the top surface is moving away from the explosion). If the explosion happens to the right of the rigidbody, it turns counter clockwise, so it's top surface moves away from the explosion.

    In other words, I need to add torque to to the rigidbody relative to the location of the explosion, rather than relatve to it's own transform axes.
     
  2. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    Maybe if you use addForceAtPosition at key points, say if the explosion is to the forward left of the unit apply force(besides the explosion force) to the left arm and leg(the 2 closest limbs)

    Might do the trick
     
  3. TKDHayk

    TKDHayk

    Joined:
    Dec 22, 2015
    Posts:
    131

    That's actually what I am doing now, but it does not reliably produce net torque int he desired direction.