here is the condition: when the player encounters trigger 2, show the effect and start the timer “11”
when the timer " 11 " is more than 1.5 seconds, remove the NPC enemy.
everything seems to be correct but when I run the preview NPCenemy is deleted immediately although I did not touch the trigger 2. here is a screenshot
Whenever you check if some time has passed on a timer, you create that timer. That means you check if 1.5 seconds has passed and then you create that timer, and after 1.5 seconds has passed, npc_enemy gets deleted.
Maybe to fix this problem, you can add this condition
as a sub-event of this condition:
in this case, NPCenemy is not deleted at all while I’m writing this, 5 seconds have already passed and they are still here
Do you reset timer “11” anywhere else? If not, do so in a “beginning of scene” event (if NPCEnemy is already in the scene) or when you create the NPCEnemy in an event, and pause the timer straight after in the same event (not the one in the code snippet above).
And you should add a trigger once to the first two events. Otherwise, for the second one, the timer is reset the whole time player is touching trigger2.
That won’t work. The subevent only gets called while the parent event is true. And the parent event resets the timer every time it’s true. So the sub event conditions will never be met.
Then maybe we can add a variable that checks if we have collided with trigger2 or not.
Something like this:
Player is in collision with Trigger2 then
Show TP
Change the scene variable checker to True
Reset the timer “11” of npc_enemy
If timer “11” of npc_enemy is greater than 1.5 seconds
Variable checker is True
Deleter npc_enemy