I know that there's two or three posts about it, but I read, did almost the same thing the guys were doing,
and still need to press again, to make my character move, if I just keep the button pressed it will be still.
Can someone help me with that? Here is my code:
public class TutorialAnimController : MonoBehaviour
{
tk2dAnimatedSprite anim;
// Use this for initialization
void Start () {
anim = GetComponent<tk2dAnimatedSprite>();
}
bool walking = false;
float movespeed = 0.1f;
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.A))
{
anim.Play("hit");
anim.animationCompleteDelegate = HitCompleteDelegate;
this.transform.position = new Vector3(this.transform.position.x-movespeed, this.transform.position.y, 0);
}
if (Input.GetKeyDown(KeyCode.D))
{
anim.Play("walk");
anim.animationCompleteDelegate = null;
walking = true;
this.transform.position = new Vector3(this.transform.position.x+movespeed, this.transform.position.y, 0);
}
if (Input.GetKeyDown(KeyCode.W))
{
anim.Play("idle");
anim.animationCompleteDelegate = null;
walking = false;
}
}
}