ScreenPointToRay
Hi im making a 2d game using javascript in which im trying to click on a cube with my mouse but its giving my errors . i was following an example on How To Perform A Mouse Click On Game Object http://answers.unity3d.com/questions/34795/how-to-perform-a-mouse-click-on-game-object.html. my code keeps telling me that Assets/MyProject/MyScripts/MousePosition.js(12,38): BCE0019: 'ScreenPointToRay' is not a member of 'MousePosition'.
and also Assets/MyProject/MyScripts/MousePosition.js(14,31): BCE0023: No appropriate version of 'UnityEngine.Physics2D.Raycast' for the argument list '(UnityEngine.Ray, UnityEngine.RaycastHit2D, float)' was found. here is my code any help would be great.
pragma strict
function Start () {
}
function Update () { if (Input.GetMouseButtonDown(0)) { var hit : RaycastHit2D; var ray : Ray = this.ScreenPointToRay (Input.mousePosition); } if (Physics2D.Raycast (ray, hit, 1.0)) { Debug.Log("hit.collider2d.name");
} }