Reputation: 200
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...
Upvotes: 0
Views: 3595
Reputation: 200
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.
Upvotes: 0
Reputation: 3059
this things are mostly done by your IK solution you may wanna use a full body solver and effectors to get a semi realistic motion for these types of animation you can use final-ik it is a premade solution or you can write your own using unity`s ik system but it takes a lot of time
Upvotes: 0