- Home /
input from mouse relative to screen dimensions- how to
I saw a few-lines-long code for it on forums somewhere, but I can't find it
in the effect of it, however if the mouse was in the centre of the screen - it gave my variable the value 0, if it started moving towards right (or left) side of the screen it gradually gained value, till it gained - for example 90.
so the var valueMouseX was 0 when mouse was in the middle, and if mouse was moved to right or left side - the value grew along with the distance - of the mouse - from the centre of the screen.
same thing coudl be done with MouseY.
do you have an idea what I'm talking about, and/or how to construct such a script? Thank you.
Answer by dot · Oct 01, 2010 at 12:13 AM
ah. it was something like this :
var mouseX = 0;
function Update() { mouseX = 90 * ((Input.mousePosition.x - Screen.width / 2) / (Screen.width / 2)); }
if someone's interested.
And once you have the mouseX position then you should do something like "Set$$anonymous$$ousePosition",don't you?
I need to set the cursor of my mouse n the center of the screen...And I can't understand why this feature hasn't been implemented in the First Control Person Controller of the Unity Standard Assets...Any help?
It's in Screen.LockCursor- although, be aware that this also makes your cursor invisible.
Ahhh...I've checked this early this morning and discovered this: why this people want their mouse pointer get disappeared from the screen?. I didn't realise that users want this double feature because after this, they substitute their common mouse pointer with another sprite or 3D object (as I was desiring in tehe next phase...) . So, Thank you!. These are things that we learn when we've never make a FPS game. I'm gonna continue with it then. I'd like to watch my common mouse pointer at this phase/stage in my personal developement but I could skip this. thanks!
Your answer
Follow this Question
Related Questions
Screen.lockCursor not working? 3 Answers
Script wont read array 2 Answers
How to make something happen when mouse on side of screen? 1 Answer
Mouse position script... 0 Answers