private void HandleAnimations() { float velocity_mag; bool on_ground; bool is_hanging; if (IsOwner) { velocity_mag = Vector3.ProjectOnPlane(cc.velocity, Physics.gravity).magnitude; on_ground = lastGroundState = pc.OnGround(); is_hanging = lastHangState = pc.IsHanging(); } else { on_ground = lastGroundState; is_hanging = lastHangState; velocity_mag = Vector3.ProjectOnPlane(netptransform.velocity, Physics.gravity).magnitude; previous_position = transform.position; } // NOTE: This makes animations framerate dependent. We may want to move this into fixed update in the future. velocity_mag = averageVelocity.Accumulate(velocity_mag) / averageVelocity.Size(); if (Input.GetKey(KeyCode.Q)) { isSliding = true; isWalking = false; isRunning = false; isJumping = false; } else { isSliding = false; if (on_ground && velocity_mag < 0.2f) { isWalking = false; isRunning = false; } else if (on_ground && velocity_mag < (walkMaxSpeedMult * cc.radius)) { isWalking = true; isRunning = false; } else if (on_ground && velocity_mag > (runMinSpeedMult * cc.radius)) { isRunning = true; isWalking = false; } else if (on_ground && !isWalking && !isRunning) { isWalking = true; } if (!on_ground) { isJumping = true; isWalking = false; isRunning = false; } else { isJumping = false; } if (is_hanging) { isJumping = false; isWalking = false; isRunning = false; isHanging = true; } else { isHanging = false; } } //Add more animation states here animator.SetBool("isRunning", isRunning); animator.SetBool("isWalking", isWalking); animator.SetBool("isJumping", isJumping); animator.SetBool("isHanging", isHanging); animator.SetBool("isSliding", isSliding); }