[solved]Trouble with event/trigger once

This forum is currently in read-only mode.
From the Asset Store
Change the size and position of everything without calculating anything!
  • I can't solve this:

    wish:

    When a self firing weapon(/turret) runs out of ammo, it reloads. After reloading it can fire again.

    Problem:

    With more than 1 weapon on screen, they start to synchronize (unwanted result) after 1 reload and reload and fire bullets at the same time.

    (1 weapon on the screen works fine)

    + Weapon: Value 'ammo' Equal to 0

       + System: Trigger once*

       -> System: Create object reloading on layer 1 at (Weapon.x, Weapon.y)

       + reloading: Animation "Default" finished

       -> reloading: Destroy

       -> Weapon: Set 'ammo' to 3

    * when I don't use "trigger once", it keeps creating sprites, because ammo stays "0" for several seconds. But this way, it creates only 1 sprite "reloading" for 1 weapon, while there are several weapons on the screen.

    (CC v0.99.84)

  • It's hard to tell exactly what the problem is without a cap. The Trigger once is easily replaced with a private variable. Call it "Reload Time".

    + Weapon: Value 'Reload Time' Equal to 0

       -> Weapon: Set 'Reload Time' to -1

       -> System: Create object reloading on layer 1 at (Weapon.x, Weapon.y)

       + reloading: Animation "Default" finished

       -> reloading: Destroy

       -> Weapon: Set 'ammo' to 3

       -> Weapon: Set 'Reload Time' to 3

    Every time you subtract from Ammo (When you shoot i guess) just subtract 1 from Reload Time as well.

  • Thanks for the reply.

    With your suggestion it doesn't execute/look at the subevent ("reloading: Animation "Default" finished).

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

    (Tried in CC 1.2 as well)

  • It is synchronizing because Weapon and reloading are not paired.

    The sub-event:

    + reloading: animation "default" finished

    is picking that one reloading object and all the Weapons with an ammo of 0.

    To fix you need to pick the Weapon that you want paired with reloading. You could use a variable with UID or since it appears that your weapons don't move you can pick the Weapon that is in the same location as reloading.

    + Weapon: Value 'ammo' Equal to 0

       + System: Trigger once

       -> System: Create object reloading on layer 1 at (Weapon.x, Weapon.y)

       + reloading: Animation "Default" finished

       + Weapon: X Equal to reloading.X

       + Weapon: Y Equal to reloading.Y

       -> reloading: Destroy

       -> Weapon: Set 'ammo' to 3

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • R0J0hound, that sounds so right, but it didn't work.

    update:

    Now I'm trying to figure out the first part first:

    assigning every weapon that runs out of ammo a reloading-sprite, because it seems that the "trigger once"-condition gives the unwanted result: only applying it to 1 weapon.

  • Just Upload the .cap and I think this will be solved very quickly by some random clever mod. <img src="smileys/smiley36.gif" border="0" align="middle" />

    Use this site if you don't wan't to register or do anything else, Really fast.

    yourfilelink.com

  • Thanks Nifl, for the offer, thinking and earlier post.

    I'm glad I just got it working! (thanks to R0J0hound's suggestion of UID's)

    event 1

    + Weapon: Value 'ammo' Equal to 0

    + Weapon: Value 'Reloading' Equal to 0

    -> System: Create object reloading on layer 1 at (Weapon.x, Weapon.y)

    -> reloading: Set 'WeaponUID' to Weapon.UID

    -> Weapon: Set 'Reloading' to 1

    event 2

    + reloading: Animation "Default" finished

    + Weapon: Unique ID is reloading.value('WeaponUID')

    -> reloading: Destroy

    -> Weapon: Set 'ammo' to 3

    -> Weapon: Set 'Reloading' to 0

    This simple event took me 3 hours, I think. <img src="smileys/smiley18.gif" border="0" align="middle" />

    When R0J0hound mentioned pairing, I thought I could use the Container feature/property, but it didn't work or I didn't know how.

    If there's a more quicker/elegant way to achieve the above result, I am interested.

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