Skip to content

Instantly share code, notes, and snippets.

@JoseRFJuniorLLMs
Created April 3, 2018 04:58
Show Gist options
  • Select an option

  • Save JoseRFJuniorLLMs/c23fd79ce91bcb379f8ab5d167d36b14 to your computer and use it in GitHub Desktop.

Select an option

Save JoseRFJuniorLLMs/c23fd79ce91bcb379f8ab5d167d36b14 to your computer and use it in GitHub Desktop.
PlayerController.cs
using UnityEngine;
using UnityEngine.AI;
public class PlayerController : MonoBehaviour {
//Variavel da Camera
public Camera cam;
public NavMeshAgent agent;
// Atualiza na hora que inicia o jogo
void Update () {
//Se for apertado o botão direito do Mouse
if (Input.GetMouseButtonDown(0)) {
// O local da posição do mouse onde foir apertado
// torna-se o ponto
Ray ray = cam.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
//AQUI QUE COMEÇA A IA
agent.SetDestination(hit.point);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment