- تم التحرير
Mixing animations for 360° aiming
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.
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).
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
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
Yup, order was the issue. Hitting reset on the constraints fixed everything. Thanks!
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.
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)
Hi there. I am trying to do the same thing as the OP. Although I am having trouble setting up the IK's and constraints to that of the spineboy's. Is there a more in-depth tutorial for this? Thanks in advance.
This might help:
Spineboy example
Hi Nate,
I am still having trouble with this. Is there a way we can screen share to see if I am doing this right? Or a more in-depth tutorial?
Thanks.
Here is a video to hopefully help see my problem.