I want to rotate a GameObject through mouse movement between -20° and +20°.
I know that there's a possibility to grab the smoothed Input through
Input.GetAxis("Horizontal");
and Input.GetAxis("Vertical");
which returns float values between -1
and 1
It would be nice if there would exist something like
Input.GetMouseAxis("Horizontal");
or Input.GetMouseAxis("Horizontal");
.
But I the output shouldn't be influenced by keyboard. I'm sorry that I don't have much experience with Unity and its API.
In this case the "normalizedSpeed" will be your target
i use sqrMagnitude instead of distance because the sqr root call in distance() takes alot of memory, so it is faster to compare the squared distances vs each other
Also keep in mind im wirting this as a pseudo-code so the overall idea is what im going for, im leaving you syntactically responsible for the implementation ;)