Need Help Fixing script

heres the code the enemy does follow me but he keeps on flying and not using the walking animation he also just tips over if anyone could help it would be much appreciated

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ZombieAI : MonoBehaviour {
    public float fpsTargetDistance;
    public float enemyLookDistance;
    public float attackDistance;
    public float enemyMovementSpeed;
    public float damping;
    public Transform fpsTarget;
    Rigidbody theRigidbody;
    Renderer myRender;


    // Use this for initialization
    void Start ()
    {
        myRender = GetComponent<Renderer> ();
        theRigidbody = GetComponent<Rigidbody> ();

    }
  
    //Update is called once per frame
    void FixedUpdate ()
    {
        fpsTargetDistance = Vector3.Distance (fpsTarget.position, transform.position);
        if (fpsTargetDistance < enemyLookDistance) {
            myRender.material.color = Color.yellow;
            lookAtPlayer ();
            print ("Look at Player Please");

        }
        if (fpsTargetDistance < attackDistance) {
            attackPlease ();
            print ("ATTACK!");
        }
    }

    void lookAtPlayer(){
        Quaternion rotation = Quaternion.LookRotation (fpsTarget.position - transform.position);
        transform.rotation = Quaternion.Slerp (transform.rotation, rotation, Time.deltaTime * damping);
    }


    void attackPlease(){
        theRigidbody.AddForce (transform.forward * enemyMovementSpeed);
  
    }
}

Maybe image or video would help… is that a top down game?
How the characters are animated? 3D? Does normal walking animation work?

Maybe open this (or other similar project) in separate project and see how they do it,

all animations work

You mention “tips over”, have you applied rotational constraints to the rigidbody?

1 Like

no how would i fix this issue

Look at the rigidbody in the inspector - it’ll have a set of checkboxes for constraining movement. Tick the ones to constrain rotation.

1 Like

Thanks