Commit ed2d0627 by Philipp Adolf

Fix fire oscilating between players

parent 113a58be
...@@ -15,6 +15,9 @@ public class FireScript : MonoBehaviour ...@@ -15,6 +15,9 @@ public class FireScript : MonoBehaviour
private Vector2 spawnPosition; private Vector2 spawnPosition;
public float respawnTime = 5.0f; public float respawnTime = 5.0f;
public float relayDelay = 0.25f;
private bool canRelay = true;
void Start() void Start()
{ {
startScale = transform.localScale; startScale = transform.localScale;
...@@ -32,16 +35,23 @@ public class FireScript : MonoBehaviour ...@@ -32,16 +35,23 @@ public class FireScript : MonoBehaviour
void OnTriggerEnter2D(Collider2D other) void OnTriggerEnter2D(Collider2D other)
{ {
if (other.tag == "Player") if (canRelay && other.tag == "Player")
{ {
Invoke("stopBurning", burningTime); Invoke("stopBurning", burningTime);
parentHealth = other.GetComponent<PlayerHealth>(); parentHealth = other.GetComponent<PlayerHealth>();
transform.position = other.transform.position; //hier schon position setzen transform.position = other.transform.position; //hier schon position setzen
transform.parent = other.transform; transform.parent = other.transform;
transform.localScale = startScale; transform.localScale = startScale;
canRelay = false;
Invoke("enableRelay", relayDelay);
} }
} }
void enableRelay()
{
canRelay = true;
}
void stopBurning() void stopBurning()
{ {
CancelInvoke("stopBurning"); CancelInvoke("stopBurning");
......
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