Hi Guys,
Just got the 2dtoolkit and its good.
However, I am new to unity coding and am having trouble making the animation play correctly.
The following confuses me.
It says that the CurrentClip name is "walkRight" -
If this is true it should not re-trigger the animation -
But it seems to be re-triggering the animation every frame anyway?
I must be missing something, (perhaps to do with the delgate, which I have bypassed)
Any advice would be appreciated -
Here is the snippet,
Debug.Log( "current anim " + anim.CurrentClip.name);
if (anim.CurrentClip.name != "walkRight") {
anim.Play("walkRight");}
And here is the full code -
void Update ()
{
Debug.Log( "PLaying" + anim.Playing);
if ( Xdest > transform.position.x )
{
Debug.Log( "current anim " + anim.CurrentClip.name);
if (anim.CurrentClip.name != "walkRight") {
anim.Play("walkRight");}
//anim.Play("walkRight");
//anim.animationCompleteDelegate = null;
transform.Translate(new Vector3(1,0,0));
walkingRight = true;
}
else if ( Xdest < transform.position.x)
{
if (anim.CurrentClip.name != "walkLeft") {
anim.Play("walkLeft");}
//anim.Play("walkLeft");
//anim.animationCompleteDelegate = null;
transform.Translate(new Vector3(-1,0,0));
walkingLeft = true;
Debug.Log( "current anim " + anim.CurrentClip.name);
}
else
{
anim.Play("idle");
anim.animationCompleteDelegate = null;
}
}
}
Thanks,
BLueLotus.