Movement Physics

Heya all,

So Im new to Unity and C#, so please dont bash me in too hard ! :smile:
Im attempting to make a way for a player to “glide” through the air if they were to jump and move forward. THey cannot move while in mid air, but if they already issued a forward as they did the jump command, then they would move forward and jump. However, with the code below, they only jump when the conditions are met?

I’ve tried the following:
if(forward && sprint && jump){
GetComponent().AddForce(Vector3.forward * sprintSpeedCalc);
GetComponent().AddForce(Vector3.up * jumpPower * Time.deltaTime);
Debug.Log(“forward && sprint && jump”);
}

if(forward && sprint && jump){
GetComponent().AddForce((Vector3.forward * sprintSpeedCalc) + (Vector3.up * jumpPower * Time.deltaTime));
Debug.Log(“forward && sprint && jump”);
}

The whole script: https://pastebin.com/J3tKKLzH

Not sure if I exactly understand, but you should condition the sliding when the player is in air e.g

if(Player.OnGround()==false){
GetComponent().AddForce(Vector3.forward * sprintSpeedCalc);
}