[NOT a Bug] Destroy Obj when tween finish doesn't works

Like the title says when you toggle the switch “Destroy when the tween finishes” doesn’t works.

It worked for me using the latest version of the windows app. Are you using a condition like trigger once to make sure the tween doesn’t keep getting restarted on each frame? It would make smaller and smaller steps each time eventually making it unable to reach its target value because the step per frame would be so small. (The step amount per frame is calculated by distance / time)

1 Like

It also works fine on the cloud version. Must be something with your events.

1 Like

@Keith_1357 That’s actually really strange, maybe is an issue with for each obj?

As @Keith_1357 mentioned, the problem seems to be when the enemy is dead, the event is triggering on every frame (tween, wait etc…), so this cases a lot of issues. Also you can’t use trigger once in a for each event.

Try adding this condition to the last event (along with enemy is dead condition):

  • animation of enemy != “Die”
2 Likes

Did it and it works, thanks :+1:

2 Likes

I’m glad it’s working. Adding a check for the animation is excellent.

Just a tip. If the damage is only being applied in one place then it could be more efficient to check if the enemy is dead inside the event that applies the damage. There’s no need to check if the enemy is dead unless damage has been applied and I find it easier to read.

Example (the dashes represent subevents)
Bullet in collision with enemy
—for each enemy
------apply damage
------enemy is dead (with the animation check)

2 Likes

To check it better actually these are my events for the enemies and i need to say that i lose a lot of FPS when these events are ON, any suggestions to fix the fps drop?

The pathfinder uses a lot of resources to calculate a path. It should be used sparingly especially if there are a lot of enemies and obstacles to avoid.

This post might help. It discusses using a timer in combination with a distance check. When the enemy is far away then you can probably update the path (meaning using move to action) less frequently. With a long path, most of the path will be the same. It’s only the last part that changes. It’s more efficient to update less frequently when far away.

When the enemy is close then you update the path more often. It doesn’t take long to update a short path compared to a longer path with obstacles. If you don’t update frequently enough , the enemy would target old positions and create a lag.

https://forum.gdevelop.io/t/pathfinding-not-recalculating-and-passing-through-obstacles/51567/8?u=keith_1357

1 Like