My Enemy character models are walking through any objects and my FPS character model?
I am very new to Unity developing and I am completely lost as to why this is happening?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class ChaseScript : MonoBehaviour {
public Transform player;
static Animator anim;
public NavMeshAgent agent;
void Awake()
{
player = GameObject.FindGameObjectWithTag("Player").transform;
}
// Use this for initialization
void Start () {
anim = GetComponent<Animator>();
}
/*void OnTriggerEnter(Collider col)
{
Debug.Log(col.tag);
if(col.tag == "Player")
{
SceneManager.LoadScene(2);
}
}*/
// Update is called once per frame
void Update ()
{
agent.SetDestination(player.position);
Vector3 direction = player.position - this.transform.position;
if (Vector3.Distance(player.position, this.transform.position) < 10)
{
direction.y = 0;
this.transform.rotation = Quaternion.Slerp(this.transform.rotation,
Quaternion.LookRotation(direction), 0.1f);
anim.SetBool("isIdle", false);
if(direction.magnitude > 5)
{
this.transform.Translate(0, 0, 0.075f);
anim.SetBool("isWalking", true);
anim.SetBool("isAttacking", false);
}
else
{
anim.SetBool("isAttacking", true);
anim.SetBool("isWalking", false);
}
}
else
{
anim.SetBool("isIdle", true);
anim.SetBool("isWalking", false);
anim.SetBool("isAttacking", false);
}
}
}
Any help would be greatly appreciated.