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 DevMerlin · Nov 20, 2012 at 10:58 AM · physicsrigidbodyforce

What is the best way to apply force, then come to a smooth stop on control release?

Using keyboard/etc control I'd like to be able to apply a smooth acceleration to a maximum speed, using force if that is the best way to do it. When the control is released, I want to slow down to a stop.

Big note: All of this is done using physics, not transform.

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 AlucardJay · Nov 20, 2012 at 12:59 PM 0
Share

The question is a little ambiguous, even though I don't $$anonymous$$d a good "whats the best way / most efficient way" type question every now and again. When you put force in the title, that is pretty much referring to rigidbodies for everybody here (I assume!).

Now the action you are taking about is friction, in my understanding. So now you have 2 considerations : how to set up the character with rigidbody and physics material? Do i 'fake' physics? The second choice is there because ultimately if you choose the first then there is no absolute control of the object. You can push it around but you will find it very hard to say 'go there this fast and stop exactly there' with forces. There is however a neat relationship between transform.position and rigidbody.velocity. Say you movement script using transform is

 transform.position += transform.forward * speed * Time.deltaTime;

now note this can be written for the rigidbody velocity as such

 rigidbody.velocity = transform.forward * speed;

So if you want to have any certain control on what your rigidbody is up to, treat it like a transform but then directly set the velocity. $$anonymous$$uch better that getting into crazy calculations with getting the velocity anyway and making a bunch of calculations to reduce the amount of addForce to slow the object down at the target etc etc .....

avatar image Fattie · Nov 20, 2012 at 05:33 PM 0
Share

the very best way to apply force is with AddForce.

the very best way to apply drag is to apply drag.

Contents/Documentation/Documentation/Components/class-Rigidbody.html

awesome!

avatar image AlucardJay · Nov 20, 2012 at 05:56 PM 0
Share

Yes, don't get me wrong. For realizm use AddForce, then modify the amount of force by distance to target, cap force being applied by checking if the velocity magnitude is exceeding a set amount then don't apply force or make the force amount zero. But from what little I could deter$$anonymous$$e from this question, the OP wanted precision, I merely suggested an alternate method. $$anonymous$$aybe search for rigidbody character controllers and see how they do it :

http://wiki.unity3d.com/index.php/PhysicsFPSWalker

http://wiki.unity3d.com/index.php/RigidbodyFPSWalker

http://wiki.unity3d.com/index.php/Scripts/Physics

Unless they are just talking about calculating when to lerp the amount of force being applied, to stop at a target position. It is too hard to tell.

avatar image Fattie · Nov 20, 2012 at 05:58 PM 0
Share

right on -- yes the Q is a mystery to me, I just felt like typing some generalist help :)

some people don't realize DRAG is there for them..

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Griffo · Nov 20, 2012 at 11:03 AM

http://answers.unity3d.com/questions/284487/slowly-accelerate-and-slowly-slow-down-while-movin.html

Comment
Add comment · Show 4 · 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 DevMerlin · Nov 20, 2012 at 11:11 AM 1
Share

Completely off-target. As far as I can tell that's using transform to move, not force, which uses different rules. It's also ment for AI, not player.

avatar image Griffo · Nov 20, 2012 at 11:21 AM 0
Share

http://answers.unity3d.com/questions/173673/car-accelerate-over-time-javascript-and-rigidbody.html

avatar image DevMerlin · Nov 20, 2012 at 11:50 AM 0
Share

No offense but can you post anything OTHER then links? It feels more like you are just trying to get votes then to actually answer anything.

avatar image Griffo · Nov 20, 2012 at 12:17 PM 0
Share

Well, excuse me for trying to point you in the right direction, I wont bother next time ..

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

12 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

Related Questions

Character Controller meets Rigidbody 1 Answer

add force to object that has 2 different rigid bodies 0 Answers

How to apply uni-directional force to a rigidbody 0 Answers

Touch controlled ice puck 0 Answers

Parenting not working with massive force to rigidbody. Does having rigidbody on child screw things up? 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