Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Vector2 boxSize;
- public Vector2 boxOffset;
- publicLayerMask groundLayer;
- bool IsGrounded;
- void Update()
- {
- CheckGround();
- }
- void CheckGround()
- {
- Vector2 boxCenter = (Vector2)transform.position + boxOffset;
- IsGrounded = Physics2D.OverlapBox(boxCenter, boxSize, 0f, groundLayer);
- }
- void OnDrawGizmosSelected()
- {
- Gizmos.color = IsGrounded ? Color.green : Color.red;
- Vector2 boxCenter = (Vector2)transform.position + boxOffset;
- Gizmos.DrawWireCube(boxCenter, boxSize);
- }
Advertisement
Add Comment
Please, Sign In to add comment