using System.Collections; using System.Collections.Generic; using UnityEngine; public class Player_Cursor : MonoBehaviour { public Camera main_Camera; public GameObject Player; // Update is called once per frame void Start(){ Cursor.visible = true; } void Update () { ClickOn(); } void ClickOn() { if (Input.GetMouseButtonUp(1)) { Ray camera_Ray = main_Camera.ScreenPointToRay(Input.mousePosition); RaycastHit hit_Ray; Physics.Raycast(camera_Ray, out hit_Ray); ClickableParent C = hit_Ray.collider.gameObject.GetComponent(); C.OnClick(Player.transform.position); } } public static Vector3 GetPositionClick(Camera C) //returns the point where the raycast hit on the ground { Ray camera_Ray = C.ScreenPointToRay(Input.mousePosition); RaycastHit hit; Physics.Raycast(camera_Ray, out hit); return (hit.point); } }