Skiing / sliding

embe

New member
Hello, I'm trying to create a skiing ability but can't quite get the sliding to work properly. I've tried three different approaches:
  1. If I disable root motion, motor damping and positional input the player will slide if I apply AddForce to m_CharacterLocomotion using the vertical input axis (W key). However the player only slides while I'm pressing that button and never continues sliding on its own. If the player has some prior momentum when the skiing ability is activated, it will slide at that speed without applying force. But if I stop the player and try to start sliding again, it will only slide when the key is pressed. (Previous Acceleration is set to 1 btw).
  2. If I use the same setup but keep positional input enabled it solves that problem and continues to slide even when releasing the W button, but the sliding speed is constant and only increases when applying force with W. It's not affected by gravity and doesn't increase when going down a steeper slope for example. And if it starts going too fast it will lift off the ground and fly a long distance before crashing into the ground.
  3. If I copy the built-in slide ability the player seems to slide correctly/dynamically (i.e. slide faster down a steeper slope) but will regularly and suddenly get stuck as if it hit a wall, and only resume sliding if I move the player slightly. It also doesn't rotate the player to the direction I'm looking with the mouse -- it just goes straight.
Is there a way to fix one of these approaches, or a fourth one I could try? (Option 1 basically does everything I need except continuing to slide, so it would be wonderful if there is some way to just make the player frictionless)
 
Last edited:
Number 1 is the correct approach. I'm not completely understanding though - wouldn't the acceleration only be applied when you are pressing a button coming from a stop? Also, you can use physic materials to decrease the friction of the surface.
 
Alright cool, then I'm on the right track :)

To clarify the acceleration: when standing in a slope, the player's velocity should increase with the steepness of the slope like in real life, and in the direction that the player/the skis are facing. Right now the player is standing completely still even in a steep slope, and only moving when pressing the move button. I would like to avoid changing the physics materials as I have vehicles and NPCs that are moving on the same terrain.
 
Thanks for the details. The friction is going to stop the player no matter what acceleration and damping values you are using, and normally using the physics material is how you would solve that. With that said, since you can't change the physic material then I would use the settings that you are using, but also create a new skiing ability that adds a small force to the character. You will want to negate the amount that is added from the friction. Take a look at CharacterLocomotion.UpdatePosition for its use.
 
Got it, after several days of work I got a solid skiing ability. It measures and lerps the slope angle in front of the player and applies force and a friction coefficient to m_CharacterLocomotion. The force is determined by the slope and existing momentum. It's working beautifully, and I'm really starting to see the power in the Abilities system since I didn't have to modify any UCC core scripts and can reuse so many things.
 
Back
Top