I am trying to make a script where the zombie looks for the player and if the player enters the boundaries it will start chasing it. My problem is that I can’t attach my player to the script in the inspector and I am unsure why. I don’t have a problem with the code(at least I don’t think so) only with it not attaching. The player is a prefab from the unity Standard assets.
Edit: The script is attached to a prefab in my assets. The player in in the hierarchy.
Just in case here is my code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ZK_attack : MonoBehaviour
{
public Transform Player;
public float MoveSpeed = 4.5f;
public float MaxDist = 4.0f;
public float MinDist = 1.5f;
private Coroutine animat = null;
private Animator anim;
void Update()
{
transform.LookAt(Player);
if (Vector3.Distance(transform.position, Player.position) >= MinDist)
{
transform.position += transform.forward * MoveSpeed * Time.deltaTime;
anim.SetBool("inRadius", true);
if (Vector3.Distance(transform.position, Player.position) <= MaxDist)
{
anim.SetBool("AttackingPlayer", true);
}
}