How do I make upgrades only trigger once, ever?

0 favourites
  • 5 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • In my game, the player will be able to purchase upgrades to objects on specific layouts that persist throughout the game. In this case, an item in the player's house increases the filling speed of their EXP bar. The codebox is a global object that keeps track of variables that are important such as what level the upgrade-able objects are at, and what bonuses to distribute. The upgrade itself works just fine, the problem is that it triggers lines 105 and 107 again every time the player changes to a different layout. So the +5 to mainbar_speed becomes +10 on changing layout, then +15, etc.

    What am I doing wrong here? I assumed trigger once meant only once, but it seems to mean once on the current layout.

  • The "trigger once" condition prevents an event from activating multiple times once its other conditions are met.

    For instance: If you have an event with the conditions "ObjectA is overlapping ObjectB" and "Trigger Once", it would trigger once when starts ObjectA overlapping with ObjectB, and then wait for them to stop overlapping to check again.

    I'm afraid there's no event to have something happen once and then never again in the game, but it should be simple to achieve by various other means.

    In your case, you could simply move the "Add 1 to mainbar_speed" to the events that set the object's level and charge the player money. This way, it'll add to the global variable at the moment you upgrade, and only then.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It does mean trigger once on the current layout. If you want it to trigger once ever you can block it out by using another variable as a condition and then set it to something else below the action. So on 104 if debugobject=1 and anothervariable=0 then do the action. On the action add 1 to speed and set anothervariable to 1. That way 104 can never be triggered again because global anothervariable will never be 0.

  • Try using global variables as indicators and local storage to save the progress.

  • Thank you all for the suggestions! They were all very informative and helpful.

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