Question by
Koehler_Games · Jun 25, 2019 at 02:21 PM ·
enemy aichase
Why is my enemy AI hovering over ground while chasing player
The enemy AI is hovering over the ground when it is chasing me and I am not sure how to fix it. Here is my script (My screenshot that is 1 mb is apparently to large):
using UnityEngine;
using System.Collections;
public class followplayer : MonoBehaviour
{
Transform player;
float f_RotSpeed = 3.0f, f_MoveSpeed = 3.0f;
// Use this for initialization
void Start()
{
player = GameObject.FindGameObjectWithTag("Player").transform;
}
// Update is called once per frame
void Update()
{
/* Look at Player*/
transform.rotation = Quaternion.Slerp(transform.rotation
, Quaternion.LookRotation(player.position - transform.position)
, f_RotSpeed * Time.deltaTime);
/* Move at Player*/
transform.position += transform.forward * f_MoveSpeed * Time.deltaTime;
}
}
Comment
Your answer
