// Update is called once per frame void Update() { if (m_Rigidbody2D) { m_MagpieAnim.SetBool("Moving", m_Rigidbody2D.velocity.magnitude > m_fIdleSpeedTolerance); } if (m_Grabber) { m_MagpieAnim.SetBool("Carrying", m_Grabber.IsGrabbing()); } m_MagpieAnim.SetBool("InAir", m_bIsFlying); }
// Update is called once per frame void Update() { if (Input.GetAxis("Jump") > m_fHorizontalInputCutoff) { if (!m_bJumpIsPressed) { if (m_iNumJumps < m_iMaxJumps) { if (m_SoundManager) { if (m_Grabber == null || !m_Grabber.IsGrabbing()) { m_SoundManager.PlayJump(); } else { m_SoundManager.PlayCarryJump(); } } Vector2 vSpeed = m_Rigidbody.velocity; vSpeed.y = m_fJumpSpeed; m_Rigidbody.velocity = vSpeed; m_iNumJumps++; } } m_bJumpIsPressed = true; } else { m_bJumpIsPressed = false; } float fHorizontal = Input.GetAxis("Horizontal"); if (m_SpriteRenderer) { if (fHorizontal > m_fHorizontalInputCutoff) { m_SpriteRenderer.flipX = true; } else if (fHorizontal < -m_fHorizontalInputCutoff) { m_SpriteRenderer.flipX = false; } } if (Mathf.Abs(fHorizontal) > m_fHorizontalInputCutoff) { if (m_GroundList.Count > 0 && m_SoundManager != null) { m_SoundManager.PlayWalk(); } else if (m_GroundList.Count == 0 && m_SoundManager != null) { m_SoundManager.StopWalk(); } Vector2 vSpeed = m_Rigidbody.velocity; vSpeed.x = fHorizontal * m_fHorizontalSpeed; m_Rigidbody.velocity = vSpeed; } else if (m_GroundList.Count > 0) { if (m_Rigidbody.velocity.magnitude > m_fIdleSpeedTolerance && m_SoundManager != null) { m_SoundManager.StopWalk(); } Vector2 vSpeed = m_Rigidbody.velocity; vSpeed.x = 0; m_Rigidbody.velocity = vSpeed; } else { if (m_SoundManager != null) { m_SoundManager.StopWalk(); } } if (m_Rigidbody.velocity.y < m_fFallSoundCutoff) { m_SoundManager.PlayFall(); } else { m_SoundManager.StopFall(); } }