Is there a "begin step" event in Construct 3?

  • In GameMaker, there's an event called the "begin step" event. Any code in that event will be triggered at the start of the frame, before the regular step event and other triggers. Is there something similar in Construct 3?

    The reason I ask this is because I'm using global variables to store player data like HP, since the data needs to be persistent across layouts and the Persist behaviour doesn't seem to work for this. Then every tick, I'm giving this data to the player in the form of instance variables.

    The problem here is that if I try to update my health bar based on the player's variables, it will update the health bar after HP has been changed globally, but before it has been added to the player. A "begin step" condition would solve this immediately.

    Here's my project file if you need a closer look: ufile.io/1ol4z

    The health bar code is held in eCharacters, the global variables are held in eGlobals, and the data copying is also done in eGlobals.

    Any help is appreciated.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm not sure why you're sending global variable data to an instance variable on the player, you should just use global variables for player stats. As for the healthbar it looks like there is a chance for a bug since you are passing variables through functions on overlap with the takedamage code. No time to investigate now though. 'Added to the player' shouldn't be a thing though so if avoiding that fixes the bug then there we go.

  • I'm adding variables to the player because of this event:

    The Player object is part of the Characters family.

    I agree that putting player data in two places is bad code. If I could change this event to get global variables if the Player is picked specifically, then that would be a better fix.

    I started this thread because I couldn't find a solution to that and tried a different approach, but if anyone knows how to pick the Player object in that event, I would love to know.

  • Fixed. All I did to fix this was add an "isPlayer" boolean flag to the Characters family that is false for all characters except the Player. Then I added another condition to check if the character is a player or not before using the appropriate action.

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