Commit ce991bfa by Philipp Adolf

Fix shields not being deleted on restart

parent 97c74495
...@@ -12,6 +12,7 @@ public class ShieldScript : MonoBehaviour ...@@ -12,6 +12,7 @@ public class ShieldScript : MonoBehaviour
// used to store the position while the trap is deactivated // used to store the position while the trap is deactivated
private Vector2 spawnPosition; private Vector2 spawnPosition;
private Transform spawnParent;
public float relayDelay = 0.25f; public float relayDelay = 0.25f;
private bool canRelay = true; private bool canRelay = true;
...@@ -21,6 +22,7 @@ public class ShieldScript : MonoBehaviour ...@@ -21,6 +22,7 @@ public class ShieldScript : MonoBehaviour
void Start() void Start()
{ {
spawnPosition = transform.position; spawnPosition = transform.position;
spawnParent = transform.parent;
pickupAudio = GetComponent<AudioSource>(); pickupAudio = GetComponent<AudioSource>();
} }
...@@ -53,7 +55,7 @@ public class ShieldScript : MonoBehaviour ...@@ -53,7 +55,7 @@ public class ShieldScript : MonoBehaviour
CancelInvoke("stopShielding"); CancelInvoke("stopShielding");
if (parentHealth != null) parentHealth.setShield(false); if (parentHealth != null) parentHealth.setShield(false);
parentHealth = null; parentHealth = null;
transform.parent = null; transform.parent = spawnParent;
transform.position = new Vector2(100, 100); transform.position = new Vector2(100, 100);
Invoke("Activate", respawnTime); Invoke("Activate", respawnTime);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment