Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by raul corrales · Dec 08, 2010 at 03:09 PM · mouseslowpointer

My mouse pointer is slow

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

function OnGUI
{
    var pos : Rect = Rect(mousePos.x,Screen.height - mousePos.y,64,64);
    GUI.Label(pos,cursorImage);
}

thanks in advance

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image skovacs1 · Dec 08, 2010 at 03:37 PM 0
Share

Please don't shout.

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by skovacs1 · Dec 08, 2010 at 03:57 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.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image raul corrales · Dec 09, 2010 at 06:17 PM 0
Share

0

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??

avatar image skovacs1 · Dec 09, 2010 at 06:43 PM 0
Share

??? What? That sentence makes even less sense. If I make some wild assumptions about what this sentence is supposed to mean, it would seem like you are repeating your question "the speed of my mouse pointer slows when the framerate is under sixty", but that was never in doubt. Again, the part that makes no sense is "put the speed of the mouse pointer in deltaTime". Repeating your question in a more confused and broken English only serves to confuse the issue further.

avatar image
0

Answer by raul corrales · Dec 09, 2010 at 03:25 AM

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??

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Eric5h5 · Dec 09, 2010 at 03:56 AM 0
Share

Don't post comments as answers.

avatar image
0

Answer by Bampf · Apr 08, 2011 at 02:30 PM

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:

var velocity; var speed;

if (Time.deltaTime > 0.0) { velocity = (newMousePos - oldMousePos) / Time.deltaTime; // velocity vector speed = velocity.Magnitude(); }

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

How to throw a rigidbody toward the mouse? 1 Answer

Get mesh name with mouse click, then change color (and other properties) of mesh 2 Answers

Get object at mouse position? (UI) 0 Answers

Mouse Pointer Transform.Position? 1 Answer

Two independant mouse cursors 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges