Character slows down when running next to a wall

KO_Games

Member
Hi Justin,

In my game, I've noticed that when the character runs right next to walls that he slows down a bunch before speeding up again. It can make the gameplay feel a little clunky in my game. Is there any way to adjust this? See screenshot below. Ideally, I don't want the character to slow down at all when running next to a wall.

 
I'm pretty sure there's a setting in one of the locomotion inspectors for this (but I'm at work and slacking off, so can't check). This gives me an idea though... if the walls are slowing the player down that means, somewhere in the code, there is a system that detects when the player is moving along a wall. If that's the case, it opens up some interesting stealth mechanics - e.g. player is less visible when hugging walls.

Your project looks great, by the way!
 
In the UltimateCharacterLocomotion, under "Physics", the Wall Glide Curve property is what you're looking for. I believe if you set it to a straight y=1 line, the character's speed won't get affected at all.
 
@AnastaDhara Thanks glad you like the project! It's been a fun one.
@Andrew I thought the wall glide curve would affect this too, but it doesn't seem to be making a difference. I tried putting it straight at y=1. I also tried messing around with the curve at different values. It seems like if I get the curve close to zero the character stops more suddenly when bumping into walls. But nothing I could change would eliminate the slow down that occurs right after bumping or touching a wall and running next to the wall. I also tried changing the wall bounce modifier, but that didn't seem to help either.

See GIF and settings screenshot below.


Screenshot 2021-01-04 131837.png
 
Ah I see what you mean now. Unfortunately I believe this is more of a fundamental issue with moving 3D rigidbodies at an angle against other colliders - one part of the character's forward motion will always get cut off, causing the motion vector's overall magnitude to decrease. I'm not sure if there's an out-of-the-box solution for this, it may involve creating a custom movement type that can create this type of behaviour. Justin might know more.

edit: This will be added to the list for a future update - for now you should be able to create an ability that modifies AbilityMotor to apply the "extra" force along the direction perpendicular to the wall
 
Last edited:
@Andrew How would I create an ability that "modifies the ability motor to apply the extra force along the direction perpendicular to the wall?"

I know there is the documentation on how to create new abilities here: https://opsive.com/support/document...r-controller/character/abilities/new-ability/

However, I don't really follow how to apply the "extra" force along the direction perpendicular to the wall. Is this an ability that is going all of the time? Does it need to trigger just when you touch a wall? How do you apply the force along the direction perpendicular to the wall?
 
Sorry I should have been a little clearer. The UltimateCharacterLocomotion component contains a Vector3 m_AbilityMotor. This vector is added to the character's motor forces whenever it updates as an additional force, meaning that abilities can modify it to apply additional forces to the character. In the demo scene, both the Drive and Ride abilities modify the character's AbilityMotor in order to control its motion. So, you could have an ability that constantly runs and adds the extra motion required to ensure the character keeps moving parallel to a wall. The ability would probably have to contain those calculations, e.g. check the collision and determine what its motion "should" be, then add the required motion vector to AbilityMotor.
 
I think I understand what you are saying I need to do, but to be honest that seems kind of complicated. I'm not really sure how to do the calculations to know how to get the right angle to move the character next to walls. Is there an easier way to do this? I would think that people generally wouldn't want the character slowing down this much whenever they bump into a wall. @Justin Do you know if there is another way to handle this?
 
Top