2D bone animation - point gun at mouse

Started by
2 comments, last by Khatharr 7 years, 1 month ago

How is this handled?

It's some form of kinematics which I kinda understand and I have a very solid grip of trig, but I don't know how to start with having both hands attached to a single weapon with each arm moving independently and the torso also moving to accommodate extreme angles. How would one keep the gun completely static (It appears to have an origin/rotation point at the shoulder) while having the arms bend with the hands static on the gun?

Is the gun rotated to point at the mouse and that motion propagates back through the arms? Or does it figure out where the gun needs to be pointed and then rotate the arms to match?

How is the movement handled for the torso? Is the torso only rotated when the arms reach a limit?

etc.

As you can see I have a lot of questions. I'd just like a starting point to begin with, or someone to suggest a way to approach it all. An example or tutorial would be great if you could point me to one.

What I'd like to avoid is using a third party program like DragonBones, Spriter or Spine. I'd like to start at the beginning of the problem to get a fuller understanding of it all.

Thanks!

Advertisement

Show your code

Some key principles to do this are: object rotation, animating in another objects space, and 2 bone IK

1. First imagine the aim vector itself is an object which is roatating and that you can "parent" the gun under it. This is important because you want the recoil to animate in the space of the aim vector.

2. Next, animate the hands relative to the gun.

3. Read Ryan Juckett's 2 bone IK article here http://www.ryanjuckett.com/programming/analytic-two-bone-ik-in-2d/

4. The torso does look like it is just lerping to a specific pose when the angle of the aim vector crosses the horizontal axis. This is a good, simple way to do it. If you want continuous smooth pose changes you need to set up a series of poses you blend between which have their blend weights driven by the aim angle.

Looks like there's a center point and the two hand points rotate around it at a fixed distance to keep them aligned with the cursor. The rest is just inverse kinematics with the root in the hips.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

This topic is closed to new replies.

Advertisement