Hello and first of all thanks for reading this message and help me.
Need to know the code to be created to ensure that when click the mouse on the screen, can position an object in the x and y coordinates where I did that mouse click.
I was trying to create a code but this not work. This is part of the code that had tried:
public class SceneGame1 : MonoBehaviour {
public Vector2 mouseClic;
public float coordXMouse;
public float coordYMouse;
void Update()
{
if ( hit.collider.name == "objet-colision" )
{
mouseClic = Input.mousePosition;
coordXMouse = mouseClic.x;
coordYMouse = mouseClic.y;
Debug.Log (mouseClic);
GameObject.Find("object-to-move-on-screen").transform.position(coordXMouse,coordYMouse);
}
}
}
I have read that I have to use ScreenToWorldPoint, but can not find the code I need.
Thank you very much.