Search Unity

How to use physics to make an object face a specific direction?

Discussion in 'Physics' started by legoblaster1234, Dec 22, 2018.

  1. legoblaster1234

    legoblaster1234

    Joined:
    Aug 7, 2017
    Posts:
    27
    I've seen a few people ask this question. The answers are usually solutions that only work on one axis or use things like RigidBody.MoveRotation which just teleports the object to the desired angle.
    None of the solutions are what I'm looking for. I want to use physics to tween an object's rotation to face a specific direction on all 3 axes in such a way that if an object gets in its way it will be stopped (for instance by setting the objects angular velocity or applying a force but I don't know what math to do to make this solution make the object face a specific direction instead of just rotating endlessly on a axis).
     
  2. legoblaster1234

    legoblaster1234

    Joined:
    Aug 7, 2017
    Posts:
    27