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!
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!
Set the following options on Rigidbody 2D
Documentation for Rigidbody 2D
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.
Set
BodyType = dynamic
Simulated = on
GravityScale = 0