RigidBody AddForce Issue

Hi. I’m new to unity and I am working on my first project. I have been having this problem with the slide ability of my player character. In order for my character to slide, I have been using the addforce() function on the rigid body. Here’s a portion of the code:

public float dashe = 10f;

// I cut out a large portion of the code to only include the parts directly related to my issue.

rb.AddForce(transform.forward * dashe, ForceMode.VelocityChange);

But for some reason reason, the addforce function only nudges my player character a very small distance that is barely noticeable. I tried raising the value of dashe, but doing this causes my character to very quickly move forward instead of the force pushing the player and speed the player the player is sliding at gradually decreasing over time. I’ve seen some videos of other people online doing the same thing as me for their characters sliding, but their implementation actually works. I don’t know whats wrong and any advice would be greatly appreciated. Thank you in advance.

Hello,
I would guess by your explanation that the drag of your player character is way too high. Try to set it to .1 or something similar.
Maybe also change the ForceMode to acceleration or impulse?

1 Like

Thanks but the drag of my character is set to 0 and I tried changing it to acceleration and impulse before and they didn’t work as well.

If you add this force in Update you should move it to FixedUpdate instead. Also mutiply it by Time.deltaTime. Alternatively you can use ForceMode.Acceleration and not multiply it by Time.deltaTime it would be completely the same. Note that those two modes ignore rigidbody mass.
There might be something wrong in your code that you didn’t post here so it’s hard to tell what’s the problem. You can also check the orientation of your object, maybe it’s forward vector is pointing a bit downwards or is rotating to face something in the process. If it’s not the case then maybe you are applying a huge downward force (some very high gravitation)? Also you can look at you rigidbody component under the info property to see what it’s velocity actually is. Maybe you are adding some force somewhere in your code that it going in the opposite direction? Or maybe you have some constrains enabled on your rigidbody that prevent it from accelerating?

1 Like

Thanks.