Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Damage : MonoBehaviour {
- public Health health;
- public int uron;
- public float AttacTime; // Период между атаками
- private float t; // второстипенная переменная необходимая для выполнения логики
- void OnTriggerEnter (Collider other) {
- if (other.CompareTag ("Player")) {
- health = other.GetComponent(); // назночение ссылки hp скрипта игрока которого //коснулся тригер
- if (Time.time - t > AttacTime){ // алгоритм задержки между отниманием жизней
- health -= uron; // сам процесс нанесения урона
- t = Time.time; // завершение задержки
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement