- Home /
Question by
alexander11 · Aug 20, 2014 at 09:38 AM ·
collisionnavmeshagentnpcnav mesh
Nav mesh npc???
if i have a navmesh set up and a couple of npc's if i die will they still keep attacking????
this is the code for the npc and char mike geigs code
NPC code
using UnityEngine; using System.Collections; public class FollowScript : MonoBehaviour { NavMeshAgent agent; void Start () { agent = GetComponent<NavMeshAgent>(); } void Update () { agent.SetDestination (hit.point); } }
CHAR
using UnityEngine;
using System.Collections;
public class NavCharScript : MonoBehaviour {
NavMeshAgent agent;
void Start ()
{
agent = GetComponent<NavMeshAgent>();
}
void Update ()
{
if(Input.GetMouseButtonDown (0))
{
Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
RaycastHit hit;
if(Physics.Raycast(ray, out hit, 100))
{
agent.SetDestination (hit.point);
}
}
}
}
Comment