I am having a surprisingly hard time figuring this out. I’d like to add sliding akin to Mirror’s Edge or Far Cry where you can press control while sprinting to slide like a baseball player.
The controls are fine, I just can’t figure out a solid way to implement this so that the character moves faster downhill and slower uphill. Ideally I’d just use physics to carry the character but the proper method is eluding me. Here’s what I’ve tried
Launch the character and reduce their ground friction - this appears to work, but if you’re going downhill you just launch straight forward.
Add physics to the capsule - this causes the capsule to topple over and flip around on the ground (hilariously). I tried locking certain axis of movement but everything seems to result in the capsule flying around on the floor. I want the capsule to stay upright while being affected by gravity.
Is there some way to make the character move downhill like they are in some kind of vehicle/snowboarding/whatever?
You’re asking two things here. Sliding is easy, you just store the rotation of your character in a variable at the begininng of the slide, disable character controls while sliding, use a timeline to add movement input throughout the sliding action and use the same timeline to enable character controls when finished.
For the second one, you trace a line to the ground from your cahracter and get the hit normal. From that, you deduce the ground slope and add movement accordingly.
Cheers! This got me on the right track. I made a couple modifications to your solution, I used a recursive gate rather than a timeline so the player can slide downhill as long as they have momentum. I’m tempted to make a youtube video about it once I fine tune it a bit more, because there’s kind of a lot involved in this actually.
I will put a video up here in a day or two if I can find time, school is really getting in the way of my game dev… Sorry guys, I’ll post again when I can. If you guys want to do my computer engineering homework for me I can work on it right now haha, but, yeah, bear with me.