The question is answered, right answer was accepted
getting maximum x and y values of mouse position
hey. I want to get maximum x and y values of mouse position when the player pressing the mouse key. i got the values of all the x's and y's. but i can't figure out how can i eliminate maximum ones and stock in variables. here's my code:
void FixedUpdate () {
if (Input.GetMouseButton (0)) {
Vector3 posa = Camera.main.ScreenToWorldPoint (Input.mousePosition);
float x = posa.x;
float y = posa.y;
Debug.Log (x);
Debug.Log (y);
}
}
so this is my console. those values are x position of my mouse when i press and swipe my mouse. i want to get the biggest value ( in this pic it's 0.2375) and use it as a vector in order to move an object. i want to make simple swipe gesture or something like that. by the way i am new at coding.
Answer by rjth · Nov 29, 2016 at 10:59 AM
Your maximum mouse position value will always be the current screens width or height.
For x axis use Screen.width
, for the y Screen.height
.
I am sorry i couldn't explain myself. i can already get V1. it's not a problem. so my object moving in a straight path. but i want to add some curves to movement. so i think if i could get maximum x position that mouse reached when it's pressed and use it as a vector and at some point later if i give the opposite x vector my object will move curvedly.