We've successfully created the spine resource that character can aim weapon to the "target" bone as this video.
What we want next is a function to turn on / off the aiming weapon feature in runtime.
The reason is we want to specify which frame of the animation that the character should aim to "target" bone in runtime instead of asking the person who made the spine resource to specify it.
Is there's any solution to achieve it?
Thanks!!!
How to turn on/off aiming weapon in runtime?
To turn on or off the aiming weapon feature at runtime, you can manipulate the IK constraint's mix value. The mix value determines how much influence the IK constraint has over the bones. By setting the mix value to 1, the IK constraint is fully active, and the character will aim at the target bone. By setting it to 0, the IK constraint is inactive, and the character will not aim. You can adjust this mix value at specific frames during runtime to control when the character should aim. This approach allows you to dynamically control the aiming without needing to modify the Spine resource itself.
Spinebot's answer is correct. Just to be sure, I'll mention the available method for this: you can find a specific IK constraint using Skeleton findIKConstraint
and then set the mix with a float value between 0 and 1 like this:
skeletonAnimation.Skeleton.FindIkConstraint("constraintName").Mix = 0f;
Misaki Thank a lot, it seems work well.