Hi, I’m starting in unity3D and I’m doing the tutorial and testing everything that I can.
Now I’m trying to modify one of the script from “PROJECT: SURVIVAL SHOOTER”, so the enemies follow the CapsuleCollider’s center of the player instead of the player’s center.
I have tried with GameObject.FindGameObjectWithTag ("Player").GetComponent(SphereCollider).center
and nav.SetDestination (player);
but it doesn’t work.
These is the script I want to modify.
public class EnemyMovement : MonoBehaviour
{
Transform player;
NavMeshAgent nav;
void Awake ()
{
player = GameObject.FindGameObjectWithTag ("Player").transform;
nav = GetComponent <NavMeshAgent> ();
}
void Update ()
{
nav.SetDestination (player.position);
}
}
Thanks in advance and sorry if my English is not good.