Created
April 3, 2018 04:58
-
-
Save JoseRFJuniorLLMs/c23fd79ce91bcb379f8ab5d167d36b14 to your computer and use it in GitHub Desktop.
PlayerController.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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