Main Content

We have a standard 2D humanoid character that needs to be able to aim/shoot in 360 degrees. I'm not exactly sure how to approach this with Spine/Unity.

I've seen solutions for this which manually rotate a bone (in this case arm) the desired degrees. This isn't a great solution for us because we also want to tilt the head and torso as they aim in different directions.

Currently we have animation states for 5 directions: down (-90°), angle-down (-45°), forward (0°), angle-up (45°) and up (90°). My hope is that we if the player wants to aim at say 20° we can set the aim animation track to an animation that is a 44% mix of the forward and angle-up animations. Or something similar that can achieve the same result.

11 months ago

MrSkinny

Posts: 11

Nate

Is your character a side view? 3/4? Top down?

For side view (and others), you can use constraints which will be easier than manipulating bones via code or combining animations at various angles. Take a look at our IK demo, check the Aim box, then move the red aim circle. See the latest spineboy project (in the Spine installation folder, reinstall to get the latest if your installation is old) for how it is rigged. One IK points the shooting arm at the aim bone and another IK points a bone at the hip at the aim bone. Transform constraints modify the arm, torso, and head to match that bone at that hip. Their mix is not 100%, which is what makes it look nice. Note the aim animation is just setting the transform constraint mixes (they are 0 in the setup pose).

11 months ago

Nate

Posts: 8458

MrSkinny

Nate, thanks as always for the reply. The character is side view and the aim in the IK demo is exactly what we are trying to accomplish. Cheers

---

Nate, I am having one issue with trying to set this up that's puzzling me. I have an IK constraint that I tried to setup like the "aim-torso-ik" in the spineboy-pro setup. For some reason the parent doesn't rotate towards the target bone though. See below:

If I tried targeting different bones and sometimes it works correctly. Do know what could cause this? Thanks

6 months ago

MrSkinny

Posts: 11

Nate

While arm-left-constraint-target (the zero length bone in your image) is only constrained by the one IK constraint, you have a number of constraints. Likely one of the other constraints is being applied first and manipulating a parent bone. When a constraint changes a bone transform, the transform for all the descendant bones needs to be recomputed. When that happens any changes to the child transforms by previous constraints is lost.

Drag your constraints so the IK is applied after any constraints which affect that bone or any parent bones.Constraints: Order

6 months ago

Nate

Posts: 8458

MrSkinny

Yup, order was the issue. Hitting reset on the constraints fixed everything. Thanks!

6 months ago

MrSkinny

Posts: 11

Nate

Great! Note that the constraints Reset tries to automatically order the constraints in a reasonable way, but sometimes you will want a different order. In that case you can just drag the constraints up/down. In 3.7 we indicate the constraints are dragable when you hover over them.

6 months ago

Nate

Posts: 8458

thislop

Thanks Nate & MrSkinny, this solved a massive problem I was having introducting new arm IKs into an existing rig! (Programmer working with the Spine API, getting my head round actually animating for workflow purposes before delegating to the animation team)