mirror of
https://github.com/frizbee19/FebGameJam.git
synced 2026-11-11 04:22:40 +00:00
RESPAWNER
This commit is contained in:
1 parent
0629824797
commit
e1da79c14e
4 files changed
+16
-7
No files matched your search
@@ -7,7 +7,6 @@ public class SpawnTrigger : Trigger
|
|||||||
[SerializeField] float despawnTimer = 10f;
|
[SerializeField] float despawnTimer = 10f;
|
||||||
[SerializeField] GameObject entity;
|
[SerializeField] GameObject entity;
|
||||||
[SerializeField] Vector2 startPos;
|
[SerializeField] Vector2 startPos;
|
||||||
private GameObject clone;
|
|
||||||
private bool spawned;
|
private bool spawned;
|
||||||
[SerializeField] bool respawns = false;
|
[SerializeField] bool respawns = false;
|
||||||
[SerializeField] float respawnTime = 3f;
|
[SerializeField] float respawnTime = 3f;
|
||||||
@@ -17,11 +16,15 @@ public class SpawnTrigger : Trigger
|
|||||||
|
|
||||||
//And function itself
|
//And function itself
|
||||||
IEnumerator SpawnDespawn(){
|
IEnumerator SpawnDespawn(){
|
||||||
|
GameObject clone;
|
||||||
|
|
||||||
clone = Instantiate(entity, startPos, Quaternion.identity);
|
clone = Instantiate(entity, startPos, Quaternion.identity);
|
||||||
clone.gameObject.SetActive(true);
|
clone.gameObject.SetActive(true);
|
||||||
yield return new WaitForSeconds(despawnTimer);
|
yield return new WaitForSeconds(despawnTimer);
|
||||||
Destroy(clone);
|
Destroy(clone);
|
||||||
this.gameObject.SetActive(false);
|
if(!respawns) {
|
||||||
|
this.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public override void Action() {
|
public override void Action() {
|
||||||
if(!spawned && !respawns) {
|
if(!spawned && !respawns) {
|
||||||
@@ -29,10 +32,11 @@ public class SpawnTrigger : Trigger
|
|||||||
StartCoroutine(SpawnDespawn());
|
StartCoroutine(SpawnDespawn());
|
||||||
}
|
}
|
||||||
else if(respawns) {
|
else if(respawns) {
|
||||||
if(elapsed < respawnTime) {
|
elapsed += Time.deltaTime;
|
||||||
|
if(elapsed > respawnTime) {
|
||||||
|
|
||||||
elapsed = 0;
|
elapsed = 0;
|
||||||
|
StartCoroutine(SpawnDespawn());
|
||||||
StartCoroutine(SpawnDespawn());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,8 +56,8 @@ public abstract class Trigger : MonoBehaviour
|
|||||||
if(forceInteract)
|
if(forceInteract)
|
||||||
{
|
{
|
||||||
Action();
|
Action();
|
||||||
hasOccurred = true;
|
|
||||||
if(!repeatable) {
|
if(!repeatable) {
|
||||||
|
hasOccurred = true;
|
||||||
isActive = false;
|
isActive = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -393,11 +393,13 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
forceInteract: 1
|
forceInteract: 1
|
||||||
repeatable: 0
|
repeatable: 1
|
||||||
value: 0
|
value: 0
|
||||||
despawnTimer: 5
|
despawnTimer: 5
|
||||||
entity: {fileID: 1489501924}
|
entity: {fileID: 1489501924}
|
||||||
startPos: {x: 0, y: 0}
|
startPos: {x: 0, y: 0}
|
||||||
|
respawns: 1
|
||||||
|
respawnTime: 1
|
||||||
--- !u!61 &814501016
|
--- !u!61 &814501016
|
||||||
BoxCollider2D:
|
BoxCollider2D:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ EditorUserSettings:
|
|||||||
RecentlyUsedScenePath-1:
|
RecentlyUsedScenePath-1:
|
||||||
value: 22424703114646680e0b0227036c78111b1258192f2d28353e663536ebe73c2cf1a71aecf13f33722c0ce6281d
|
value: 22424703114646680e0b0227036c78111b1258192f2d28353e663536ebe73c2cf1a71aecf13f33722c0ce6281d
|
||||||
flags: 0
|
flags: 0
|
||||||
|
RecentlyUsedScenePath-2:
|
||||||
|
value: 22424703114646680e0b0227036c7c0219001c396c1c23233967083debf42d
|
||||||
|
flags: 0
|
||||||
vcSharedLogLevel:
|
vcSharedLogLevel:
|
||||||
value: 0d5e400f0650
|
value: 0d5e400f0650
|
||||||
flags: 0
|
flags: 0
|
||||||
|
|||||||
Reference in new issue
Block a user