# How to make a player glide realistically

I am trying to make a game where a player is able to glide around, and their speed will increase when they angle their character downward, and decrease when upward. I am having trouble making the character angle up and down, and making the speed realistic. I have used this article to help out with the main math: Gliding script with air resistance and force, but I am still having trouble with it. Any help on how best to do this is very much appreciated.

2 Likes

I wouldnâ€™t know where to start with the math but if your map in mostly flat you could calculate the speed with the y-axis. For instance if the playerâ€™s root part drops 10 studs on the y-axis you could add to the speed and slow the speed if the player is moving up on the y-axis.

If the map is flat or not might not matter if you do it that way. I donâ€™t remember why I was thinking the map had to be flat.

You could have it check every Heartbeat and change speed depending on the camera CFrame with :ToWorldSpace() I think

I think that I have the speed equitation down, my main problem is that I cant test it because I donâ€™t know how to align the player so that they can be angled up and down with the camera.

For the math: What you want to do is have some sort of â€śresistanceâ€ť force (think like a parachute), which moves about depending on orientation (Iâ€™d imagine poking out of the characters back). This should be in proportion to the downward velocity (not gravity, the velocity added by gravity). Taking the dot product of a vector out the back & the downward velocity should give this proportion. Then, apply this to scale two vectors: a vector facing directly up against gravity, and a vector forwards out of the head. This means that as you slow down vertically, you will speed up horizontally, and vice versa. If you have problems with going up/down out of nowhere (kind of like you are getting free energy) you might want to scale the vectors such that the up force only resists gravity completely when you are falling a certain speed down (this way, it is a system that optimises towards some down velocity rather than zero).

The easiest way to have the player character rotate nicely is to just lock the â€śPlatformStandingâ€ť property to true, and use a BodyGyro with massive MaxTorque etc. Update the physics & the rotation on a render stepped event and youâ€™ll get some very smooth and fun mechanics

5 Likes