Commit af1c3305 authored by Tanner Grehawick's avatar Tanner Grehawick

ground check and air jump

parent cd9f34e5
......@@ -5,6 +5,10 @@ using System.Collections.Generic;
public class Jump : AbstractBehavior {
public float jumpHeight = 5;
public float airJumpHeight = 5;
public int airJumpCount = 1;
int airJumpsMade = 0;
void FixedUpdate() {
if (inputState.GetButtonPressed(inputButtons[0])) {
......@@ -13,10 +17,18 @@ public class Jump : AbstractBehavior {
}
public void Activate() {
// if grounded:
Vector2 vel = body.velocity;
vel.y = GetJumpVelocity(jumpHeight);
body.velocity = vel;
if (collisionState.onGround) {
airJumpsMade = 0;
Vector2 vel = body.velocity;
vel.y = GetJumpVelocity(jumpHeight);
body.velocity = vel;
}
else if (airJumpsMade < airJumpCount) {
Vector2 vel = body.velocity;
vel.y = GetJumpVelocity(airJumpHeight);
body.velocity = vel;
airJumpsMade ++;
}
}
float GetJumpVelocity(float height) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment