Hello. So I made a simple animation and attached it to the main character. I was hoping that as I push down the button that makes the character move right that the animation will play while holding the button down, either I didn’t do it correctly or it wasn’t correct in the first place. How can I do this?
( For easy clarification )
I want a specific set animation to play while holding a button down with or without this script
using UnityEngine;
using System.Collections;
public class Move2 : MonoBehaviour
{
public float speed = 5f;
private bool mouseDown = false;
public void OnMouseDown ()
{
mouseDown = true;
}
public void OnMouseUp()
{
mouseDown = false;
}
public void Update()
{
if(mouseDown){
transform.position -= Vector3.left * speed * Time.deltaTime;
}
}
}