- Home /
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?
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.
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.
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).
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
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.
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
![](https://koobas.hobune.stream/wayback/20220613081520im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
rigidbody.Velocity stops gravity 2 Answers
Applying force to a rigidbody 2 Answers
Rigidbody--Addforce on a Spherical Platform(A Globe) 2 Answers
adding force every frame to control my ridigbody makes it shake ugly 4 Answers
Is there a way to have rigid bodies collide, but not transfer any force? 2 Answers