aboutsummaryrefslogtreecommitdiff
path: root/Assets/Scripts/Player/PlayerMovement.cs
blob: 8f02b5bba8ce6034567d7e5d5d2626942b80050d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*******************************************************************************
*
*    Unicity (Project SimLife): A Sims clone written in Unity C#
*    Copyright (C) 2019 Unicity Development Team
*
*    This software is protected by the copyright and licensing rights held
*    by the Unicity Development Team. (2019)
*
*********************************************************************************/
using UnityEngine;
using UnityEngine.AI;

public class PlayerMovement : MonoBehaviour
{
    NavMeshAgent agent;

    // Start is called before the first frame update
    void Start()
    {
        agent = GetComponent<NavMeshAgent> ();
    }

    // Update is called once per frame
    void Update()
    {
       if(Input.GetMouseButtonDown(0))
       {
           RaycastHit hit;
           Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
           if(Physics.Raycast(ray, out hit, Mathf.Infinity))
           {
               agent.SetDestination(hit.point);
           }
       }
    }
}