**Put the code below inside Update function havent tested the code but it should work**
public GameObject mygameobject;
if(Input.GetKey("w")) {
if(!mygameobject.animation.IsPlaying("urWalkAnimationName"))
{
mygameobject.animation.Play("urWalkAnimationName");
animation["urWalkAnimationName"].speed= 0.4f;
} }
if(Input.GetKey("r")) {
{
if(!mygameobject.animation.IsPlaying("urRunAnimationName"))
{
mygameobject.animation.Play("urRunAnimationName");
animation["urRunAnimationName"].speed= 0.4f;
} }
↧