- Home /
The question is answered, right answer was accepted
rigidbody2D.AddForce doesn't work!
Why does this code doesn't work?
rigidbody2D.AddForce(transform.up Speed Time.deltaTime);
This AddForce doesn't move my gameobject. Have you got any ideas?
Thanks for you statement!
What the mass? How big is 'Speed'? Is there a possibility that the object is hitting another collider? Note the use of 'Speed' here is misleading since this code will not make something go a specific speed.
Yes, it is. When I uncheck "Is $$anonymous$$inematic" gameobject fall.
Please don't post your comments as answers. I've converted your "answers" back into comments but please try to understand the comments system for next time :) There's also a tutorial video here that helps you understand Unity Answers.
Answer by Statement · Dec 21, 2013 at 11:23 PM
Set the following options on Rigidbody 2D
Is Kinematic: Off
Gravity Scale: 0
Documentation for Rigidbody 2D
Answer by jobar · May 11, 2014 at 12:53 AM
The previous responses are correct, you need to be aware of the settings in the inspector and the values you use in the function call. Also, Time.deltaTime produces a small value which can likely lead a force that is unlikely to overcome gravity. For instance,
rigidbody2D.AddForce(Vector3.up * 10 * Time.deltaTime);
might not produce a force strong enough to overcome gravity, but if you try something like
rigidbody2D.AddForce(Vector3.up * 300);
you will likely see something happen.
This is worked for me..but when i move player it keep moving after i finished my touch player keep moving.and also player accelerate his speed continusly
Answer by Nolaa_Uzul · Jul 17, 2017 at 10:02 PM
Set BodyType = dynamic Simulated = on GravityScale = 0
Follow this Question
Related Questions
Unwanted 2d pixel after-image when moving 1 Answer
onTriggerEnter only triggers when the gameobject its shall hit moves. 1 Answer
Erratics movements from my rigidbody : why does it behave like that? 0 Answers
Rigidbody slows down before touching its target 1 Answer
2D Game, Character Slides off Slopes, Need to be Able to Walk on Them 1 Answer