Advertisement
Guest User

Untitled

a guest
Nov 16th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.48 KB | None | 0 0
  1. void Update()
  2.     {
  3.         // Input for PC/Mouse
  4.         if (Input.GetButtonDown("Fire1") || Input.touchCount > 0)
  5.         {
  6.             Debug.Log("click recognised");
  7.             Ray ray = cam.ScreenPointToRay(Input.mousePosition);
  8.             RaycastHit hit;
  9.             if (Physics.Raycast(ray, out hit, 500f))
  10.             {
  11.                 Debug.Log(hit.collider.name);
  12.                 if (hit.collider.name == "Ground")
  13.                 {
  14.                     //Move the player to what we hit
  15.                     //stop focusing any objects
  16.  
  17.                     motor.MoveToPoint(hit.point);
  18.                     removeFocus();
  19.  
  20.                 }
  21.                 else
  22.                 {
  23.                     Debug.Log("Checking interactable");
  24.                     // Check if we hit an Interactable
  25.                     Interactable interactable = hit.collider.GetComponent<Interactable>();
  26.                     //If we did, set it as our focus
  27.                     Vector3 standpos;
  28.                     if (interactable != null)
  29.                     {
  30.                         if(hit.collider.name=="Market_Stall")
  31.                         {
  32.                            
  33.                             GameObject Stall = hit.collider.gameObject;
  34.                             standpos = Stall.transform.position;
  35.                             Vector3 offset = Stall.transform.position - hit.point;
  36.                             Debug.Log(transform.InverseTransformPoint(hit.point));
  37.                             Debug.Log("Stall Clicked at " + standpos + ", Rotation.y is " + Stall.transform.rotation.y);
  38.                             switch (Stall.transform.rotation.y)
  39.                             {
  40.                                 case 90:
  41.                                     {
  42.                                         Debug.Log("adjusting X pos");
  43.                                         standpos.x += 40;
  44.                                         motor.MoveToPoint(standpos);
  45.                                         break;
  46.                                     }
  47.                             }
  48.                         }
  49.                         //Vector3 standpoint = standpos.transform.position;
  50.                        
  51.                         //setFocus(interactable);
  52.                     }
  53.                     else
  54.                     {
  55.                         motor.MoveToPoint(hit.point);
  56.                         removeFocus();
  57.                     }
  58.                 }
  59.             }
  60.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement