Hi to all.
the speed of my mouse pointer slows. when the framerate is under sixty...
how can i put the speed of the mouse pointer in DELTATIME?
my actual code is
thanks in advance
asked Dec 08 '10 at 03:09 PM
You question doesn't make sense. "put the speed of the mouse pointer in deltaTime" is complete nonsense. What is that even supposed to mean?
You cannot change the speed of your mouse in Unity. You can change the sensitivity in the Input Settings which affects the responsiveness of Input functions, but that's about it.
Unity is generally processing and doing other resource-consuming stuff when your framerate begins to drop. If this is sufficiently CPU-intensive, leaving less available CPU capacity for your computer's OS's input mechanism to deal with your mouse input, this could also cause your mouse to be less responsive in general, not just in Unity. It is also possible that some other process is using system resources, leaving less for Unity, making it in an equally CPU-intensive setup that yields the same results. Whatever the cause, the issue is likely not one with the mouse necessarily, but with what you are doing in-between each frame that causes your framerate to drop. You should fix that issue in stead as framerate issues are very problematic in and of themselves.
OnGUI is called several times per frame and should update more often that Update, meaning that it is happening more often than your framerate would indicate, but it is still limited by the same problems above. Time.deltaTime is the amount of time it took to complete the last frame and makes little sense outside of the context of an Update function which is called only once per frame. See the docs for more.
answered Dec 08 '10 at 03:57 PM
I refer that when the frames per second go down 60 my leader of the mouse finds it hard to him to continue to mouseX, and to mouseY..
is there any solution??
answered Dec 09 '10 at 03:25 AM
If I'm understanding you, you want to calculate the absolute speed of the mouse pointer, without getting bad effects from the frame rate. In other words, when the frame rate is worse, the mouse jumps further between frames, even though the speed of the movement is the same.
The speed of the mouse is simply: the position change divided by the time it took to move that far. So all you need to do is divide the position change by deltaTime.
This code isn't tested, its just to give you an idea:
That's the theory, anyway. In practice, you may get noise and rounding issues. Simple example: if the frame rate is really fast, the timeDelta for some frames will be very very small, and the mouse pointer may not have moved to a new pixel. If you look at the velocity at just that one frame, you may think the mouse isn't moving.
If you are using the velocity every frame, then it's no big deal if the velocity rounds up or down each frame. But if you want to get the velocity at a single point in time, say when the player lets go of the mouse button, then you may need to average together the velocities of more than just the most recent frame.
Here's a link to similar Q&A on this topic, but for iOS drags rather than mouse pointer. Same idea though.
answered Apr 08 '11 at 02:30 PM