Having some bizarre behavior with sub-events

Discussion and feedback on Construct 2

Post » Sun Jan 04, 2015 7:59 am

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)

Image

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.
B
4
S
1
G
3
Posts: 31
Reputation: 1,114

Post » Sun Jan 04, 2015 8:06 am

Use an 'Else' between your System: PlayerPos = "XYZ" events
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sun Jan 04, 2015 7:14 pm

Cool, that fixed it right up. Obviously I was just confused about how sub-events work.
B
4
S
1
G
3
Posts: 31
Reputation: 1,114

Post » Sun Jan 04, 2015 10:01 pm

Pythagoras wrote: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.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596


Return to Construct 2 General

Who is online

Users browsing this forum: gameba and 1 guest