- Home /
What unit does Rigidbody.AddForce() use?
I'm trying to add a 3 world units per second force (or velocity) to a Rigidbody, and so I found the AddForce()
method. I tried rigidbody.AddForce(Vector3.up*3)
but it didn't produce the result I wanted.
What unit does the AddForce()
method use? Or better yet, any ideas on how I can produce the effect I want? Thanks!
Yeah, I understand that perfectly. But without knowing the units, I really can't get my desired results. Of course, I can brute force, but that's not very efficient and accurate.
Answer by hijinxbassist · May 24, 2012 at 07:20 AM
Actually, someone asked this before. Before posting a question, do a search through the database to see if you question has already been asked/answered. http://answers.unity3d.com/questions/18182/rigidbodyaddforce-is-in-what-units.html>Here is the link to the answer i found upon first search.
For searching, i use google and add unity to the beginning of the search topic. This is what i typed, "unity add force unit". It was the second link, the title was clear enough for me to make the decision to proceed following the link. Hope that helps you in future inquires.
Oh, sorry about that. I tried searching but I must have been looking at the wrong places. :P
Thanks! And sorry for the trouble! :)
absolutely no trouble. I picked up that search technique early on, and it has been a life saver and helps me help others quick & effectively. I use it to get the unity reference as well if i dont have the unity ref page open already. i usually type something like, "unity TOPIC ref" works well 93.6% of the time :P
Answer by save · May 24, 2012 at 07:24 AM
AddForce()
is just adding to the total velocity which is in Unity-units per second. The impact of the force is heavily connected to the mass, momentum and friction of the rigidbody which makes it non-measurable in a simple way. You can check if the velocity is good enough, if it isn't then add more force to the rigidbody.
function FixedUpdate () {
if (rigidbody.velocity.y<3) rigidbody.AddForce(Vector3.up*3);
}
You can also alter the velocity directly, which will produce a non-realistic result:
rigidbody.velocity = Vector3.up*3;