Newer
Older
CGTrack / Assets / Scripts / Bausatz / Target.cs
@Pascal Syma Pascal Syma on 25 Jul 2021 656 bytes Initial Commit
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Bausatz
{
        
    public class Target : MonoBehaviour
    {
        private Light _light;
        private bool _isHit;
        private void Awake()
        {
            _light = GetComponentInChildren<Light>();
        }

        public void Hit()
        {
            if (_isHit) return;

            _light.color = Color.green;
            _isHit = true;
            Invoke(nameof(ResetLight), 2f);
        }

        private void ResetLight()
        {
            _light.color = Color.white;
            _isHit = false;
        }
    }

}