![]() |
Eye of the Nile Docs
Everything you need to know to get started!
|
If something enters this object's trigger zone, this script will spawn an object or projectile. This is useful for stage hazards, such as the arrow trap.
Documentation updated 1/31/2025
Public Attributes | |
GameObject | projectilePrefab |
Projectile to spawn when an object enters the trigger zone. | |
Transform | spawnPoint |
Position where the projectile should be spawned. | |
float | spawnCooldown = 3f |
How long, in seconds, until another projectile can be spawned. | |
bool | facingLeft = true |
Should the projectile be facing left? | |
bool | playerOnly = true |
Should enemies be able to activate the trigger zone, or just the player? | |
Private Member Functions | |
void | Start () |
Start cooldownTimer at spawnCooldown so the projectile can be spawned immediately. | |
void | Update () |
Increase cooldownTimer by the amount of time that's passed since the last frame. | |
void | OnTriggerEnter2D (Collider2D col) |
If an object enters the trigger zone (and the cooldown is up), instantiate a new instance of projectilePrefab. If playerOnly is enabled, only the player can trigger the projectile. Make sure it's facing the right direction (if projectilePrefab is actually a BasicProjectile), and reset the cooldown timer. | |
Private Attributes | |
float | cooldownTimer = 0f |
Seconds since cooldown was last started. When greater than spawnCooldown, cooldown is over. | |
|
private |
If an object enters the trigger zone (and the cooldown is up), instantiate a new instance of projectilePrefab. If playerOnly is enabled, only the player can trigger the projectile. Make sure it's facing the right direction (if projectilePrefab is actually a BasicProjectile), and reset the cooldown timer.
col | Represents the object that's entered the trigger zone. |
|
private |
Start cooldownTimer at spawnCooldown so the projectile can be spawned immediately.
|
private |
Increase cooldownTimer by the amount of time that's passed since the last frame.
|
private |
Seconds since cooldown was last started. When greater than spawnCooldown, cooldown is over.
bool SpawnOnTrigger.facingLeft = true |
Should the projectile be facing left?
bool SpawnOnTrigger.playerOnly = true |
Should enemies be able to activate the trigger zone, or just the player?
GameObject SpawnOnTrigger.projectilePrefab |
Projectile to spawn when an object enters the trigger zone.
float SpawnOnTrigger.spawnCooldown = 3f |
How long, in seconds, until another projectile can be spawned.
Transform SpawnOnTrigger.spawnPoint |
Position where the projectile should be spawned.