- Home /
 
script not working on second character
so i have a script here it works fine but then it doesnt work on the second character even thou they are copys of each other anybody know what im doing wrong
 var waypoint : Transform[];
 
               static var speed : float = 5; private var currentWaypoint : int;
function Update () {
 var Enemy = GameObject.FindWithTag ("Enemy");
 
 
     if ( Vector3.Distance(Enemy.transform.position, transform.position ) < 3) {
     transform.LookAt(Enemy.transform);
     print("suck mun dee");
     rigidbody.constraints = RigidbodyConstraints.FreezePositionX |RigidbodyConstraints.FreezePositionZ|RigidbodyConstraints.FreezePositionY;
 }
 
  if(currentWaypoint < waypoint.length)
     {
     
         var target : Vector3 = waypoint[currentWaypoint].position;
         var moveDirection : Vector3 = target - transform.position;
         var velocity = rigidbody.velocity;
         if(moveDirection.magnitude < 1)
         {
             currentWaypoint++;
         }
         else
         {
             velocity = moveDirection.normalized*speed;
         }
                      rigidbody.velocity = velocity;
     }
    
 }
 
              
               Comment
              
 
               
              Answer by Eric5h5 · Feb 19, 2012 at 05:41 AM
For one thing it's using a static variable; never use those unless you specifically mean for it to be static, which you don't if you're using a script on more than one object.
Your answer
 
             Follow this Question
Related Questions
Jump Script, no luck getting it to work.. 2 Answers
Pickup script not workimg 0 Answers
Door script not working when door is turned 90 degrees 1 Answer
Walking script not working need help 1 Answer