Question by 
               Denis1081 · Aug 02, 2018 at 02:36 AM · 
                2d game2d-platformer2d-physics2d-gameplay  
              
 
              How Do I stop AI Following player on the Y-axis?
I have code for an AI follow script in C#. At the moment the AI follow's the player just fine, although the AI begins to float and bounce up and down which is extremely frustrating and I've got no idea how to fix it. Also if you can I can't seem to get the animation to flip from left to right depending on the direction the AI is travelling either.
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class EnemyFollow : MonoBehaviour {
 
     public GameObject enemy;
     public float speed;
     private Transform target;
 
     // Use this for initialization
     void Start () {
         target = GameObject.FindGameObjectWithTag ("Player").GetComponent<Transform> ();
 
 
     }
     
     // Update is called once per frame
     void Update () {
         
         transform.position = Vector2.MoveTowards (transform.position, target.position, speed * Time.deltaTime);
 
 
     }
 }
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
The ban on going beyond the edge collider 0 Answers
Could someone help me with my 2D game project? 0 Answers
Ragdoll Movement Script, Help! 0 Answers
Unity 2D 5.2.2 How can I aim with keys towards an object? 2 Answers
2d platformer physics 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                