private void Update() { if (player != null && (DateTime.Now - lastEncounter).TotalSeconds > timeDelay) { player.TakeDamageFromTraps(-damage); lastEncounter = DateTime.Now; } }
private void OnTriggerEnter2D(Collider2D info) { if ((DateTime.Now - lastEncounter).TotalSeconds < 0.1f) { return; } lastEncounter = DateTime.Now; player = info.GetComponent <Player_controller>(); if (player != null) { player.TakeDamageFromTraps(-damage); } }