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 halycon · Nov 10, 2010 at 10:36 PM · rotationmouselerp

Mouse controls sometimes "bounces"

I want to build a bare-bones space flight/combat sim for class and I ran into some trouble with the mouse controls. I want the player avatar to "look" around using the mouse. The mouse-axes determine X and Y rotation. The problem is when I move the mouse too fast from the left to right (or vice versa), the camera will "bounce", as though it decided to move the opposite way before going the correct way. If I continually move the mouse extremely quickly, the bouncing motion will become more frequent. Here's the code snippet for my current mouse controls:

// Change cummulative rotation based on mouse input
cummulativeRotation.x -= Input.GetAxis("Mouse Y") * Time.deltaTime * rotationFactor;
cummulativeRotation.y += Input.GetAxis("Mouse X") * Time.deltaTime * rotationFactor;
// Create the target rotation from the cummulative rotatons
Quaternion targetRotation = Quaternion.Euler(cummulativeRotation.x, cummulativeRotation.y, 0.0f);
currentRotation = Quaternion.Slerp(currentRotation, targetRotation, ROTATION_DAMP * Time.deltaTime);

And the variables:

// Rotation private Quaternion currentRotation; private Vector3 cummulativeRotation; public float rotationFactor = 200.0f;

// Dampening private const float ROTATION_DAMP = 3.0f;

Just a note, I tried changing rotationFactor to 2000.0 and the bouncing effect was much more prominent. In fact I could not move my mouse at all without experiencing it. I assume the rpoblem lies with Quaternion.Lerp and how it treats angles but I'm not sure how to solve it. I tried implementing this with Mathf.Lerp and Mathf.LerpAngle. Both methods have the same problem. Any suggestions or alternative methods I could use would be appreciated.

Comment
Add comment
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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by gava100 · Feb 02, 2012 at 07:03 PM

Hello,

I'm getting exactly the same problem. Have you got any solution for that?

Thx.

Rafael

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
avatar image
0

Answer by gava100 · Feb 03, 2012 at 12:18 PM

Hello,

try to change the value of ROTATION_DAMP or instead of using Time.deltaTime try Time.time.

Regards

Gava

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
avatar image
0

Answer by gava100 · Feb 03, 2012 at 12:18 PM

Hello,

try to change the value of ROTATION_DAMP or instead of using Time.deltaTime try Time.time.

Regards

Gava

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

1 Person is following this question.

avatar image

Related Questions

How can I Lerp the Rotation of my Game Object to my Mouse Pointer? 1 Answer

spinning an object with mouse movement 1 Answer

Smooth camera rotation on mobile and pc when GetMouseButton()? 0 Answers

How do I rotate Z axis based off mouse click and drag? 2 Answers

Problem with rotation script. 3 Answers


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