Files
SimUL/Assets/Scripts/CharacterMovement.cs
T
2022-08-17 11:14:32 +03:00

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);
}
}
}
}