Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.AI;
- using UnityEngine.Networking;
- using UnityEngine.UI;
- public class Player : NetworkBehaviour
- {
- public LayerMask clickable;
- private NavMeshAgent player;
- // Use this for initialization
- void Start ()
- {
- if(!isLocalPlayer)
- {
- Destroy(this);
- return;
- }
- player = GetComponent<NavMeshAgent>();
- }
- // Update is called once per frame
- void Update ()
- {
- // Right click to move to desired position
- if (Input.GetMouseButton(1))
- {
- Ray myRay = Camera.main.ScreenPointToRay(Input.mousePosition);
- RaycastHit hitInfo;
- if (Physics.Raycast(myRay, out hitInfo, 100, clickable))
- {
- player.SetDestination(hitInfo.point);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement