29 lines
602 B
C#
29 lines
602 B
C#
![]() |
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.AI;
|
||
|
|
||
|
public class Boat : MonoBehaviour
|
||
|
{
|
||
|
private NavMeshAgent agent;
|
||
|
|
||
|
private void Awake()
|
||
|
{
|
||
|
agent = GetComponent<NavMeshAgent>();
|
||
|
}
|
||
|
|
||
|
private void Update()
|
||
|
{
|
||
|
if (Input.GetMouseButtonDown(0))
|
||
|
{
|
||
|
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||
|
RaycastHit hit;
|
||
|
|
||
|
if (Physics.Raycast(ray, out hit, 1000f))
|
||
|
{
|
||
|
agent.SetDestination(hit.point);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|