Eye of the Nile Docs
Everything you need to know to get started!
Loading...
Searching...
No Matches
WallDetectorZone Class Reference

Detailed Description

This script is used by trigger zone(s) around some entities' sides that detects when the entity is touching a wall. This is also used by the player! Options:

  1. Attach this script to a single wall detector object that encapsulates both of the entity's sides.
  • Set "Side" to "Both" in the inspector.
  • A Collider2D must be attached to this object.
  • Also attach WallDetectorInfo.cs to this object.
  1. Have a wall detector (attach WallDetectorInfo.cs to it) and give it two children:
  • A trigger zone that encapsulates the front side of the entity.
  • A trigger zone that encapsulates the back side of the entity.
  • Attach this script to both children and set "Side" to "Front" and "Back" on each, respectively.
  • Each trigger zone must have some kind of Collider2D attached.

This detects the layer(s) selected on this script in the inspector, which should usually be set to "Ground" and "Collision" This script can only detect objects that have colliders.

Documentation updated 12/19/2024

Author
Alexander Art

Private Member Functions

void Awake ()
 
void OnTriggerEnter2D (Collider2D col)
 Runs when an object enters the wall detector zone. Updates WallDetectorInfo.
 
void OnTriggerStay2D (Collider2D col)
 Runs when an object is inside the wall detector zone. Updates WallDetectorInfo. This part is not necessary for the wall detector to work, but it is kept for redundancy.
 
void OnTriggerExit2D (Collider2D col)
 Runs when an object exits the wall detector zone. Updates WallDetectorInfo.
 

Private Attributes

WallDetectorSide side = WallDetectorSide.Both
 Tell this script in the inspector which side of the entity this trigger zone is attached to.
 
WallDetectorInfo wallDetectorInfo
 

Member Function Documentation

◆ Awake()

void WallDetectorZone.Awake ( )
private

◆ OnTriggerEnter2D()

void WallDetectorZone.OnTriggerEnter2D ( Collider2D col)
private

Runs when an object enters the wall detector zone. Updates WallDetectorInfo.

Parameters
colRepresents the object inside the trigger zone.

◆ OnTriggerExit2D()

void WallDetectorZone.OnTriggerExit2D ( Collider2D col)
private

Runs when an object exits the wall detector zone. Updates WallDetectorInfo.

Parameters
colRepresents the object inside the trigger zone.

◆ OnTriggerStay2D()

void WallDetectorZone.OnTriggerStay2D ( Collider2D col)
private

Runs when an object is inside the wall detector zone. Updates WallDetectorInfo. This part is not necessary for the wall detector to work, but it is kept for redundancy.

Parameters
colRepresents the object inside the trigger zone.

Member Data Documentation

◆ side

WallDetectorSide WallDetectorZone.side = WallDetectorSide.Both
private

Tell this script in the inspector which side of the entity this trigger zone is attached to.

◆ wallDetectorInfo

WallDetectorInfo WallDetectorZone.wallDetectorInfo
private

WallDetectorInfo is what keeps track of when the entity is touching a wall and which layers should count as wall. If the wall detector has one trigger zone, WallDetectorInfo will be on this script. If the wall detector has two trigger zones, WallDetectorInfo will be on the parent object of this script.


The documentation for this class was generated from the following file: