Multi-Resolution Game Development With GameBuilder Studio Check it out!
NEW Version 0.9.7 has arrived! New Blazing Fast Particle Engine & More Game Actions. Check it out
How to create, access, and destroy spawned objects while the game is running?
  • Is there a way to edit, manipulate, or destroy a spawned entity that is not moving off the screen?  Do the spawned entities get their own ID's or are they just copy's of the original object?  What I am look for is a way to spawn an entity (a tower) that can be destroyed when it runs out of hit points, but also be able to upgrade the spawned entity as well.

    Thanks
  • 2 Comments sorted by
  • @Grimdin yes. You can only access a spawned entity if you give it a unique name in the spawn action. So if you are creating multiple objects of the same type then increment the name using an expression value with an index. (e.x. "NewTower" + towerCountIndex ) Increase the index after each object has been spawned. By doing this you can then access the object using the same dot syntax as any object created in-editor before hand (e.x. NewTower1.Properties.towerType ). The newly created object is an exact replica of the object it is based on so change any properties on the new object once created to make it unique.

    You can have a Destroy action on the entity that get triggered based on a certain condition and the spawned entity will be removed from the game.
  • OK great, thanks. That makes a lot of sense now that I see it. So much to learn. Thanks for the response Lavon

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion