Beispiel #1
0
 private void OnTriggerEnter(Collider other) //runs when this object detects another object entering it
 {
     if (other.CompareTag("Player"))         //if the colliding object has the tag "Player"
     {
         myDamage.isDamaging = false;        //Turns on the damaging function on the AccuracyCalculator script
         myDamage.UpdateDamage();            //calls to update the damage calculator so it can register the change in damage state
     }
 }
    [SerializeField] public DamageController myDamage; //provides access to the functions and data of the data controller script

    private void OnTriggerStay(Collider other)         //runs when this objects detects another object staying within it
    {
        if (other.CompareTag("Player"))                //if the colliding object has the tag "Player"
        {
            myDamage.isDamaging = true;                //Turns off the damaging boolean on the damage controller script
            myDamage.UpdateDamage();                   //triggers damage calculator to update
        }
    }
Beispiel #3
0
 /*private void OnTriggerEnter(Collider other)
  * {
  *  if (other.CompareTag("Player"))
  *  {
  *      isDamaging = true; //Turns on the damaging function on the AccuracyCalculator script
  *  }
  * }
  * private void OnTriggerExit(Collider other)
  * {
  *  if (other.CompareTag("Player"))
  *  {
  *      isDamaging = false;//Turns off the damaging function on the AccuracyCalculator script
  *  }
  * }*/
 private void OnTriggerStay(Collider other)
 {
     if (other.CompareTag("Player"))
     {
         myDamage.playerDamage = myDamage.playerDamage + 0.1f;
     }
     myDamage.UpdateDamage();
 }