Hello
I'm working on a space invader game and I've ran into a couple of problems while trying to spawn ships and fill in values for their variables depending on the model. Here's a bit from my script.
I have to spawn multiple models of ships, depending on what the player chooses but for now it's just one. I've set some commands to assign values to some of the ship's variables but only a few essential ones. The rest I want to set using the Ships | On Created event to save script but I've only added a few for now. Note that FighterShip is part of the Ships group.
The problem is that the commands of the On Created event seem to trigger before the commands on the first event. Either that or the commands on the first event only trigger a frame after FighterShip is spawned. To test this I put in the NumTest command and event. In debugging I saw that even though NumTest had been set to 1 the ship's text variable "HeavyGun" was not set to "No". I take this to mean that NumTest was not 1 at the time when On Created was triggered but only later.
Am I missing something here? Does anyone know exactly the order by which these events run? Does spawning a sprite require 1 frame before it can be accessed by Events and Commands?
My other problem is making a dynamic script for spawning multiple types of objects. I wish I had a command where I could type in the name of the object to be spawned or put in a variable but there's clearly no such thing. Instead I have to do a separate event for each type of ship. If the variable that determines the ship model is FighterShip, spawn FighterShip, if the variable is set to TraderShip, spawn a TraderShip and so on. I wish I could just have a command that says Spawn Object "ModelVariable" to replace all the ifs because there will be a lot of models.
I tried the trick of spawning a Ships family object instead but it only chooses a random object from the family to spawn and I can't control it. I tried to have an event select one FighterShip and then spawn a Ships object but it still spawned random models, not just the FighterShip. Does anyone have a better solution than making a long list of events, one for each model?
Any help would be greatly appreciated as I still have a lot to learn.