Sorry, this is probably a super simple question, but I’m struggling.
Basically, I have a box collider set up in my scene. I want it to be where the player will enter the box collider and this will trigger the NPC to move to a specific point. It’s a one time trigger that deactivates.
I’m having two problems. The first is that the NPC’s walk animation doesn’t work. It’ll play for one second and then stop, but I want it to continuously play while he’s walking. The second is that for some reason the NPC just won’t move to the target? This is the code I’m using:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LZBOutsideTrigger : MonoBehaviour
{
[Header(“Zombie Boy Movement”)]
[SerializeField] private Animation myLZB = null;
public Transform target;
public Transform boy;
public float speed;
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag(“Player”))
{
myLZB.Play(“Take001”);
Vector3 a = boy.position;
Vector3 b = target.position;
boy.position = Vector3.MoveTowards(a, b, speed);
gameObject.SetActive(false);
}
}
}
Any help would be very much appreciated!