Hey everybody,
I'm currently using the above plugins (2DToolkit runtime with spine) and applying animations in the following way:
[SerializeField]
private tk2dSpineAnimation spineAnim; // Set in editor
// I call this from somewhere when I trigger the jump
public void StartJump(){
if (spineAnim.animationName == "Jump"){
// must reset the jump
} else {
if (player.HasVehicle()) {
spineAnim.animationName = "Vehicle1Jump";
vehicleAnim.animationName = "Jump";
vehicleAnim.loop = false;
} else {
spineAnim.animationName = "Jump";
}
}
spineAnim.loop = false;
}
Now, the above code works, but I don't think that I should be directly setting the animation names and their loop value.
What I think I should be doing is :
[SerializeField]
private tk2dSpineAnimation spineAnim; // Set in the editor
public void StartJump(){
if (spineAnim.animationName == "Jump"){
// must reset the jump
} else {
if (player.HasVehicle()) {
spineAnim.state.SetAnimation("Vehicle1Jump",false);
vehicleAnim.state.SetAnimation("Jump",false);
} else {
spineAnim.state.SetAnimation("Jump",false);
}
}
}
Setting the animation in this way does not work however. I get a NRE saying the object reference not set to an instance of an object. Am I using SetAnimation incorrectly? In other examples I see around here people using ....SetAnimation(0,"Jump",false); but I don't have any of those overloads.
Thanks for any help.