more from me
This commit is contained in:
		@@ -116,223 +116,227 @@ public class PlayerMovement : MonoBehaviour
 | 
			
		||||
            FreezeControl();
 | 
			
		||||
        }
 | 
			
		||||
        else{
 | 
			
		||||
        
 | 
			
		||||
        if(isFrozen)
 | 
			
		||||
        {
 | 
			
		||||
            Data.gravityStrength = tempGrav;
 | 
			
		||||
            Data.fallGravityMult = tempFall;
 | 
			
		||||
            isFrozen = false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        unlockedTrumpet = stateController.unlockedTrumpet;
 | 
			
		||||
        #region TIMERS
 | 
			
		||||
        LastOnGroundTime -= Time.deltaTime;
 | 
			
		||||
        LastOnWallTime -= Time.deltaTime;
 | 
			
		||||
        LastOnWallRightTime -= Time.deltaTime;
 | 
			
		||||
        LastOnWallLeftTime -= Time.deltaTime;
 | 
			
		||||
 | 
			
		||||
        LastPressedJumpTime -= Time.deltaTime;
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region INPUT HANDLER
 | 
			
		||||
 | 
			
		||||
        if (_moveInput.x != 0)
 | 
			
		||||
            CheckDirectionToFace(_moveInput.x > 0);
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        // if (!IsJumping)
 | 
			
		||||
        // {
 | 
			
		||||
        //     print("not jumping");
 | 
			
		||||
        // }
 | 
			
		||||
        // else
 | 
			
		||||
        // {
 | 
			
		||||
        //     print("jumping, " + RB.velocity.y);
 | 
			
		||||
        // }
 | 
			
		||||
 | 
			
		||||
        #region COLLISION CHECKS
 | 
			
		||||
        if (!IsJumping)
 | 
			
		||||
        {
 | 
			
		||||
            //Ground Check
 | 
			
		||||
            if (IsGrounded()) //checks if set box overlaps with ground
 | 
			
		||||
            
 | 
			
		||||
            if(isFrozen)
 | 
			
		||||
            {
 | 
			
		||||
                LastOnGroundTime = Data.coyoteTime; //if so sets the lastGrounded to coyoteTime
 | 
			
		||||
                if (unlockedTrumpet) {
 | 
			
		||||
                    trumpet = 2;
 | 
			
		||||
                    gameUI.ToggleTrumpet(true);
 | 
			
		||||
                } else {
 | 
			
		||||
                    trumpet = -1;
 | 
			
		||||
                }
 | 
			
		||||
                wasGrappling = false;
 | 
			
		||||
                isRegFalling = false;
 | 
			
		||||
            } else {
 | 
			
		||||
                // print("not jumping");
 | 
			
		||||
                if(!_isJumpFalling && !isRegFalling) {
 | 
			
		||||
                    if(unlockedTrumpet) {
 | 
			
		||||
                        trumpet = 1;
 | 
			
		||||
                Data.gravityStrength = tempGrav;
 | 
			
		||||
                Data.fallGravityMult = tempFall;
 | 
			
		||||
                isFrozen = false;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            unlockedTrumpet = stateController.unlockedTrumpet;
 | 
			
		||||
            #region TIMERS
 | 
			
		||||
            LastOnGroundTime -= Time.deltaTime;
 | 
			
		||||
            LastOnWallTime -= Time.deltaTime;
 | 
			
		||||
            LastOnWallRightTime -= Time.deltaTime;
 | 
			
		||||
            LastOnWallLeftTime -= Time.deltaTime;
 | 
			
		||||
 | 
			
		||||
            LastPressedJumpTime -= Time.deltaTime;
 | 
			
		||||
            #endregion
 | 
			
		||||
 | 
			
		||||
            #region INPUT HANDLER
 | 
			
		||||
 | 
			
		||||
            if (_moveInput.x != 0)
 | 
			
		||||
                CheckDirectionToFace(_moveInput.x > 0);
 | 
			
		||||
            #endregion
 | 
			
		||||
 | 
			
		||||
            // if (!IsJumping)
 | 
			
		||||
            // {
 | 
			
		||||
            //     print("not jumping");
 | 
			
		||||
            // }
 | 
			
		||||
            // else
 | 
			
		||||
            // {
 | 
			
		||||
            //     print("jumping, " + RB.velocity.y);
 | 
			
		||||
            // }
 | 
			
		||||
 | 
			
		||||
            #region COLLISION CHECKS
 | 
			
		||||
            if (!IsJumping)
 | 
			
		||||
            {
 | 
			
		||||
                //Ground Check
 | 
			
		||||
                if (IsGrounded()) //checks if set box overlaps with ground
 | 
			
		||||
                {
 | 
			
		||||
                    LastOnGroundTime = Data.coyoteTime; //if so sets the lastGrounded to coyoteTime
 | 
			
		||||
                    if (unlockedTrumpet) {
 | 
			
		||||
                        trumpet = 2;
 | 
			
		||||
                        gameUI.ToggleTrumpet(true);
 | 
			
		||||
                    } else {
 | 
			
		||||
                        trumpet = -1;
 | 
			
		||||
                    }
 | 
			
		||||
                    isRegFalling = true;
 | 
			
		||||
                    wasGrappling = false;
 | 
			
		||||
                    isRegFalling = false;
 | 
			
		||||
                } else {
 | 
			
		||||
                    // print("not jumping");
 | 
			
		||||
                    if(!_isJumpFalling && !isRegFalling) {
 | 
			
		||||
                        if(unlockedTrumpet) {
 | 
			
		||||
                            trumpet = 1;
 | 
			
		||||
                            gameUI.ToggleTrumpet(true);
 | 
			
		||||
                        } else {
 | 
			
		||||
                            trumpet = -1;
 | 
			
		||||
                        }
 | 
			
		||||
                        isRegFalling = true;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                //Right Wall Check
 | 
			
		||||
                if (((Physics2D.OverlapBox(this.transform.position, _wallCheckSize, 0, _groundLayer) && IsFacingRight)
 | 
			
		||||
                        || (Physics2D.OverlapBox(this.transform.position, _wallCheckSize, 0, _groundLayer) && !IsFacingRight)) && !IsWallJumping)
 | 
			
		||||
                    LastOnWallRightTime = Data.coyoteTime;
 | 
			
		||||
 | 
			
		||||
                //Right Wall Check
 | 
			
		||||
                if (((Physics2D.OverlapBox(this.transform.position, _wallCheckSize, 0, _groundLayer) && !IsFacingRight)
 | 
			
		||||
                    || (Physics2D.OverlapBox(this.transform.position, _wallCheckSize, 0, _groundLayer) && IsFacingRight)) && !IsWallJumping)
 | 
			
		||||
                    LastOnWallLeftTime = Data.coyoteTime;
 | 
			
		||||
 | 
			
		||||
                //Two checks needed for both left and right walls since whenever the play turns the wall checkPoints swap sides
 | 
			
		||||
                LastOnWallTime = Mathf.Max(LastOnWallLeftTime, LastOnWallRightTime);
 | 
			
		||||
            }
 | 
			
		||||
            #endregion
 | 
			
		||||
 | 
			
		||||
            #region JUMP CHECKS
 | 
			
		||||
            if (IsJumping && RB.velocity.y <= 0)
 | 
			
		||||
            {
 | 
			
		||||
                IsJumping = false;
 | 
			
		||||
                // print("isJumping " + IsJumping);
 | 
			
		||||
 | 
			
		||||
                if (!IsWallJumping)
 | 
			
		||||
                    _isJumpFalling = true;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (IsWallJumping && Time.time - _wallJumpStartTime > Data.wallJumpTime)
 | 
			
		||||
            {
 | 
			
		||||
                IsWallJumping = false;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (LastOnGroundTime > 0 && !IsJumping && !IsWallJumping)
 | 
			
		||||
            {
 | 
			
		||||
                _isJumpCut = false;
 | 
			
		||||
 | 
			
		||||
                if (!IsJumping)
 | 
			
		||||
                    _isJumpFalling = false;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            //Jump
 | 
			
		||||
            if (CanJump() && LastPressedJumpTime > 0)
 | 
			
		||||
            {
 | 
			
		||||
                IsJumping = true;
 | 
			
		||||
                IsWallJumping = false;
 | 
			
		||||
                _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;
 | 
			
		||||
                }
 | 
			
		||||
                else if (!IsGrounded() && !in_range && trumpet > 0)
 | 
			
		||||
                {
 | 
			
		||||
                    trumpet -= 1;
 | 
			
		||||
                }
 | 
			
		||||
                // check if double jump, play sound
 | 
			
		||||
                if (trumpet == 0) {
 | 
			
		||||
                    gameObject.transform.Find("Trumpet").GetComponent<AudioSource>().Play();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            //Right Wall Check
 | 
			
		||||
            if (((Physics2D.OverlapBox(this.transform.position, _wallCheckSize, 0, _groundLayer) && IsFacingRight)
 | 
			
		||||
                    || (Physics2D.OverlapBox(this.transform.position, _wallCheckSize, 0, _groundLayer) && !IsFacingRight)) && !IsWallJumping)
 | 
			
		||||
                LastOnWallRightTime = Data.coyoteTime;
 | 
			
		||||
 | 
			
		||||
            //Right Wall Check
 | 
			
		||||
            if (((Physics2D.OverlapBox(this.transform.position, _wallCheckSize, 0, _groundLayer) && !IsFacingRight)
 | 
			
		||||
                || (Physics2D.OverlapBox(this.transform.position, _wallCheckSize, 0, _groundLayer) && IsFacingRight)) && !IsWallJumping)
 | 
			
		||||
                LastOnWallLeftTime = Data.coyoteTime;
 | 
			
		||||
 | 
			
		||||
            //Two checks needed for both left and right walls since whenever the play turns the wall checkPoints swap sides
 | 
			
		||||
            LastOnWallTime = Mathf.Max(LastOnWallLeftTime, LastOnWallRightTime);
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region JUMP CHECKS
 | 
			
		||||
        if (IsJumping && RB.velocity.y <= 0)
 | 
			
		||||
        {
 | 
			
		||||
            IsJumping = false;
 | 
			
		||||
            // print("isJumping " + IsJumping);
 | 
			
		||||
 | 
			
		||||
            if (!IsWallJumping)
 | 
			
		||||
                _isJumpFalling = true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (IsWallJumping && Time.time - _wallJumpStartTime > Data.wallJumpTime)
 | 
			
		||||
        {
 | 
			
		||||
            IsWallJumping = false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (LastOnGroundTime > 0 && !IsJumping && !IsWallJumping)
 | 
			
		||||
        {
 | 
			
		||||
            _isJumpCut = false;
 | 
			
		||||
 | 
			
		||||
            if (!IsJumping)
 | 
			
		||||
                _isJumpFalling = false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //Jump
 | 
			
		||||
        if (CanJump() && LastPressedJumpTime > 0)
 | 
			
		||||
        {
 | 
			
		||||
            IsJumping = true;
 | 
			
		||||
            IsWallJumping = false;
 | 
			
		||||
            _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;
 | 
			
		||||
            // stop sound if needed
 | 
			
		||||
            if (soundPlaying && (isRegFalling || IsJumping || _isJumpFalling)) {
 | 
			
		||||
                print("footsteps stop");
 | 
			
		||||
                audioSource.Stop();
 | 
			
		||||
                soundPlaying = false;
 | 
			
		||||
            }
 | 
			
		||||
            else if (!IsGrounded() && !in_range && trumpet > 0)
 | 
			
		||||
            {
 | 
			
		||||
                trumpet -= 1;
 | 
			
		||||
 | 
			
		||||
            //WALL JUMP
 | 
			
		||||
            // else if (CanWallJump() && LastPressedJumpTime > 0)
 | 
			
		||||
            // {
 | 
			
		||||
            //     IsWallJumping = true;
 | 
			
		||||
            //     IsJumping = false;
 | 
			
		||||
            //     _isJumpCut = false;
 | 
			
		||||
            //     _isJumpFalling = false;
 | 
			
		||||
            //     _wallJumpStartTime = Time.time;
 | 
			
		||||
            //     _lastWallJumpDir = (LastOnWallRightTime > 0) ? -1 : 1;
 | 
			
		||||
            //
 | 
			
		||||
            //     WallJump(_lastWallJumpDir);
 | 
			
		||||
            // }
 | 
			
		||||
            #endregion
 | 
			
		||||
 | 
			
		||||
            #region GRAPPLE CHECKS
 | 
			
		||||
            // set wasGrappling to true if the player starts grappling
 | 
			
		||||
            if (grapplingRope.isGrappling) {
 | 
			
		||||
                wasGrappling = true;
 | 
			
		||||
            }
 | 
			
		||||
            // check if double jump, play sound
 | 
			
		||||
            #endregion
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            #region SLIDE CHECKS
 | 
			
		||||
            if (CanSlide() && ((LastOnWallLeftTime > 0 && _moveInput.x < 0) || (LastOnWallRightTime > 0 && _moveInput.x > 0)))
 | 
			
		||||
                IsSliding = true;
 | 
			
		||||
            else
 | 
			
		||||
                IsSliding = false;
 | 
			
		||||
            #endregion
 | 
			
		||||
 | 
			
		||||
            #region GRAVITY
 | 
			
		||||
            //Higher gravity if we've released the jump input or are falling
 | 
			
		||||
            if (IsSliding)
 | 
			
		||||
            {
 | 
			
		||||
                SetGravityScale(0);
 | 
			
		||||
            }
 | 
			
		||||
            else if (RB.velocity.y < 0 && _moveInput.y < 0)
 | 
			
		||||
            {
 | 
			
		||||
                //Much higher gravity if holding down
 | 
			
		||||
                SetGravityScale(Data.gravityScale * Data.fastFallGravityMult);
 | 
			
		||||
                //Caps maximum fall speed, so when falling over large distances we don't accelerate to insanely high speeds
 | 
			
		||||
                RB.velocity = new Vector2(RB.velocity.x, Mathf.Max(RB.velocity.y, -Data.maxFastFallSpeed));
 | 
			
		||||
            }
 | 
			
		||||
            else if (_isJumpCut)
 | 
			
		||||
            {
 | 
			
		||||
                //Higher gravity if jump button released
 | 
			
		||||
                SetGravityScale(Data.gravityScale * Data.jumpCutGravityMult);
 | 
			
		||||
                RB.velocity = new Vector2(RB.velocity.x, Mathf.Max(RB.velocity.y, -Data.maxFallSpeed));
 | 
			
		||||
            }
 | 
			
		||||
            else if ((IsJumping || IsWallJumping || _isJumpFalling) && Mathf.Abs(RB.velocity.y) < Data.jumpHangTimeThreshold)
 | 
			
		||||
            {
 | 
			
		||||
                SetGravityScale(Data.gravityScale * Data.jumpHangGravityMult);
 | 
			
		||||
            }
 | 
			
		||||
            else if (RB.velocity.y < 0)
 | 
			
		||||
            {
 | 
			
		||||
                //Higher gravity if falling
 | 
			
		||||
                SetGravityScale(Data.gravityScale * Data.fallGravityMult);
 | 
			
		||||
                //Caps maximum fall speed, so when falling over large distances we don't accelerate to insanely high speeds
 | 
			
		||||
                RB.velocity = new Vector2(RB.velocity.x, Mathf.Max(RB.velocity.y, -Data.maxFallSpeed));
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                //Default gravity if standing on a platform or moving upwards
 | 
			
		||||
                SetGravityScale(Data.gravityScale);
 | 
			
		||||
            }
 | 
			
		||||
            #endregion
 | 
			
		||||
 | 
			
		||||
            #region SOUND CHECKS
 | 
			
		||||
            if (!IsJumping && !_isJumpFalling && !isRegFalling && _moveInput.x != 0) {
 | 
			
		||||
                if (!soundPlaying) {
 | 
			
		||||
                    // print("footsteps PLAY");
 | 
			
		||||
                    audioSource.Play();
 | 
			
		||||
                    soundPlaying = true;
 | 
			
		||||
                }
 | 
			
		||||
            } else if (soundPlaying && audioSource.clip.name == "footsteps") {
 | 
			
		||||
                // print("footsteps stop");
 | 
			
		||||
                audioSource.Stop();
 | 
			
		||||
                soundPlaying = false;
 | 
			
		||||
            }
 | 
			
		||||
            #endregion
 | 
			
		||||
 | 
			
		||||
            #region UPDATE UI
 | 
			
		||||
            if (trumpet == 0) {
 | 
			
		||||
                gameObject.transform.Find("Trumpet").GetComponent<AudioSource>().Play();
 | 
			
		||||
                gameUI.ToggleTrumpet(false);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // stop sound if needed
 | 
			
		||||
        if (soundPlaying && (isRegFalling || IsJumping || _isJumpFalling)) {
 | 
			
		||||
            print("footsteps stop");
 | 
			
		||||
            audioSource.Stop();
 | 
			
		||||
            soundPlaying = false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //WALL JUMP
 | 
			
		||||
        // else if (CanWallJump() && LastPressedJumpTime > 0)
 | 
			
		||||
        // {
 | 
			
		||||
        //     IsWallJumping = true;
 | 
			
		||||
        //     IsJumping = false;
 | 
			
		||||
        //     _isJumpCut = false;
 | 
			
		||||
        //     _isJumpFalling = false;
 | 
			
		||||
        //     _wallJumpStartTime = Time.time;
 | 
			
		||||
        //     _lastWallJumpDir = (LastOnWallRightTime > 0) ? -1 : 1;
 | 
			
		||||
        //
 | 
			
		||||
        //     WallJump(_lastWallJumpDir);
 | 
			
		||||
        // }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region GRAPPLE CHECKS
 | 
			
		||||
        // set wasGrappling to true if the player starts grappling
 | 
			
		||||
        if (grapplingRope.isGrappling) {
 | 
			
		||||
            wasGrappling = true;
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        #region SLIDE CHECKS
 | 
			
		||||
        if (CanSlide() && ((LastOnWallLeftTime > 0 && _moveInput.x < 0) || (LastOnWallRightTime > 0 && _moveInput.x > 0)))
 | 
			
		||||
            IsSliding = true;
 | 
			
		||||
        else
 | 
			
		||||
            IsSliding = false;
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region GRAVITY
 | 
			
		||||
        //Higher gravity if we've released the jump input or are falling
 | 
			
		||||
        if (IsSliding)
 | 
			
		||||
        {
 | 
			
		||||
            SetGravityScale(0);
 | 
			
		||||
        }
 | 
			
		||||
        else if (RB.velocity.y < 0 && _moveInput.y < 0)
 | 
			
		||||
        {
 | 
			
		||||
            //Much higher gravity if holding down
 | 
			
		||||
            SetGravityScale(Data.gravityScale * Data.fastFallGravityMult);
 | 
			
		||||
            //Caps maximum fall speed, so when falling over large distances we don't accelerate to insanely high speeds
 | 
			
		||||
            RB.velocity = new Vector2(RB.velocity.x, Mathf.Max(RB.velocity.y, -Data.maxFastFallSpeed));
 | 
			
		||||
        }
 | 
			
		||||
        else if (_isJumpCut)
 | 
			
		||||
        {
 | 
			
		||||
            //Higher gravity if jump button released
 | 
			
		||||
            SetGravityScale(Data.gravityScale * Data.jumpCutGravityMult);
 | 
			
		||||
            RB.velocity = new Vector2(RB.velocity.x, Mathf.Max(RB.velocity.y, -Data.maxFallSpeed));
 | 
			
		||||
        }
 | 
			
		||||
        else if ((IsJumping || IsWallJumping || _isJumpFalling) && Mathf.Abs(RB.velocity.y) < Data.jumpHangTimeThreshold)
 | 
			
		||||
        {
 | 
			
		||||
            SetGravityScale(Data.gravityScale * Data.jumpHangGravityMult);
 | 
			
		||||
        }
 | 
			
		||||
        else if (RB.velocity.y < 0)
 | 
			
		||||
        {
 | 
			
		||||
            //Higher gravity if falling
 | 
			
		||||
            SetGravityScale(Data.gravityScale * Data.fallGravityMult);
 | 
			
		||||
            //Caps maximum fall speed, so when falling over large distances we don't accelerate to insanely high speeds
 | 
			
		||||
            RB.velocity = new Vector2(RB.velocity.x, Mathf.Max(RB.velocity.y, -Data.maxFallSpeed));
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            //Default gravity if standing on a platform or moving upwards
 | 
			
		||||
            SetGravityScale(Data.gravityScale);
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region SOUND CHECKS
 | 
			
		||||
        if (!IsJumping && !_isJumpFalling && !isRegFalling && _moveInput.x != 0) {
 | 
			
		||||
            if (!soundPlaying) {
 | 
			
		||||
                // print("footsteps PLAY");
 | 
			
		||||
                audioSource.Play();
 | 
			
		||||
                soundPlaying = true;
 | 
			
		||||
            if (isDashing)
 | 
			
		||||
            {
 | 
			
		||||
                gameUI.ToggleClarinet(false);
 | 
			
		||||
            }
 | 
			
		||||
        } else if (soundPlaying && audioSource.clip.name == "footsteps") {
 | 
			
		||||
            // print("footsteps stop");
 | 
			
		||||
            audioSource.Stop();
 | 
			
		||||
            soundPlaying = false;
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
 | 
			
		||||
        #region UPDATE UI
 | 
			
		||||
        if (trumpet == 0) {
 | 
			
		||||
            gameUI.ToggleTrumpet(false);
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
            #endregion
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -390,6 +394,7 @@ public class PlayerMovement : MonoBehaviour
 | 
			
		||||
    #region RUN METHODS
 | 
			
		||||
    private void Run(float lerpAmount)
 | 
			
		||||
    {
 | 
			
		||||
        if(!isDashing){
 | 
			
		||||
        //Calculate the direction we want to move in and our desired velocity
 | 
			
		||||
        float targetSpeed = _moveInput.x * Data.runMaxSpeed;
 | 
			
		||||
        //We can reduce are control using Lerp() this smooths changes to are direction and speed
 | 
			
		||||
@@ -443,6 +448,7 @@ public class PlayerMovement : MonoBehaviour
 | 
			
		||||
		 * RB.velocity = new Vector2(RB.velocity.x + (Time.fixedDeltaTime  * speedDif * accelRate) / RB.mass, RB.velocity.y);
 | 
			
		||||
		 * Time.fixedDeltaTime is by default in Unity 0.02 seconds equal to 50 FixedUpdate() calls per second
 | 
			
		||||
		*/
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void Turn()
 | 
			
		||||
@@ -459,6 +465,7 @@ public class PlayerMovement : MonoBehaviour
 | 
			
		||||
    #region JUMP METHODS
 | 
			
		||||
    private void Jump()
 | 
			
		||||
    {
 | 
			
		||||
        if(!isDashing){
 | 
			
		||||
        //Ensures we can't call Jump multiple times from one press
 | 
			
		||||
        LastPressedJumpTime = 0;
 | 
			
		||||
        LastOnGroundTime = 0;
 | 
			
		||||
@@ -473,6 +480,7 @@ public class PlayerMovement : MonoBehaviour
 | 
			
		||||
 | 
			
		||||
        RB.AddForce(Vector2.up * force, ForceMode2D.Impulse);
 | 
			
		||||
        #endregion
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void WallJump(int dir)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user