Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Dartmor · Aug 20, 2015 at 07:05 AM · rigidbodygetcomponentspeedminimum

Set MINIMUM speed?

 GetComponent<Rigidbody> ().AddForce (Input.GetAxis ("Mouse X")+3000, 0f, Input.GetAxis ("Mouse Y" )+3000);
 
 

Don't work properly. Player start moving even if i don't move mouse at all.

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
0

Answer by GiyomuGames · Aug 20, 2015 at 07:15 AM

You are adding 3000 to the mouse movement values so it is normal that the player moves even if the mouse doesn't move. What are you trying to do?

Comment
Add comment · Show 3 · 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 Dartmor · Aug 20, 2015 at 07:19 AM 0
Share

if i move mouse just a little, i want player to move, but not too slow because i can control mouse movement, i can easily move mouse slowly, and player will move slowly too even if i add " * 10000 ", so i want it to move with at least certain $$anonymous$$imum speed even with little movement of mouse

avatar image GiyomuGames · Aug 20, 2015 at 07:33 AM 1
Share

Ok then you need to put a bit of logic like

 float $$anonymous$$Speed = 30f; // the $$anonymous$$imum speed
 float speed = 20f; // the additional speed if the mouse moves by "1"
 float movementThreshold = .1f; // the player will move only if the mouse moves more than this value
 
 float movementX = Input.GetAxis ("$$anonymous$$ouse X");
 if ($$anonymous$$athf.Abs(movementX) > movementThreshold)
 {
      movementX = $$anonymous$$athf.Sign(movementX) * ($$anonymous$$Speed + ($$anonymous$$athf.Abs(movementX) - movementThreshold) * speed);
 }
 
 float movementY = Input.GetAxis ("$$anonymous$$ouse Y");
 if ($$anonymous$$athf.Abs(movementY) > movementThreshold)
 {
      movementY = $$anonymous$$athf.Sign(movementY) * ($$anonymous$$Speed + ($$anonymous$$athf.Abs(movementY) - movementThreshold) * speed);
 }
 
 GetComponent<Rigidbody> ().AddForce (movementX, 0f, movementY);

Sorry I can't tell if this is exactly what you need or if it will work but it should get you closer to what you are trying to do. Basically it detects when the mouse moves more than a specific value (movementThreshold). If so then the force is at least $$anonymous$$Speed and you need to also add a force depending how fast the mouse is moving above the threshold.

avatar image Dartmor · Aug 21, 2015 at 01:45 AM 0
Share

I will need to rework this, but it might help, not sure yet.

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

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

RigidBodies vs CapsuleCasts 0 Answers

Why does my rigidbody slows down at time ? 1 Answer

Cap rigid body move speed, without capping rotation speed 1 Answer

How to get collision force, not relative velocity? 1 Answer

Getting speed without Rigidbody.velocity.magnitude 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