![]() |
Eye of the Nile Docs
Everything you need to know to get started!
|
When the player presses the interactKey, this script will search for nearby interactable objects. If an interactable object is within range, this script will tell that object to trigger its functionality. It will also wait to see if the user holds the interact key down for long enough for it to be considered a "long press" and triggers any additional functionality.
Documentation updated 4/6/2025
Public Attributes | |
Transform | attackPoint |
Reference to the player's's attack point. It's a point in space that's a child of the player, existing some distance in front of it. Projectiles spawn from the attack point, and melee attacks scan for enemies to damage from a certain radius around it. | |
LayerMask | interactableLayers |
List of layers that the player can interact with objects on. | |
float | interactRange = 0.5f |
Distance from the attack point an object can be to allow interaction. | |
string | interactKey = "e" |
Name of the key the player must press to interact with an object. | |
float | interactCooldown = 0.5f |
Cooldown time after an interaction has happened, in seconds. | |
float | longPressLength = 1f |
Amount of seconds the user should have to hold the interact button to trigger a long press interaction. | |
List< Collider2D > | touchedInteractables |
List of all interactables overlapping with the player's hitbox. | |
Collider2D[] | previouslyInRange |
Keep track of which interactables were in range on the previous frame/game loop cycle. Used for triggerProximityEnter/Stay/Exit. | |
Events | |
static Action< float > | interactProgress |
An event that reports the current progress on a long press interaction. Used for InteractProgressBar. | |
Private Member Functions | |||
void | Awake () | ||
Set reference to dataManager. | |||
void | Update () | ||
Get all interactables currently overlapping with the player's hitbox (OnTriggerEnter() and OnTriggerExit()) | |||
void | OnTriggerEnter2D (Collider2D collision) | ||
Runs when an object enters the player's hitbox. Adds any newly touched interactables to the touchedInteractables list.
| |||
void | OnTriggerExit2D (Collider2D collision) | ||
Runs when an object exits the player's hitbox. Remove any untouched interactables from the touchedInteractables list.
| |||
Private Attributes | |
DataManager | dataManager |
Reference to the DataManager. Used for checking if the Skyhub is unlocked. | |
float | cooldownTimer = 0 |
Time when cooldown time is over (interactCooldown seconds in the future). | |
bool | interactUsed |
True if the player has already interacted with an object and the cooldown needs to start. | |
float | interactTimer |
Time when long press interaction will be complete (longPressLength seconds in the future). | |
bool | longPressInteractionActive = false |
True during a long press interaction. | |
|
private |
Set reference to dataManager.
|
private |
Runs when an object enters the player's hitbox. Adds any newly touched interactables to the touchedInteractables list.
collision |
|
private |
Runs when an object exits the player's hitbox. Remove any untouched interactables from the touchedInteractables list.
collision |
|
private |
Get all interactables currently overlapping with the player's hitbox (OnTriggerEnter() and OnTriggerExit())
Otherwise...
Transform PlayerInteract.attackPoint |
Reference to the player's's attack point. It's a point in space that's a child of the player, existing some distance in front of it. Projectiles spawn from the attack point, and melee attacks scan for enemies to damage from a certain radius around it.
|
private |
Time when cooldown time is over (interactCooldown seconds in the future).
|
private |
Reference to the DataManager. Used for checking if the Skyhub is unlocked.
LayerMask PlayerInteract.interactableLayers |
List of layers that the player can interact with objects on.
float PlayerInteract.interactCooldown = 0.5f |
Cooldown time after an interaction has happened, in seconds.
string PlayerInteract.interactKey = "e" |
Name of the key the player must press to interact with an object.
float PlayerInteract.interactRange = 0.5f |
Distance from the attack point an object can be to allow interaction.
|
private |
Time when long press interaction will be complete (longPressLength seconds in the future).
|
private |
True if the player has already interacted with an object and the cooldown needs to start.
|
private |
True during a long press interaction.
float PlayerInteract.longPressLength = 1f |
Amount of seconds the user should have to hold the interact button to trigger a long press interaction.
Collider2D [] PlayerInteract.previouslyInRange |
Keep track of which interactables were in range on the previous frame/game loop cycle. Used for triggerProximityEnter/Stay/Exit.
List<Collider2D> PlayerInteract.touchedInteractables |
List of all interactables overlapping with the player's hitbox.
|
static |
An event that reports the current progress on a long press interaction. Used for InteractProgressBar.