Godot Version
4.3
Question
Hi everybody. I’ve always had a problem where, say I’m making a 2D Zelda-style game. I’m making the player character swing a sword using the animationplayer to move an Area2D in an arc. The enemy has an Area2D on it that tells it through a signal if an Area2D on physics layer ‘sword’ enters it. When the sword swing starts, I make the sword’s Area2D monitorable. When it ends, I make the Area2D not monitorable.
My problem is, what happens when the location of the sword’s Area2D happens to be inside the enemy already when the sword’s Area2D is made monitorable? There’s no area_entered signal tripped then.
So then I just warp the sword’s Area2D to (-9999999, -9999999) at the end of the swing and warp it back at the start.
But THEN, sometimes the player gets hit by the enemy mid-swing and the animation doesn’t finish, so the 999 warp doesn’t happen, so then I have to set a timer to coincide with the end of the swinging animation instead…
You see my point. Very inelegant. I’m sure I’m just not understanding best practices. If anyone can tear my thinking apart and tell me where it all went wrong it would be much appreciated. What would be an intelligent way to accomplish this?