Advertisement
iFrenzo

Untitled

Nov 17th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Damage : MonoBehaviour {
  6.    
  7.     public Health health;
  8.     public int uron;
  9.     public float AttacTime; // Период между атаками
  10.     private float t; // второстипенная переменная необходимая для выполнения логики
  11.     void OnTriggerEnter (Collider other) {  
  12.         if (other.CompareTag ("Player")) {  
  13.             health = other.GetComponent(); // назночение ссылки hp скрипта игрока которого //коснулся тригер
  14.             if (Time.time - t > AttacTime){ // алгоритм задержки между отниманием жизней
  15.                 health -= uron; // сам процесс нанесения урона
  16.                 t = Time.time; // завершение задержки
  17.             }
  18.         }  
  19.     }   
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement