Spawning Issues

Get help using Construct 2

Post » Mon Aug 05, 2013 4:46 am

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:

https://www.dropbox.com/s/pgerl5ezzc4x0fj/Desktop%20Dogfighters.capx

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!
B
3
Posts: 4
Reputation: 183

Post » Mon Aug 05, 2013 5:23 am

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.
ImageImage
B
99
S
20
G
6
Posts: 1,056
Reputation: 11,636

Post » Tue Aug 06, 2013 1:26 am

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

B
3
Posts: 4
Reputation: 183

Post » Tue Aug 06, 2013 1:50 am

sorry for the double post, but I tried to edit, and got some weird security error.   


     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?
B
3
Posts: 4
Reputation: 183

Post » Tue Aug 06, 2013 6:02 am

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")GenkiGenga2013-08-06 06:48:44
ImageImage
B
99
S
20
G
6
Posts: 1,056
Reputation: 11,636

Post » Thu Aug 08, 2013 12:25 am

Thanks so much for the help! It is working perfectly now. I am so thankful for such a welcoming and helpful community!
B
3
Posts: 4
Reputation: 183


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 1 guest