admin管理员组

文章数量:1122832

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?

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?

Share Improve this question asked yesterday pheedstapheedsta 2,0802 gold badges16 silver badges11 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 3
v3 = Quaternion.Euler(0, a, 0) * (v2 - v1) + v1
motion = v3 - v2

Explanations:

  • v2 - v1: Vector of v2 with v1 as the origin
  • Quaternion.Euler(0, a, 0) *: Rotate the above vector counter-clockwise by a degree around the y-axis. If this is about 2D, you need to rotate around the z-axis
  • + v1: Get the v3 position in world space
  • v3 - v2: The move vector is from v2 to v3

本文标签: How do I calculate a Vector on the edge of a circle in Unity for a CharacterControllerStack Overflow