add trumpet sound effect
This commit is contained in:
		@@ -52,6 +52,7 @@ public class PlayerMovement : MonoBehaviour
 | 
			
		||||
    [Header("Checks")]
 | 
			
		||||
    //Size of groundCheck depends on the size of your character generally you want them slightly small than width (for ground) and height (for the wall check)
 | 
			
		||||
    [SerializeField] private Vector2 _groundCheckSize = new Vector2(0.49f, 0.03f);
 | 
			
		||||
    [SerializeField] private float _groundCheckOffset;
 | 
			
		||||
    [Space(5)]
 | 
			
		||||
    [SerializeField] private Vector2 _wallCheckSize = new Vector2(0.5f, 1f);
 | 
			
		||||
 | 
			
		||||
@@ -164,8 +165,10 @@ public class PlayerMovement : MonoBehaviour
 | 
			
		||||
            _isJumpCut = false;
 | 
			
		||||
            _isJumpFalling = false;
 | 
			
		||||
            Jump();
 | 
			
		||||
            
 | 
			
		||||
            if (!IsGrounded() && in_range && trumpet > 0)
 | 
			
		||||
            {
 | 
			
		||||
                gameObject.transform.Find("Trumpet").GetComponent<AudioSource>().Play();
 | 
			
		||||
                enemy.GetComponent<EnemyPatrol>().DefeatEnemy();
 | 
			
		||||
                enemy = null;
 | 
			
		||||
                in_range = false;
 | 
			
		||||
@@ -174,6 +177,10 @@ public class PlayerMovement : MonoBehaviour
 | 
			
		||||
            {
 | 
			
		||||
                trumpet -= 1;
 | 
			
		||||
            }
 | 
			
		||||
            // check if double jump, play sound
 | 
			
		||||
            if (trumpet == 0) {
 | 
			
		||||
                gameObject.transform.Find("Trumpet").GetComponent<AudioSource>().Play();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        //WALL JUMP
 | 
			
		||||
        // else if (CanWallJump() && LastPressedJumpTime > 0)
 | 
			
		||||
@@ -449,7 +456,7 @@ public class PlayerMovement : MonoBehaviour
 | 
			
		||||
    public bool IsGrounded()
 | 
			
		||||
    {
 | 
			
		||||
        // print(Physics2D.OverlapBox(this.transform.position, _groundCheckSize, 0, _groundLayer) && !IsJumping);
 | 
			
		||||
        return (Physics2D.OverlapBox(this.transform.position, _groundCheckSize, 0, _groundLayer) && !IsJumping);
 | 
			
		||||
        return (Physics2D.OverlapBox(new Vector2(this.transform.position.x, this.transform.position.y - _groundCheckOffset), _groundCheckSize, 0, _groundLayer) && !IsJumping);
 | 
			
		||||
    }
 | 
			
		||||
    #endregion
 | 
			
		||||
 | 
			
		||||
@@ -458,7 +465,7 @@ public class PlayerMovement : MonoBehaviour
 | 
			
		||||
    private void OnDrawGizmosSelected()
 | 
			
		||||
    {
 | 
			
		||||
        Gizmos.color = Color.green;
 | 
			
		||||
        Gizmos.DrawWireCube(this.transform.position, _groundCheckSize);
 | 
			
		||||
        Gizmos.DrawWireCube(new Vector2(this.transform.position.x, this.transform.position.y - _groundCheckOffset), _groundCheckSize);
 | 
			
		||||
        Gizmos.color = Color.blue;
 | 
			
		||||
        Gizmos.DrawWireCube(this.transform.position, _wallCheckSize);
 | 
			
		||||
        Gizmos.DrawWireCube(this.transform.position, _wallCheckSize);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user