Best practice for removing all objects when changing state

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
User avatar
rrTea
Posts: 475
Joined: Sat Feb 15, 2014 9:54 am

Best practice for removing all objects when changing state

Post by rrTea »

Right now I have it set up that when the player gets hit, the State switches from "Arena" (removes all models OnLeave) to "Game Over" screen.

The problem is that the majority of enemies have a pretty simple

+OnRemove:
=Play some sound
=Spawn "Flash" model for explosion

setup, which is generally fine, but doesn't work well in this context because when all the enemies get removed at the same time explosions can be both heard and seen in the next State etc.

I can partially solve this by putting a OnStart:RemoveAllModels in the "Game Over" state too (or have a middle State with a just RemoveAllModels + proceed to "Game Over") which would remove the explosions, but this sounds like a bad workaround and still doesn't solve the problem of exploding sound carrying over.

To avoid this I can make it so that some enemies explode only when their Hitpoints reach 0, but I'm trying to avoid that because many simple enemies do not have nor need hitpoints at all (explode as soon as they get hit).

There must be a better way to go about this?
Last edited by rrTea on Mon Dec 01, 2014 9:45 am, edited 1 time in total.
User avatar
VilleK
Site Admin
Posts: 2277
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Hi,

I looked my own projects ZBlast and TripleE (both which are included in the ZGE distribution) and see that I use OnCollision instead of OnRemove to spawn explosions. Maybe you can use that too?
User avatar
rrTea
Posts: 475
Joined: Sat Feb 15, 2014 9:54 am

Post by rrTea »

Hi,

Yes I thought of that too, I'll definitely have to reorganize it a bit. Will post the results on weekend.
Post Reply