using System.Collections; using System.Collections.Generic; using UnityEngine; public class Vanisher : MonoBehaviour { [SerializeField] private float timeToVanish; [SerializeField] private float timeToAppear; private GrappleHook grapple; private bool isVanishing = false; //TODO represent obj is breaking public void Begin(GrappleHook grapple){ if(isVanishing)return; this.grapple = grapple; Invoke("Vanish", timeToVanish); isVanishing = true; } private void Vanish(){ grapple.Unhook(); gameObject.SetActive(false); Invoke("Appear", timeToAppear); isVanishing = false; } private void Appear(){ gameObject.SetActive(true); } private void OnCollisionEnter(Collision other) { if(other.gameObject.tag.Equals("Player")){ Begin(other.gameObject.GetComponent()); } } }