using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class ZombieAI : MonoBehaviour
{
private NavMeshAgent Zombie;
[SerializeField] private static GameObject Zombro;
[SerializeField] public static GameObject Player;
float dist = Vector3.Distance(Player.transform.position, Zombro.transform.position);
[SerializeField] private Animator myAnimationController;
// Start is called before the first frame update
void Start()
{
GetComponent<Animation>();
Zombie = GetComponent<NavMeshAgent>();
}
// Update is called once per frame
void Update()
{
Zombie.SetDestination(Player.transform.position);
if(dist > 1)
{
myAnimationController.SetBool("attack1", true);
}
}
}
The fields “Zombro” and “Player” do not show up in the inspector of unity, what am I doing wrong??
I was having the same issue but my problem was a little bit different. [SerializedField] variables weren’t showing up because Visual Studio wasn’t connected properly to Unity, so the changes I was making weren’t reflected in Unity properly. Because my script was so small, I didn’t bother putting in the time to figure out why Visual Studio wasn’t connecting to Unity properly, so as a temporary solution, I just refreshed the C# script in Unity and then the Fields showed up.