This repository has been archived by the owner on Mar 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
455 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
PlatformerController/Assets/Scripts/Core/Components/CollisionSenses.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using UnityEngine; | ||
|
||
public class CollisionSenses : CoreComponent | ||
{ | ||
[SerializeField] private float groundCheckRadius; | ||
[SerializeField] private float wallCheckDistance; | ||
|
||
[SerializeField] private LayerMask whatIsGround; | ||
|
||
[SerializeField] private Transform groundCheck; | ||
[SerializeField] private Transform wallCheck; | ||
[SerializeField] private Transform ledgeCheck; | ||
[SerializeField] private Transform ceilingCheck; | ||
|
||
public float GroundCheckRadius => groundCheckRadius; | ||
|
||
public float WallCheckDistance => wallCheckDistance; | ||
|
||
public LayerMask WhatIsGround => whatIsGround; | ||
|
||
public Transform GroundCheck => groundCheck; | ||
public Transform WallCheck => wallCheck; | ||
public Transform LedgeCheck => ledgeCheck; | ||
public Transform CeilingCheck => ceilingCheck; | ||
|
||
public bool Ceiling => Physics2D.OverlapCircle(ceilingCheck.position, groundCheckRadius, whatIsGround); | ||
|
||
public bool Ground => Physics2D.OverlapCircle(groundCheck.position, groundCheckRadius, whatIsGround); | ||
|
||
public bool WallFront => Physics2D.Raycast(wallCheck.position, Vector2.right * core.Movement.FacingDirection, | ||
wallCheckDistance, whatIsGround); | ||
|
||
public bool WallBack => Physics2D.Raycast(wallCheck.position, Vector2.right * -core.Movement.FacingDirection, | ||
wallCheckDistance, whatIsGround); | ||
|
||
public bool Ledge => Physics2D.Raycast(ledgeCheck.position, Vector2.right * core.Movement.FacingDirection, | ||
wallCheckDistance, whatIsGround); | ||
} |
11 changes: 11 additions & 0 deletions
11
PlatformerController/Assets/Scripts/Core/Components/CollisionSenses.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
PlatformerController/Assets/Scripts/Core/Components/CoreComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using UnityEngine; | ||
|
||
public class CoreComponent : MonoBehaviour | ||
{ | ||
protected Core core; | ||
|
||
protected virtual void Awake() | ||
{ | ||
core = transform.parent.GetComponent<Core>(); | ||
|
||
if (!core) | ||
{ | ||
Debug.LogError("There is no Core on the parent."); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
PlatformerController/Assets/Scripts/Core/Components/CoreComponent.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.