unity-game-engine

How do I calculate a Vector on the edge of a circle in Unity for a CharacterController?


In Unity, I need to move a CharacterController from v2 to v3. I have the following information: the centre point of the circle (v1); the current character position on the outside of the circle (v2); the angle (a). How do I calculate the move vector for the CharacterController so it moves from v2 to v3?

Finding v3


Solution

  • v3 = Quaternion.Euler(0, a, 0) * (v2 - v1) + v1
    motion = v3 - v2
    

    Explanations: