33 lines
689 B
C#
33 lines
689 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.AI;
|
|
|
|
public class CharacterMovement : MonoBehaviour
|
|
{
|
|
public NavMeshAgent playerNavMeshAgent;
|
|
|
|
public Camera playerCamera;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if(Input.GetMouseButton(0))
|
|
{
|
|
Ray myRay=playerCamera.ScreenPointToRay(Input.mousePosition);
|
|
RaycastHit hit;
|
|
|
|
if(Physics.Raycast(myRay, out hit))
|
|
{
|
|
playerNavMeshAgent.SetDestination(hit.point);
|
|
}
|
|
}
|
|
}
|
|
}
|