AutoKillOnEnter.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. //***********************************************************
  2. // Filename: AutoKillOnEnter.cs
  3. // Author: Marco Fendrich, Moritz Kolvenbach
  4. // Last changes: Thursday, 9th of August 2018
  5. // Content: Destroys the start area and ends the tutorial as soon as the player leaves the start area
  6. //***********************************************************
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using UnityEngine;
  10. /// <summary>
  11. /// Destroys start area and ends the tutorial as soon as the player leaves the start area
  12. /// </summary>
  13. public class AutoKillOnEnter : MonoBehaviour
  14. {
  15. // The object that is destroyed as soon as a collision with the object that this script is attached to occurs
  16. public GameObject objectToBeDestroyed;
  17. // The targetManager; needed so this script can update isExpActive on collision
  18. public TargetManager targetManager;
  19. /// <summary>
  20. /// Updates isExpActive, destroys the given object and the object this script is attached to
  21. /// </summary>
  22. /// <param name="other"> The collider of the obejct this script is attached to</param>
  23. void OnTriggerStay(Collider other)
  24. {
  25. targetManager.isExpActive = true;
  26. Destroy(objectToBeDestroyed);
  27. Destroy(gameObject);
  28. }
  29. }