Having some bizarre behavior with sub-events

  • I'm not sure why, but I'm having a problem with sub events that I can't quite wrap my head around. I'm trying to make a basic sort of myst style point and click control scheme, with animated transitions for moving and turning, and to do that I'm using a global variable to store the player's current camera position, and when a zone on the screen is clicked, it will play a specific animation and then update the player's position based on the value in that global variable.

    My problem is occuring in this little bit here (I'm just using the "player" object to visualize the player's direction on an overhead map, it doesn't really matter)

    When the player clicks on the left or right zones, he's supposed to turn to a different position. In the "BCam" position, everything works fine; it plays the transition from BCam to FCam perfectly, but when the player is in the FCam position, the game simply runs the actions as if he were in the BCam position instead, and looking in the debugger, I see that the position simply stays at FCam. At first, I thought it might be because I was using text instead of variables to store the player's position, but I tried it with a number scheme for each position, and got the same result. For some reason, the order of the sub-events makes a difference (if I flip the first 2 events, I get the opposite effect, where the FCam position works fine and the BCam position runs the FCam events), but as far as I can tell this shouldn't be happening.

  • Use an 'Else' between your System: PlayerPos = "XYZ" events

  • Cool, that fixed it right up. Obviously I was just confused about how sub-events work.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Cool, that fixed it right up. Obviously I was just confused about how sub-events work.

    Not really related to subevents, just a very common beginner's error. Each event (or subevent) runs from top to bottom, so this kind of thing (in pseudocode)

    (assuming A = 1)

    if A = 1, set A = 2

    if A = 2, set A = 3

    if A = 3, set A = 1

    probably doesn't look right to you (A will always be 1) but it's what you're doing in your code.

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