Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEngine.UI;
- using System.Collections;
- public class laikaController : MonoBehaviour {
- Camera cam;
- laikaMotor motor;
- public LayerMask movementMask;
- public UnityEngine.AI.NavMeshAgent agent;
- [SerializeField] GameObject interactable;
- public bool canInteract = false;
- public Text textOne;
- void Start() {
- cam = Camera.main;
- motor = GetComponent<laikaMotor>();
- }
- void Update() {
- Ray ray = cam.ScreenPointToRay(Input.mousePosition);
- RaycastHit hit;
- if (Input.GetMouseButtonDown(0)) {
- {
- if (Physics.Raycast(ray, out hit, 100, movementMask)) {
- motor.moveToPoint(hit.point);
- agent.speed = 3.5f;
- }
- }
- }
- }
- private void OnTriggerEnter(Collider other) {
- if(other.gameObject.tag == "Interactable") {
- print("interacting");
- agent.speed = 0f;
- canInteract = true;
- }
- }
- void OnTriggerExit() {
- canInteract = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement