Enemys velocity in 2D platformer
Trying to create an enemy's AI, using unity. But enemy just stops on the place and twitch. I think, it's smth with my mind 'cause I can't fix that for 3 hours. Thanks in advance.
void Start () {
     rb = GetComponent<Rigidbody2D>();
     player = GameObject.FindGameObjectWithTag("Player").GetComponent<Transform>();
 }
 public void FixedUpdate()
 {
    if (player.transform.position.x > this.transform.position.x) { FacingLeft = false; Facing = 1; } else { FacingLeft = true; Facing = -1; }
     if (FacingLeft == true)
     {
         Checker.transform.position = new Vector3(this.transform.position.x - 4f, this.transform.position.y, this.transform.position.z);
         
         rb.velocity = new Vector2(2*-speed, rb.velocity.y);
     }
     else { Checker.transform.position = new Vector3(this.transform.position.x + 4f, this.transform.position.y, this.transform.position.z);
         
         rb.velocity = new Vector2(rb.velocity.x, rb.velocity.y);
     }
            
     if (isGround = Physics2D.OverlapCircle(Checker.transform.position, checkRadius)) {rb.velocity = Vector2.up * JumpForce; }
 }
     void Flip()
 {
     FacingLeft = !FacingLeft;
     Vector3 Scaler = transform.localScale;
     Scaler.x *= -1;
     transform.localScale = Scaler;
 }
}
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                