Animation #2 is a death animation. It should play 1 time after an enemy dies with teleporting an enemy to spawning coordinates , switching back to animation #0 and reviving an enemy. But it works totally chaotically :
- At first an enemy stops to move to my player with pathfinding sometimes.
- Most of the time an enemy is not teleported to a starting position but revived at the same place.
- During an animation#2 the sprite of the enemy is like moving while i set his speed to 0 before switching an animation. Sometimes it looks like i need to add TimeDelta somewhere as well
Can you post a pic of your scene. Are there obstacles for the pathfinder? Are the obstacles set to passable? I’m guessing here but if you try to move to an invalid spot the pathfinder doesn’t move at all. I don’t want to make any assumptions.
I would have to test the trigger onces because Im not super familiar with the health behavior. But I think the trigger onces are stopping repeated changes.
I would skip the trigger once and see what happens. If the enemy is revived in the same event then it won’t trigger again until it dies again. And if it’s not dead, you need to keep updating the Pathfinder location should the player move.
If an action can happen to multiple enemies during the same frame then you might also need to use a for each object after the conditions.
I would first try removing the trigger onces. One at a time.
Seems like Wait X seconds doesnt work correctly with trigger once. If i have a condition: If enemy is Dead - Trigger once - Change an animation, wait 1 sec, change a position, heal an enemy - so it doesnt go after changing an animation. When i remove Wait X sec so it goes after an animation. Moreover it seems like sometimes i can do too much dmg to an enemy so it goes like negative - this way healing for the max HP value of the enemy is not enough.
I don’t want to give bad advice. I’d like to test my theory first. I’ll post something after I check something on my PC.
I’ve fixed pathfinding issue but the question about changing an animation + wait X seconds + changing position after is still unsolved
Yeah, the first trigger once is a problem. Trigger once conditions won’t trigger again until it changes states. An enemy would have to go from dead back to alive first before being triggered again for any instance.
This is how I would do it.
I don’t like wait I prefer to wait for the animation to finish. That means you need to check the current animation so events don’t repeat for the same instance.
The pathfinder really needs a stop action. The 2nd best way is to have it move to its current position. otherwise, it still wants to continue to move even if its speed is zero and it can cause problems.
Edit: I think I added everything. If you have problems or a question, just ask.
Your explanation is very valuable. Especially about a pathfinding. I’ll do it like you said. Thank you!