Jump to content
  • Advertisement
Sign in to follow this  
-=NuBC4k3=-

2D bone animation - point gun at mouse

This topic is 504 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!