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
2
Question by Tuah · Oct 05, 2010 at 08:39 PM · physicsrigidbodyforcerelativequack

Add Relative Force

So I've been working on this incredibly complex control system only to discover "addRelativeForce" and facepalm.

Say I have a rigidbody sitting on a moving object, and I want it to move at a goal speed in relation to the object it's on. (For example, character run at 10mph + the train's speed of 40mph.)

From what I understand, using addForce for this will simply make my character attempt to reach a grand total of 10mph, whereas addRelativeForce will make my character attempt to reach 10mph + the train's speed.

Is this about right?

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

2 Replies

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

Answer by skovacs1 · Oct 05, 2010 at 09:01 PM

No, not quite.

AddForce adds force in world coordinates and AddRelativeForce adds force in local coordinates.

rigidbody.AddForce(transform.forward * 10);

is the same as

rigidbody.AddRelativeForce (Vector3.forward * 10);

If you have a rigidbody sitting atop a moving object, the amount of force transferred from the the moving object to the rigidbody is determined by the amount of friction on both of the objects' collider's physic material, the amount of force pushing the body against the moving object and the mass of the rigidbody. If you have no friction, you would have to add the force of the moving object while they are in contact.

AddForce will always add force. If you are moving with the same forces as the train (however you decide to achieve this), when you AddForce on top of that, you will be moving with that much more force than the train.

Force is not measured in units of velocity(distance/time), but in units of Force (Newtons or whatever). Applying a force doesn't necessarily apply enough force to reach velocity x except in a completely empty and appropriately setup system because of things like drag, surface interactions and constant forces and the like which will affect velocity in different ways. With drag, the rigidbody will slow to a stop as it moves. Physic materials and collisions can easily have a wide variety of effects on velocity from bouncing back with equivalent force to friction adding the velocity of whatever was collided with.

Comment
Add comment · Show 2 · 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 Jesus_Freak · Dec 22, 2010 at 04:49 PM 0
Share

@skovacs1: thanks for explaining that to them, because this is the first post i saw with the subject, and i wanted to know how to add force in local coords, and you helped me understand how... thanks!

avatar image guzmonne · Nov 21, 2013 at 10:54 AM 0
Share

Thank you very much for this simple explanation.

avatar image
5

Answer by burnumd · Oct 05, 2010 at 09:00 PM

Not really. AddRelativeForce has more to do with the direction of the rigidbody you're adding force to rather than the magnitude of force. characterRigidbody.AddForce (0, 0, 1) will push your character in the global z-direction. characterRigidbody.AddRelativeForce (0, 0, 1) will push your character forward based on which direction your character is facing (whichever way the blue arrow points when select the character and have "Local" selected as the coordinate system in the editor). In both cases, you must still determine the amount of force by multiplying the normalized direction by the magnitude of force.

Comment
Add comment · Show 1 · 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 Fady-S · Jul 27, 2012 at 11:27 AM 0
Share

@Francis Fernandez, yes very true,thanks for clearing this out.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

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

Simple Rigidbody / force question 3 Answers

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

chain and 3rd person character 0 Answers

relativeVelocity how to? (noob question) 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