Spawning Issues

0 favourites
  • 6 posts
  • Hello everyone!

         I am having an issue with spawning objects based on a particular variable. the short story is I am making a top-down dogfighting game with WWII aircraft.   It is for 2 players on the same keyboard. When one plane is destroyed, there is a good chance a pilot will jump out and "hit the silk". If this happens, I want to be able to spawn another aircraft related to the player that bailed. However, the issue that I am running into is that the instance I set up does not seem to be triggering the spawn.

         I have it set upon death to set a random number up to 6(the deciding factor in pilot survival). if that number is greater than or equal to 2, the plane spawns a pilot bail animation. Once that animation fades, It spawns an aircraft. If I try to narrow it down to include an instance variable of whether the pilot survived and it is player 1 or 2 (Player or Enemy respectively), it doesn't work. If I remove the condition of Enemy PilotSurvived=1 it will work, but if I do that, and I set up the player to have a similar action, the engine spawns BOTH planes on top of one another.

         I have included the instance of me attempting to specify a term so I can spawn the related plane. I do not want the death of the "enemy" to spawn a player aircraft. this can be found on the event sheet in the 20th spot. Here is the dropbox link so anyone who is willing to assist in straightening out this issue can see it:

    If I need to clarify what I am trying to do, please let me know. I am unsure if I was able to get across what is in my head. Thanks for any assistance!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hey En4cer,

    The problem is that you are storing an important variable into the object itself (as opposed to using local or global variable).

    By the time the parachute fades, the object has already been destroyed. So you don't give it a chance to trigger.

    Change your 'Pilot Survived' to a local or global variable and it will work fine.

  • Thank you so much! That worked perfectly! Now I can have the planes spawn the respective player's plane.

    <img src="smileys/smiley10.gif" border="0" align="middle" /> <img src="smileys/smiley10.gif" border="0" align="middle" />

  • sorry for the double post, but I tried to edit, and got some weird security error.   <img src="smileys/smiley9.gif" border="0" align="middle" />

         Now I have run into another problem. The user manual says we can use image point names as a reference, but does not give any examples. I am looking at trimming down my event sheet by referencing image point names rather than a new line for each image point.

         For instance, I have each plane that has more than one gun and would love to name each image point the same, and use one line of spawn bullet at image point gun, but any syntax I can think of does not work.

         I have tried self.ImagePoint.Egun, Enemy.ImagePoint(EGun) and Enemy.ImagePointX(EGun). I will be using the naming convention of EGun for enemy gun barrels, and PGun for player Gun barrels. This will also be useful when I add more than one sprite to give the option of selecting what plane to use, that way I do not have to set a firing event for each sprite.

    Does anyone have success in calling an image point by name? and if so, can you kindly provide the syntax used?

  • Ahh close, you use quotation marks "".

    So it looks like this in a spawning event:      

    Player Spawn bullet on Layer 1 (Image point "gun barrel1")

    If you wanted to use image points elsewhere, like setting the bullet towards a point of the ship or something you would use it like this:

    Bullet, set angle toward position :

    Player.ImagePointX("gun barrel1")

    Player.ImagePointY("gun barrel1")

  • Thanks so much for the help! It is working perfectly now. I am so thankful for such a welcoming and helpful community! <img src="smileys/smiley1.gif" border="0" align="middle" />

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)