Character Jitters/Bounces When Moving on Slopes.

Updated on June 3, 2019 in [A] Unity Scripting
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
6 on June 1, 2019

Hello all,
   
I’m working on a 3rd Person Controller. However, when walking & running down slopes, it bounces. I need smooth movement. To this end, I unfortunately have found no working solutions online. I’m using a Rigidbody and the MovePosition function to move my character. Applying force downwards on my character does not keep it stuck. I also couldn’t force my character to remain at a distance of X from the ground using its transform as that increased the jittering for some reason (I may have done it wrong?).
     
This bug is occurring (I believe) because I’m moving forward but gravity is failing to keep my character on the ground. I need smooth movement and as applying a downwards force doesn’t fix it, I’m out of ideas.

Please give me some ideas! I’ve been stuck trying to fix it for a few days now and nobody online seems to have shared a solution.

https://youtu.be/UpE5NIXfBUU

Attached is a video of my character placeholder moving up and down a slope at jog to max speed.

  • Liked by
Reply
2 on June 1, 2019

I can only say how Unity’s NavMeshAgent does it.

It ignores gravity and measures each frame the distance to the ground. If the distance has changed, it moves the object accordingly by this delta distance.

 

Devoted
on June 1, 2019

Oh, good to know! Thank you very much.
I’ll try this tomorrow and see how I go.

Devoted
on June 1, 2019

I tried to do this but can’t figure out how to set the player at X distance away from the ground. Does anyone know how to do this? 

Show more replies
  • Liked by
Reply
Cancel
2 on June 2, 2019

UPDATE: Rigidbodies are evil. I’ve spent about 7 hours trying to fix this but nothing worked as well as I’d like. So I’ve moved over to a character controller, it’s super easy to adapt your code. It only took me 4 minutes or so verses the hours I wasted. So if anyone ever has the same problem as me, don’t try make the controller completely from scratch and instead use the CharacterController collider. Then just use its Move function to replace AddForce and/or rb.MoveaPosition where needed.

Helpful
on June 2, 2019

That’s what I actually use in my game. But your question sounds like that you wanted to create your own by purpose. So I didn’t told you that in Unity there already exists such thing.

You can be sure for future problems. If you want to use some very fundamental stuff, there is probably already a build-in Unity solution.

Devoted
on June 3, 2019

Yeah, good to know. I mostly have experience with top-down games so I have very little experience with 3D projects. I’ll definitely keep that in mind as I problem solve new challenges. 

Show more replies
  • Liked by
Reply
Cancel