Adapted movement controller to work with master
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user