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 badges1 Answer
Reset to default 3v3 = Quaternion.Euler(0, a, 0) * (v2 - v1) + v1
motion = v3 - v2
Explanations:
v2 - v1
: Vector of v2 with v1 as the originQuaternion.Euler(0, a, 0) *
: Rotate the above vector counter-clockwise bya
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 spacev3 - 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
版权声明:本文标题:How do I calculate a Vector on the edge of a circle in Unity for a CharacterController? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736283369a1926945.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论