- Home /
How do I get the x and y coordinates out of Input.mousePosition?
The question is pretty much self-explanatory.
I am looking for a way to get the x and y coordinates out of the current mouse position but can seem to find a way to 'isolate them'.
Also, is there a way to record only the initial mouse position and not having it record while the mouse is down?
Thanks in advance for the help ;)
Answer by Jorn · Aug 27, 2011 at 04:14 PM
To retrieve
float x = Input.mousePosition.x;
float y = Input.mousePosition.y;
and with mousedown
if(Input.GetMouseButtonDown(0))
{
float x = Input.mousePosition.x;
float y = Input.mousePosition.y;
},
Answer by SharksInteractive · Apr 17, 2018 at 12:05 AM
Thank you! I thought there might be something like that, but was to busy to search the documentation!
Your answer
Follow this Question
Related Questions
ScreenToViewportPoint offset from Input.mousePosition ? 1 Answer
Left Click While Holding Right Click 1 Answer
How to disable mouse click detection in game when clicking exit menu button? 1 Answer
does getmousebuttondown counts as physicaly clicking (for mobile games)? 1 Answer
Input System Can't Catch Event on Update 0 Answers