• 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
13
Question by TurboHermit · Sep 26, 2012 at 01:48 PM · rigidbodygravityforce

Reading force on rigidbody?

Is there any way to determine what the current forces are on a rigidbody? I have a bouncing rigidbody that I want to play a different animation when it's on the peak of it's bounce. Anyone have any suggestions?

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
15
Best Answer

Answer by Fattie · Sep 26, 2012 at 02:06 PM

great question in a way !

BUT

what you're chasing there is actually velocity.

attach this script to your object,

 function FixedUpdate()
 {
 if ( rigidbody.velocity.magnitude < 0.01 )
  {
  Debug.Log("unity answers saves the day!");
  }
 }

the "forces on" a body never change under gravity, it's always the same. in this example you're thinking of velocity. tune the 0.01 figure so it works good for you in your situation.

Comment
Add comment · Show 6 · 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 TurboHermit · Sep 26, 2012 at 02:20 PM 0
Share

Great! I never noticed velocity before! I used velocity.y to check if it was on it's turning point and it works perfectly now. Thank you.

avatar image Fattie · Sep 26, 2012 at 02:22 PM 0
Share

glad to help :O

avatar image jaskij · Sep 26, 2012 at 06:12 PM 0
Share

When it comes to force (or acceleration for that matter) though, the only solution seems to be comparing velocity between this and previous FixedUpdate, or is there another way? (Couldn't find anything in the reference).

avatar image Fattie · Sep 26, 2012 at 06:36 PM 1
Share

I'm pretty sure that's correct yeah.

it would be great if there was a callback "force felt, other than gravity", say.

well it's worth considering that the only way force can be applied is (1) collision (could possibly be an ongoing drag issue) (2) gravity (3) constant force (4) throgh AddForce etc in code

avatar image Snowirbis · Jan 07, 2020 at 12:51 PM 0
Share

It does not answer the original question of reading the force on a rigidbody.. You should either change the title or include the actual answer to the question.

avatar image Owen-Reynolds Snowirbis · Jan 07, 2020 at 06:12 PM 1
Share

Well, it answers the Q in the text -- the peak of a bounce is when velocity drops from +, through 0, to -. As for the title, you can't. Velocity is the only thing stored on an RB. Forces in a real physics sense are produced and applied externally. See the previous 2 comments (and add "springs and hinges" to the options).

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

13 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

Related Questions

Tornado throwing back force after pulling 1 Answer

How to clear all forces but not the gravity force? 1 Answer

Gravitational Object Creation for 3D Game 1 Answer

Replicate physics.gravity with custom code. 2 Answers

rigidbody.Velocity stops gravity 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