using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
public class InvertManager : MonoBehaviour
{
public GameObject Tuerquita;
private Rigidbody2D _myrb;
private Transform _myTransform;
public ManoloMov _myManoloMov;
public float speedValue;
void Start()
{
_myTransform = transform;
_myrb = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
_myrb.velocity = new Vector2(0, -speedValue);
_myTransform = transform;
}
private void OnTriggerEnter2D(Collider2D collision)
{
ManoloMov manolomov = collision.GetComponent<ManoloMov>();
if (manolomov != null)
{
Tuerquita.SetActive(false);
_myManoloMov.speedValue = -15f;
StartCoroutine(VuelveNormal());
}
}
IEnumerator VuelveNormal()
{
Debug.Log("Esperando 5 segundos");
yield return new WaitForSeconds(5f);
Debug.Log("Restaurando velocidad normal");
_myManoloMov.speedValue = -_myManoloMov.speedValue;
}
}