0

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...

Leonard Parisi
  • 200
  • 1
  • 3
  • 12
  • Update: I figured out that when I rotate the spine, its position is changed. If I rotate the spine, then reset the position to 0, it looks fine! I did this is the game inspector, so how could I implement this in my code? I try to rotate the spine, but it isn't working (most likely because of the idle animation that is currently looping over it?). – Leonard Parisi Apr 27 '16 at 00:24

2 Answers2

0

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

Milad Qasemi
  • 3,011
  • 3
  • 13
  • 17
  • I'm sorry, but I dont really understand what you mean. I tried looking up what IK are, but I don't quite understand it. Could you please explain what it is and how I could apply it to my existing animation to get the effect I want? @user2320445 – Leonard Parisi Apr 27 '16 at 11:58
  • IK = inverse kinematics. This is the thing for example that make your player's arms and elbows follow hands in a realistic move when moving the hands. You must find tutorials about Unity IK, it's easier than it seems. I started here : http://docs.unity3d.com/Manual/InverseKinematics.html – FLX Apr 29 '16 at 11:17
0

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.

Leonard Parisi
  • 200
  • 1
  • 3
  • 12