Hrm. . . . I'm not sure. I use Unity / C#, and I've never used Godot before. But, here is how I would set it up for Unity:
- Depending on the game, I'd have a Rigidbody component either on the trigger GameObj or the player GameObj. Let's say it is on the player.
- Create a GameObj that has a Collider on it. *Make sure it is set to trigger!* That's important.
- Have a script with code (sorta like this) on the trigger GameObj:
[SerializeField] private float timer = 10f; [SerializeField] private float timeForAnimation = 3f; // State private bool startTimer; private void Update() { if (startTimer) { timer -= Time.deltaTime; if (timer <= 0f) { GetComponent<Animator>().SetTrigger("Scare"); Destroy(gameObject, timeForAnimation); // This could be extracted as a function to use as an anim event } } } private void OnTriggerEnter(Collider other) { if (other.CompareTag("Player") && !startTimer) { startTimer = true; } }