My purpose is control the graviry setting by clip's time.
For example I edit a clip(010s) , 09s has gravity and no gravity at 10s.
When I play a clip attack_01 not loop , when the clip play over , I cannot get the entry, code is
SkeletonAnimation sa;
Rigidbody2D rigid;
// Use this for initialization
void Start()
{
rigid = this.GetComponent<Rigidbody2D>();
sa = this.GetComponent<SkeletonAnimation>();
sa.state.SetAnimation(0, "attack_01", false);
}
void Update()
{
if(sa.state.GetCurrent(0) == null)
{
Debug.LogError("Cannot get the entry!");
return;
}
if (sa.state.GetCurrent(0).time == 10)
{
rigid.gravityScale = 0;
}
else if (sa.state.GetCurrent(0).time >= 0)
{
rigid.gravityScale = 1;
}
}
Then I cannot get the entry , so is there a method help me get the clip time as 10s ?
Is there a method can set the clip stay the last frame when it complete?