Commit 62d5b853 authored by Tanner Grehawick's avatar Tanner Grehawick

airborne and grounded animation transitions

parent 2122d06a
...@@ -14,10 +14,20 @@ public class Jump : AbstractBehavior { ...@@ -14,10 +14,20 @@ public class Jump : AbstractBehavior {
int airJumpsMade = 0; int airJumpsMade = 0;
void Update() { void Update() {
if (!jumpRequested && inputState.GetButtonPressed(inputButtons[0])) { if (!jumpRequested && inputState.GetButtonPressed(inputButtons[0])) {
jumpRequested = true; jumpRequested = true;
} }
float jumpState;
Vector2 vel = body.velocity;
jumpState = Mathf.Abs(vel.y) / GetJumpVelocity(jumpHeight);
jumpState = 1 - Mathf.Clamp01(jumpState);
if (jumpState == 1) {
jumpState = 0;
}
jumpState = Mathf.Sqrt(jumpState);
animator.SetFloat("jump state", jumpState);
} }
void FixedUpdate() { void FixedUpdate() {
......
...@@ -15,10 +15,17 @@ public class CollisionState : MonoBehaviour { ...@@ -15,10 +15,17 @@ public class CollisionState : MonoBehaviour {
private InputState inputState; private InputState inputState;
private Rigidbody2D body; private Rigidbody2D body;
private Animator animator;
void Awake() { void Awake() {
inputState = GetComponent<InputState>(); inputState = GetComponent<InputState>();
body = GetComponent<Rigidbody2D>(); body = GetComponent<Rigidbody2D>();
animator = GetComponentInChildren<Animator>();
}
void Update() {
animator.SetBool("on ground", onGround);
animator.SetBool("on wall", onWall);
} }
void FixedUpdate() { void FixedUpdate() {
......
...@@ -23,7 +23,6 @@ public class Walk : AbstractBehavior { ...@@ -23,7 +23,6 @@ public class Walk : AbstractBehavior {
Vector2 vel = body.velocity; Vector2 vel = body.velocity;
float hspeed = Mathf.Abs(vel.x / speed); float hspeed = Mathf.Abs(vel.x / speed);
animator.SetFloat("horizontal speed", hspeed); animator.SetFloat("horizontal speed", hspeed);
print(hspeed);
} }
// Update is called once per frame // Update is called once per frame
......
No preview for this file type
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