- Home /
 
               Question by 
               Juhsi · Oct 27, 2013 at 12:06 PM · 
                animationdistanceloopanimationclip  
              
 
              Play animation if Player is close within certain distance.
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 (:
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
How to play many animations at once without slowdown? 3 Answers
Animation keeps playing 2 Answers
Animation not looping 1 Answer
How to Serialize an AnimationState 0 Answers
Parameterized Animation Clip 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                