From 8e221cf94b0d16ff470a0b3451d58d3494f02305 Mon Sep 17 00:00:00 2001 From: Nicholas Novak <34256932+NickyBoy89@users.noreply.github.com> Date: Thu, 27 Apr 2023 12:54:31 -0700 Subject: [PATCH] Adapted movement controller to work with master --- Assets/Scenes/GrappleScene.unity | 12 ++++++++++++ Assets/Scripts/PlayerController.cs | 19 ++++++++----------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/Assets/Scenes/GrappleScene.unity b/Assets/Scenes/GrappleScene.unity index 8b8632a..8817c62 100644 --- a/Assets/Scenes/GrappleScene.unity +++ b/Assets/Scenes/GrappleScene.unity @@ -2725,6 +2725,18 @@ PrefabInstance: propertyPath: m_camera value: objectReference: {fileID: 519420031} + - target: {fileID: 5559747613460074786, guid: 576d3fc87874f426294e4bbacb171478, type: 3} + propertyPath: Data + value: + objectReference: {fileID: 11400000, guid: fec218a9d55267dedac6ebe31eab6dcd, type: 2} + - target: {fileID: 5559747613460074786, guid: 576d3fc87874f426294e4bbacb171478, type: 3} + propertyPath: _groundCheckSize.y + value: 0.93 + objectReference: {fileID: 0} + - target: {fileID: 5559747613460074786, guid: 576d3fc87874f426294e4bbacb171478, type: 3} + propertyPath: _groundLayer.m_Bits + value: 64 + objectReference: {fileID: 0} - target: {fileID: 5885597207104481986, guid: 576d3fc87874f426294e4bbacb171478, type: 3} propertyPath: m_RootOrder value: 9 diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index 96b1ed3..b704b9b 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -43,12 +43,9 @@ public class PlayerMovement : MonoBehaviour //Set all of these up in the inspector [Header("Checks")] - [SerializeField] private Transform _groundCheckPoint; //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); [Space(5)] - [SerializeField] private Transform _frontWallCheckPoint; - [SerializeField] private Transform _backWallCheckPoint; [SerializeField] private Vector2 _wallCheckSize = new Vector2(0.5f, 1f); [Header("Layers & Tags")] @@ -97,19 +94,19 @@ public class PlayerMovement : MonoBehaviour if (!IsJumping) { //Ground Check - if (Physics2D.OverlapBox(_groundCheckPoint.position, _groundCheckSize, 0, _groundLayer) && !IsJumping) //checks if set box overlaps with ground + if (Physics2D.OverlapBox(this.transform.position, _groundCheckSize, 0, _groundLayer) && !IsJumping) //checks if set box overlaps with ground { LastOnGroundTime = Data.coyoteTime; //if so sets the lastGrounded to coyoteTime } //Right Wall Check - if (((Physics2D.OverlapBox(_frontWallCheckPoint.position, _wallCheckSize, 0, _groundLayer) && IsFacingRight) - || (Physics2D.OverlapBox(_backWallCheckPoint.position, _wallCheckSize, 0, _groundLayer) && !IsFacingRight)) && !IsWallJumping) + 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(_frontWallCheckPoint.position, _wallCheckSize, 0, _groundLayer) && !IsFacingRight) - || (Physics2D.OverlapBox(_backWallCheckPoint.position, _wallCheckSize, 0, _groundLayer) && IsFacingRight)) && !IsWallJumping) + 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 @@ -409,10 +406,10 @@ public class PlayerMovement : MonoBehaviour private void OnDrawGizmosSelected() { Gizmos.color = Color.green; - Gizmos.DrawWireCube(_groundCheckPoint.position, _groundCheckSize); + Gizmos.DrawWireCube(this.transform.position, _groundCheckSize); Gizmos.color = Color.blue; - Gizmos.DrawWireCube(_frontWallCheckPoint.position, _wallCheckSize); - Gizmos.DrawWireCube(_backWallCheckPoint.position, _wallCheckSize); + Gizmos.DrawWireCube(this.transform.position, _wallCheckSize); + Gizmos.DrawWireCube(this.transform.position, _wallCheckSize); } #endregion }