I’m working on my game and have a script that is supposed to add extra time if an object is destroyed, But i’ve met a problem, both the player and the object is destroyed and no extra time is given
Is there something wrong in the script?
using UnityEngine;
using System.Collections;
public class EkstraTid : MonoBehaviour {
Tid tid;
public int ekstraTid;
private bool _triggered;
void Start ()
{
}
void Update ()
{
if (_triggered)
Destroy(gameObject);
}
void OnTriggerEnter(Collider other) {
if (other.gameObject.CompareTag("EkstraTid"))
tid.tiden += 100f;
_triggered = true;
Destroy(other.gameObject);
print ("object Destroyed");
}
}
Edit. Removed some unused lines in script