# 2D bone animation - point gun at mouse

N

#### -=NuBC4k3=-

##### Guest
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 to hold it in place?

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.

I guess my brain is a bit fried at the moment. I've made no progress on this at all. It hasn't been a great week so far... I am well aware that it's Monday.

Thanks!

Last edited by a moderator:

#### HammerOn

##### Member
A complex looking system is a simple and stable structure decorated. It's essential to understand this concept when trying to implement something like this.
What I mean is that, behind the scenes, the only pieces that affect the character movement are probably the torso and the gun. The torso rotates and the gun offsets with it. They are connected. The gun also rotates to point to the mouse position. It's a simple two bones system.
The arms don't affect the character, they just follow the gun and torso movement with inverse kinematics. You could also make the character breath, rotate the head or move the legs joints with inverse kinematics too. They are just decorations on top of the two bones and the system still works if you remove all this decoration later.

I would say that designing and programming something like this is about reducing it to the most simple mechanism you can get and then add visual on top of it. Technical simplicity to make it easy to code and bug free plus visual complexity to appeal to the player. The best of the the worlds.
An example that I like a lot is the game Wipeout 2048.
If you disable all the fancy looking stuff. Floating effect, camera and ship's dynamic rotations, barrel roll, rear tilt, etc. This is probably a capsule shape fixed at a static distance from the ground. It can only yaw and pitch traveling a smooth path in the track.
Physics based games like Limbo, Intrusion 2 and many racing games are all about faking what is hard to control. Otherwise you can't make it stable or feasible at all.

Last edited: