How to put a delay in collision2D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By stoicmess

I have a sprite, collisionshape2D and an animation player. The purpose is: The sprite enters an Area2D and collision triggers inside the Area2D once.

I changed the shape of the collisionshape2D during my animation so that it follows the sprite animation. However, during the collision, the collision registers each time the sprite animation changes. This makes an unnecessary repetition of collisions. How do I put a delay in my Collisionshape2D after each hit so that it only registers once in certain amount of time?

I’ve tried using the timer node, but it does not work.

Thanks in advance.

:bust_in_silhouette: Reply From: Magso

collision triggers inside the Area2D once

You could disable the Area2D’s collisionshape in the body_entered signal.
The physics engine will keep registering entering collisions as the collisionshape itself is altered, I don’t know the full nitty-gritty of why this is but it’s unavoidable and it doesn’t only happen in Godot either.