简体   繁体   中英

How to rotate upper body of a first person character (unity)

I'm making a first person RPG game in unity. So, I have an attack animation but it only attacks what's in front of the character. How can I make the animation based off of where the player is looking (For example, if I look up, the character should attack upward instead of forward)? I've tried attaching the first person camera to the upper part of the body so it would rotate with the camera, but it causes the character's mesh to stretch and distort, and the animation doesn't even work anyway.

By the way, the character is all rigged, has different animations for walking, running, and an attack animation using Unity's mecanim. Everything else works, I'm just having trouble with this attack animation...

这些事情大部分是由IK解决方案完成的,您可能想使用全身求解器和效果来获得这些类型动画的半逼真的运动,您可以使用final-ik这是一种预制的解决方案,也可以使用unity编写自己的解决方案。 ik系统,但需要很多时间

For those of you still wondering, I changed the rotation of the upper body in the LateUpdate() function. I created a variable that kept track of the last rotation done, got the user input, and just rotated the upper body based on the user input + the last rotation in LateUpdate() and updated the last rotation done. You have to always rotate the last rotation otherwise the character will spaz out and the upper body will not keep looking at the right place.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM