Advertisement
Guest User

Laika controller

a guest
Jun 20th, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4.  
  5. public class laikaController : MonoBehaviour {
  6.  
  7. Camera cam;
  8. laikaMotor motor;
  9. public LayerMask movementMask;
  10. public UnityEngine.AI.NavMeshAgent agent;
  11. [SerializeField] GameObject interactable;
  12. public bool canInteract = false;
  13. public Text textOne;
  14.  
  15. void Start() {
  16. cam = Camera.main;
  17. motor = GetComponent<laikaMotor>();
  18. }
  19.  
  20. void Update() {
  21. Ray ray = cam.ScreenPointToRay(Input.mousePosition);
  22. RaycastHit hit;
  23.  
  24.  
  25. if (Input.GetMouseButtonDown(0)) {
  26. {
  27. if (Physics.Raycast(ray, out hit, 100, movementMask)) {
  28. motor.moveToPoint(hit.point);
  29. agent.speed = 3.5f;
  30. }
  31. }
  32. }
  33. }
  34. private void OnTriggerEnter(Collider other) {
  35. if(other.gameObject.tag == "Interactable") {
  36. print("interacting");
  37. agent.speed = 0f;
  38. canInteract = true;
  39. }
  40. }
  41. void OnTriggerExit() {
  42. canInteract = false;
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement