Question by 
               RevivedBear · Oct 18, 2015 at 09:07 AM · 
                c#unity 5vector3  
              
 
              enemy AI help: no movement! C#
Hello, I need help with my enemy AI in csharp, the theory is that the enemy moves left and then right and repeats for ever. The problem is it only ever moves in one direction and there are errors with my void functions. someone please help, code below:
using UnityEngine; using System.Collections;
public class enemyAI : MonoBehaviour {
 private float rightDistance;
 private float leftDistance;
 
 public void moveRight(float rightDistance)
 {
     rightDistance = 0.02f;
     transform.position = new Vector3(transform.position.x + rightDistance, transform.position.y, transform.position.z);
     yield return new WaitForSeconds(1);
 }
 public void moveLeft(float leftDistance)
 {
     leftDistance = 0.02f;
     transform.position = new Vector3(transform.position.x - leftDistance, transform.position.y, transform.position.z);
     yield return new WaitForSeconds(1);
 }
 public IEnumerator move ()
 {
     int i = 0;
     while (i < 10)
     {
         moveRight();
         yield return new WaitForSeconds(1);
         moveLeft();
     }
 }
 // Update is called once per frame
 void Update () 
 {
     StartCoroutine(move());
 }
}
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                