Hey, I have a problem about play animation.
The script is not work. My animation just play a clip for a loop continuously without count distance when I Start the game.
How can I figure that?
using UnityEngine;
using System.Collections;
public class Penguin_ani : MonoBehaviour {
public AnimationClip clipName ;
public float reachDistance;
public GameObject Player;
public GameObject Target;
void Start () {
reachDistance =Vector3.Distance(Player.transform.position,Target.transform.position);
if(reachDistance < 5.0f){
animation.wrapMode = WrapMode.Loop;
animation.Play(animation.clip.name);
animation[animation.clip.name].speed = 0.1f;
Debug.Log(reachDistance);
}
}
// Update is called once per frame
void Update () {
}
}
Thanks for the help (: