Hi, forgive me if this is stupid, I'm new to both 2d Toolkit and Unity. But I followed the documentation exactly until it came to scripting the animation and I made some changes and I'm not sure if I made them correctly or if I made enough. This is what the result looks like:
As you can see on the left there's no sprite, and when you run the game it's just a gray square. This is my code I'm running:
using System.Collections;
public class TutorialAnimController : MonoBehaviour
{
tk2dAnimatedSprite anim;
// Use this for initialization
void Start () {
anim = GetComponent<tk2dAnimatedSprite>();
}
bool walking = false;
void HitCompleteDelegate(tk2dAnimatedSprite sprite, int clipId)
{
if (walking)
{
anim.Play("walk");
}
else
{
anim.Play("idle");
}
}
// Update is called once per frame
void Update ()
{
if (Input.GetKeyDown(KeyCode.F))
{
anim.Play("hit");
anim.animationCompleteDelegate = HitCompleteDelegate;
}
if (Input.GetKeyDown(KeyCode.Space))
{
anim.Play("jump");
anim.animationCompleteDelegate = null;
walking = false;
}
if (Input.GetKeyDown(KeyCode.RightArrow))
{
anim.Play("walk");
anim.animationCompleteDelegate = null;
walking = true;
}
if (Input.GetKeyDown(KeyCode.LeftArrow))
{
anim.Play("walkleft");
anim.animationCompleteDelegate = null;
walking = true;
}
}
}Has anyone got the time to take a look at this and tell me what I'm doing wrong? Should I be naming the animation somewhere in the script? I'm not now. Should I even be doing this in scripting? Should I be doing this in Playmaker or something? I just tried to follow the documentation.
Please help. Thanks for reading.