im building Bubbles game, i need to detect mouse click event on screen and to project a Bubble from the center of the buttom of the screen,to the clicking point, i got no problem with creating the momvent once i know the cordinates.
How do i detect the clickng event and how do i translate it to the world cordinates?
This will allow you to convert a position from screen space to world space. Now you need to take the screen space of the mouse and convert that like so:
camera.ScreenToWorldPoint( Input.mousePosition );
In order to detect that event you can listen to it in an update function like so:
var cameraloc:Camera;
var mousePos:Vector3;
var worldPos:Vector3;
cameraloc = GameObject.Find(“Camera”).GetComponent(Camera);
mousePos = Input.mousePosition;
worldPos = cameraloc.ScreenToWorldPoint(mousePos);
This will return a world position of the place where you clicked, it works except you have to manually set the z axis.