- Home /
Move character with AddForce
Hello I have a 2D game with a character that can jump and move left/right. Recently i changed the movement script and i'm now using Rigidbody.AddForce instead of changing the transform.position. The problem is, that the character moves very slow when is on the ground (inAir it moves as fast as it should). I looked into different answers but the only solution seems to be increasing the speed value or decreasing gravity. But if i increase the speed, it has way to fast inAir movement and if i decrease gravity, it falls extremely slow. Does anyone know another solution or a trick to solve or bypass the problem?
Answer by Caeser_21 · Apr 20 at 04:32 AM
I think it would be better to use RigidBody2D.velocity
instead of RigidBody2D.AddForce
...
Answer by CodeMonkeyYT · Apr 20 at 08:47 AM
Sounds like perhaps it's a friction problem, you need to create a Physics2D Material and set the Friction to 0. https://docs.unity3d.com/Manual/class-PhysicsMaterial2D.html
Also for moving it might be best to use Rigidbody2D.velocity instead of AddForce(); at least that's the method that I prefer, I covered a 2D Character controller here https://unitycodemonkey.com/video.php?v=Bf_5qIt9Gr8
And a Platformer controller here https://unitycodemonkey.com/video.php?v=DEGEEZmfTT0
With friction, the player can't climp any wedges. There is also some very weird sliding and speed increase over time. The problem with the velocity is, that by using this the player falls extremely slow It also can't walk over edges. is there another way of doing this?
Your answer
Follow this Question
Related Questions
How to stop input after hitting a certain velocity 1 Answer
My player goes straight through my colider 3 Answers
Getting Unusual Input into Animator Controller Script 0 Answers
[ C#] Character Movement based on Camera Direction. 2 Answers
How can I make my 2D sprite move in the direction of the most recent key pressed? 1 Answer