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 MithosAnnar · Sep 21, 2012 at 12:08 PM · positionmouserotatepivotx

Is There An OnMouseStop?

Ok let me try to explain this as simply as possible.

When the player clicks, a pivot point from where he clicked is made, this pivot point will be the position of the mouse cursors 'x' position at the time it was pressed.

 if (Input.GetMouseButtonDown(0)) {
             
    mPos_1 = Input.mousePosition.x;
             
 } 

From then on, the mouse cursors 'x' position will be recorded and compared to the pivot point. This will rotate the player.

    mPos_2 = Input.mousePosition.x;
             
    rotationSpeed = 2 * (mPos_2 - mPos_1);
                         
 if (rotationSpeed > 25) { rotationSpeed = 25; }
             
 if (rotationSpeed < - 25) { rotationSpeed = - 25; }
         
    myTransform.Rotate (0, rotationSpeed * Time.deltaTime, 0);

I need to know when the mouse has stopped moving so our player does not continue to rotate.

Thanks for reading! I would like to ask for the simplest possible way of achieving this.

Cheers!

Mithos

Comment
Add comment · Show 4
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 Fattie · Sep 21, 2012 at 12:39 PM 0
Share

you have to keep the previous position.

look at the new position

if they are the same ... the mouse has not moved.

avatar image MithosAnnar · Sep 21, 2012 at 12:47 PM 0
Share

In "Objective - c" you can apply something called a "watcher" to a float value.

The watcher sees the number changing and also if the number has stopped.

Do we have something like that in c#?

avatar image Fattie · Sep 21, 2012 at 12:57 PM 1
Share

i have no idea, because I hate computer languages.

It sounds like you are an advanced programmer .. as you can see, you simply have to program it in a stateful manner.

(ie, "you need a variable")

it is an incredibly simple situation.

to be honest i'd just use a variable every time when program$$anonymous$$g interface so it's "if nowPosition != previousPosition"

you see that in every bit of code relating to handling mouse, touch movement

I've certainly programmed this an awfully, awfully lot in XCode and I've never felt it would be a good idea to use a watcher there. so to be honest i'd give it a miss here, even if UnityScript has a watcher concept. To find out if U/S has a watcher concept, ask a new question and some expert here will know.

you may enjoy this article-lenth answer on unity interface

http://answers.unity3d.com/questions/292333/how-to-calculate-swipe-speed-on-ios.html

pls vote up if enjoyable :) nobody votes that answer up, I don't believe it! ;)

avatar image MithosAnnar · Sep 21, 2012 at 01:02 PM 0
Share

Ok Fattie! +1

Im so used to using watchers thats all.

I found unity didn't have one and was like wut?

So yeah! Thanks a bunch for being the usual incredibly helpful forum guy!

Cheers ^^

$$anonymous$$ithos

0 Replies

· Add your reply
  • Sort: 

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

10 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

Related Questions

Camera rotation around player while following. 6 Answers

Rotate plane on a pivot to the mouse position (in 2D) 1 Answer

Arbitrary rotation around a point works except when up flips? 1 Answer

something to do with pivot 1 Answer

Camera Rotate to mouse position -2 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