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
1
Question by Azaroth · Apr 29, 2013 at 05:35 PM · movementmousedetect

Detect Mouse Movement

Hello guys, i want to recognize the mouse movement (if it went left, or right, or back etc). How can i do that?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by ExTheSea · Apr 29, 2013 at 05:41 PM

 Input.GetAxis("Mouse Y") //returns the Y-Axis and
 Input.GetAxis("Mouse X") //return the X-Axis value the mouse is currently at

Also this links may help you: http://answers.unity3d.com/questions/10443/how-to-rotate-an-objects-x-y-z-based-on-mouse-move.html

http://answers.unity3d.com/questions/123647/how-to-detect-mouse-movement-as-an-input.html

Comment
Add comment · Show 8 · 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 Azaroth · Apr 29, 2013 at 05:43 PM 0
Share

Hello, thank youm i just want to ask what about back-forth and how can i detect if the mouse has moved more than a specific number of cm :D

avatar image ExTheSea · Apr 29, 2013 at 06:02 PM 0
Share

The moving more than a specific amount can be solved with this code: http://answers.unity3d.com/questions/28089/mouse-movement-.html what do you mean by back-forth?

avatar image Azaroth · Apr 29, 2013 at 06:08 PM 0
Share

In that code mouseThreshold is 0.2 cm? I mean backward and forward :D

avatar image ExTheSea · Apr 29, 2013 at 06:19 PM 0
Share

From what i know getaxis returns a value between -1 and 1 so no i don't think they are cm. You have to do some conversation and some google search to find out the scale.

The script i linked to with forward- and backward-detection:

     var mousexThreshold = 0.2;
     var mouseyThreshold = 0.2;
     function Update()
     {
     var mousex : float = Input.GetAxis ("$$anonymous$$ouse X");
     var mousey : float = Input.GetAxis ("$$anonymous$$ouse Y");
      
     if (mousex > mousexThreshold)
     {
     // Code for mouse moving right
     }
     else if (mousex < -mousexThreshold)
     {
     // Code for mouse moving left
     }
     else
     {
     // Code for mouse standing still
     }
 
     if (mousey > mouseyThreshold)
     {
     // Code for mouse moving forward
     }
     else if (mousey < -mouseyThreshold)
     {
     // Code for mouse moving backward
     }
     else
     {
     // Code for mouse standing still
     }
     }

Hope this helps.

avatar image Azaroth · Apr 30, 2013 at 06:39 AM 0
Share

I will test and tell you thanx!

Show more comments

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

14 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Detecting which way my mouse is moving the most 1 Answer

How to detect double and single clicks using javascript? 1 Answer

How do I detect a mouse hover? 1 Answer

moving an object with mouse ( my script is not smooth enough ) 0 Answers

Making my 2d character's arm follow the mouse, scrpit not working, please help :c 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