Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Update()
- {
- // Input for PC/Mouse
- if (Input.GetButtonDown("Fire1") || Input.touchCount > 0)
- {
- Debug.Log("click recognised");
- Ray ray = cam.ScreenPointToRay(Input.mousePosition);
- RaycastHit hit;
- if (Physics.Raycast(ray, out hit, 500f))
- {
- Debug.Log(hit.collider.name);
- if (hit.collider.name == "Ground")
- {
- //Move the player to what we hit
- //stop focusing any objects
- motor.MoveToPoint(hit.point);
- removeFocus();
- }
- else
- {
- Debug.Log("Checking interactable");
- // Check if we hit an Interactable
- Interactable interactable = hit.collider.GetComponent<Interactable>();
- //If we did, set it as our focus
- Vector3 standpos;
- if (interactable != null)
- {
- if(hit.collider.name=="Market_Stall")
- {
- GameObject Stall = hit.collider.gameObject;
- standpos = Stall.transform.position;
- Vector3 offset = Stall.transform.position - hit.point;
- Debug.Log(transform.InverseTransformPoint(hit.point));
- Debug.Log("Stall Clicked at " + standpos + ", Rotation.y is " + Stall.transform.rotation.y);
- switch (Stall.transform.rotation.y)
- {
- case 90:
- {
- Debug.Log("adjusting X pos");
- standpos.x += 40;
- motor.MoveToPoint(standpos);
- break;
- }
- }
- }
- //Vector3 standpoint = standpos.transform.position;
- //setFocus(interactable);
- }
- else
- {
- motor.MoveToPoint(hit.point);
- removeFocus();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement