- Home /
Applying gravity to a character controller object in 2D without a rigidbody?
how would i apply gravity to my player, without a rigidbody, because he wont fall when i start the game, like it should.
Comment
You could apply a constant force in the opposite direction. I think, you may need a ridgid body for a constant force.
You should just add a gravity force to your object's velocity while your object is not grounded. Do not transform the position itself, as suggested above, as you will end up falling into objects themselves and will not be able to utilize unity's collision detection.
Best Answer
Answer by Loius · Oct 08, 2010 at 04:02 PM
transform.position.y += Vector3(0,localGravity*Time.deltaTime,0);
localGravity -= 9.81 * Time.deltaTime;
The problem is you won't get any collisions with that. If it's a character controller you should just add that movement to its current Move command.