Adapted movement controller to work with master

This commit is contained in:
Nicholas Novak 2023-04-27 12:54:31 -07:00
parent ad3b8f9166
commit 8e221cf94b
2 changed files with 20 additions and 11 deletions

View File

@ -2725,6 +2725,18 @@ PrefabInstance:
propertyPath: m_camera propertyPath: m_camera
value: value:
objectReference: {fileID: 519420031} 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} - target: {fileID: 5885597207104481986, guid: 576d3fc87874f426294e4bbacb171478, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 9 value: 9

View File

@ -43,12 +43,9 @@ public class PlayerMovement : MonoBehaviour
//Set all of these up in the inspector //Set all of these up in the inspector
[Header("Checks")] [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) //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 Vector2 _groundCheckSize = new Vector2(0.49f, 0.03f);
[Space(5)] [Space(5)]
[SerializeField] private Transform _frontWallCheckPoint;
[SerializeField] private Transform _backWallCheckPoint;
[SerializeField] private Vector2 _wallCheckSize = new Vector2(0.5f, 1f); [SerializeField] private Vector2 _wallCheckSize = new Vector2(0.5f, 1f);
[Header("Layers & Tags")] [Header("Layers & Tags")]
@ -97,19 +94,19 @@ public class PlayerMovement : MonoBehaviour
if (!IsJumping) if (!IsJumping)
{ {
//Ground Check //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 LastOnGroundTime = Data.coyoteTime; //if so sets the lastGrounded to coyoteTime
} }
//Right Wall Check //Right Wall Check
if (((Physics2D.OverlapBox(_frontWallCheckPoint.position, _wallCheckSize, 0, _groundLayer) && IsFacingRight) if (((Physics2D.OverlapBox(this.transform.position, _wallCheckSize, 0, _groundLayer) && IsFacingRight)
|| (Physics2D.OverlapBox(_backWallCheckPoint.position, _wallCheckSize, 0, _groundLayer) && !IsFacingRight)) && !IsWallJumping) || (Physics2D.OverlapBox(this.transform.position, _wallCheckSize, 0, _groundLayer) && !IsFacingRight)) && !IsWallJumping)
LastOnWallRightTime = Data.coyoteTime; LastOnWallRightTime = Data.coyoteTime;
//Right Wall Check //Right Wall Check
if (((Physics2D.OverlapBox(_frontWallCheckPoint.position, _wallCheckSize, 0, _groundLayer) && !IsFacingRight) if (((Physics2D.OverlapBox(this.transform.position, _wallCheckSize, 0, _groundLayer) && !IsFacingRight)
|| (Physics2D.OverlapBox(_backWallCheckPoint.position, _wallCheckSize, 0, _groundLayer) && IsFacingRight)) && !IsWallJumping) || (Physics2D.OverlapBox(this.transform.position, _wallCheckSize, 0, _groundLayer) && IsFacingRight)) && !IsWallJumping)
LastOnWallLeftTime = Data.coyoteTime; LastOnWallLeftTime = Data.coyoteTime;
//Two checks needed for both left and right walls since whenever the play turns the wall checkPoints swap sides //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() private void OnDrawGizmosSelected()
{ {
Gizmos.color = Color.green; Gizmos.color = Color.green;
Gizmos.DrawWireCube(_groundCheckPoint.position, _groundCheckSize); Gizmos.DrawWireCube(this.transform.position, _groundCheckSize);
Gizmos.color = Color.blue; Gizmos.color = Color.blue;
Gizmos.DrawWireCube(_frontWallCheckPoint.position, _wallCheckSize); Gizmos.DrawWireCube(this.transform.position, _wallCheckSize);
Gizmos.DrawWireCube(_backWallCheckPoint.position, _wallCheckSize); Gizmos.DrawWireCube(this.transform.position, _wallCheckSize);
} }
#endregion #endregion
} }