using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Teleporting : MonoBehaviour
{
public Transform teleportTarget;
public GameObject thePlayer;
public GameObject teleportUI;
void OnTriggerEnter2D(Collider2D other)
{
teleportUI.SetActive(true);
thePlayer.transform.position = teleportTarget.transform.position;
}
}
It basically turns on my panel which has fade animation and it works the first time. Problem is that after finishing this, my panel stays active. That means that animation won’t play again because my panel is already active.
Probably just add a timer of some kind that deactivates the teleportUI after a time expires.
You can do that by setting a constant float for the timeout, on setting teleportUI to active, you set a tracking float variable to 0, then every update/fixed update you increment that float variable by the deltatime/fixeddeltatime and compare against your constant. If greater or equal, deactivate the teleportUI again and stop incrementing (although deactivating the teleportUI I think will suspend update/fixedupdate so that should be sufficient I think).