Checkpoint Mystery

Get help using Construct 2

Post » Sun Dec 18, 2016 12:43 am

In an attempt to save me the hassle of having several different stage checkpoint objects, I decided to have a system that relies on a global variable and a variable that changes depending on the checkpoint area triggered.

For example, if one were to enter a room with a checkpoint with the variable number 15, it would set the "stagearea" global value to that number. This part seems to work fine. However, when restarting a stage after dying, the game, for whatever reason, decides to either pick the starting point of the level or the very LAST checkpoint in the stage.

Image

(The "scrollding" variable isn't important in this)

Is there something wrong with the way I set up these events, or is this just simply not possible to do?
B
26
S
12
G
6
Posts: 29
Reputation: 5,207

Post » Sun Dec 18, 2016 3:13 pm

Nothing is impossible. ;)

What I can tell from your screenshot looks fine to me.
The problem probably lies in the way you "restart" the stage.
Are you restarting the layout?
Or are you scrolling to a specific point in the layout?
Because when restarting, the stagearea variable should be set to the stage's checkpoint number, correct?

If your current game isn't too big, a .capx would be very helpful too.

Also, adding a "Trigger once while true" to the last condition in your screenshot would be good too.
(It probably doesn't solve the problem, but it's a nice habit to add it to conditions that don't have to trigger every tick)
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Sun Dec 18, 2016 4:27 pm

randomly wrote:Nothing is impossible. ;)

What I can tell from your screenshot looks fine to me.
The problem probably lies in the way you "restart" the stage.
Are you restarting the layout?
Or are you scrolling to a specific point in the layout?
Because when restarting, the stagearea variable should be set to the stage's checkpoint number, correct?

If your current game isn't too big, a .capx would be very helpful too.

Also, adding a "Trigger once while true" to the last condition in your screenshot would be good too.
(It probably doesn't solve the problem, but it's a nice habit to add it to conditions that don't have to trigger every tick)


Restarting the stage involves resetting the layout, yes. If I add a check to make sure it doesn't get change the "stagearea" variable until the level intro sequence begins, the global variable remains the same throughout until the level actually begins.

If I were to send you this, I'd probably have to cut out a lot of stuff, so I'll just send over a video to show what's wrong. This is with the "for each" event cut out, so it happens a bit differently than I described in the video.
B
26
S
12
G
6
Posts: 29
Reputation: 5,207

Post » Sun Dec 18, 2016 6:56 pm

Okay, without the .capx, this will be a bit more difficult. But I understand that your project is quite big already and cutting it properly will take long.

Anyways, as I said, debugging from the distance is quite hard.
So let's start some tests.

  • Did you try not restarting the layout on death, but instead scrolling to the start point?
  • Do you have any other events that set "stagearea"?
  • You probably already looked at "stagearea" in the debug view right? If you didn't yet, go ahead and see how and whether it changes when entering rooms
  • Try adding "Trigger once while true" to the last condition in your screenshot. Just to make sure, this isn't what causes the problem

That's about everything I can think of now without looking at the .capx.
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Sun Dec 18, 2016 9:23 pm

Through some sort of magic and fiddling around, I've somehow managed to fix it. Thanks for the help.
B
26
S
12
G
6
Posts: 29
Reputation: 5,207


Return to How do I....?

Who is online

Users browsing this forum: Sparkz and 2 guests