1
\$\begingroup\$

I am trying to make a boxing game just for fun (I dont expect the end product to be anything decent lol) . I have my boxers in the ring and they are animated quite well so far, with Idle, and punch Left and Right. They also rotate so they are always looking at each other.

What I want to do is give the punch some aim towards the head. I will give the punch a set amount which it can move from the standard animation and move the hand bone in the direction of the targets head object. But I don't know how to do this :S

So far i have used dragged the 3 animation files into Mecanim and coded it to do the animations when a button is pressed.

Is there a way to manipulate the animation in this way? (ie. actually make the arm reach towards the target object )

\$\endgroup\$
  • 1
    \$\begingroup\$ I have not used Target Matching myself, so I will only make this a comment, but I believe it can be used for what you're looking for. You would likely need to combine that with some animation layers so that the rest of the body is not affected by it. docs.unity3d.com/560/Documentation/Manual/TargetMatching.html \$\endgroup\$ – Ed Marty Dec 19 '17 at 17:52
  • \$\begingroup\$ OK thanks Ed I'll take a look. I believe that I do want the rest of the body to follow with it, but maybe I am asking too much to be able to have it all work just be setting a target position for the hand. Maybe I have to change all bones up the arm and maybe even shoulder and stuff? . Oh well, I'll have a try anyway. cheers mate \$\endgroup\$ – Big T Larrity Dec 19 '17 at 18:00
  • 2
    \$\begingroup\$ The general term for animating with a target point in mind is called Inverse Kinematics. Hope this helps. \$\endgroup\$ – Jay Dec 20 '17 at 0:41
  • \$\begingroup\$ thanks Jay. I am following a tutorial now that will hopefully get me started on using the IK in unity to target the object. The IK I had made before was on the knees, and it mean that you could move the spine of the model down and it would appear to take a seat properly by bending legs etc. This time, as you know, I am trying to aim a punch toward a target. IK will no doubt be the answer as you guys have told me :) cheers \$\endgroup\$ – Big T Larrity Dec 20 '17 at 14:40
  • \$\begingroup\$ just for record. Im working through this tut video now as recommended by another site. It really helps me, and seems to be starting right at the level im at now so that is handy: youtube.com/watch?time_continue=117&v=GYfeALySSq8 \$\endgroup\$ – Big T Larrity Dec 20 '17 at 14:42
1
\$\begingroup\$

As the comments suggest. The two parts of Unity made for this that I could find are Target Matching https://docs.unity3d.com/560/Documentation/Manual/TargetMatching.html / and Inverse Kinematics https://docs.unity3d.com/560/Documentation/Manual/InverseKinematics.html /// https://www.youtube.com/watch?time_continue=117&v=GYfeALySSq8.

I also found a very basic "fake IK" solution that just uses the spine and was very easy to implement. But this only really works to get a character to point towards the target (eg. Aiming, or just watching it) , i dont think it would be too good for my punch the head target, which im trying now to make by using the other two things. But here is a very easy gun aiming solution for beginners: https://www.youtube.com/watch?v=6UgB7TMk3Bg

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.