Checkpoint Bug Need Help

0 favourites
  • 4 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Hi folks!

    For a checkpointing system, our project uses behaviorless "checkpoint" sprites. When the player overlaps these checkpoints, the global variables cpX and cpY are set to the checkpoints coordinates. When the player dies, we restart the layout, and so long as cpX and cpY arent both 0, we set the player's position to cpX and cpY.

    Now, there's a teensy bit of lag when it restarts, and if you hit the "up" key (no other key triggers it, but you can hit other keys along with "up") during this lag, the player starts at the default starting location instead of the cpX and cpY. However, if the player then dies before hitting the 1st checkpoint, they start at the correct one on the reload (otherwise they start at that new checkpoint) provided they didnt hit "up" on the load again.

    It looks the variable is being stored A'ok, so I'm wondering if the problem is in the behind the scenes stuff that happens in limbo.

    Is there any reason that Construct 2 or the browser would cause this? If not, I'll keep looking for bugs, though for the life of me I cant find one that would cause this. Testing on Chrome

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • My guess is its an unintended operation in your coding.. aka bug.

    Have you tried moving the events that grabs the coordinates from the variables as close to the beginning of your restart routine as possible so as to minimize any interference,

    You could also try putting 2 text objects on the screen and having them display cpX and cpY every tick.. this way you can debug what the data is when its acting funny and maybe see where its happening.

    Lastly, if all else fails, don't use coordinates. Use the actual checkpoints to spawn the player via a variable for each toggled to On or Off (ie. current one is On, rest Off) and for example if checkPoint3=1 then CheckPoint3-SpawnInstance_Player or whatever... it would mean more coding but if you just can't solve your original problem it might work-around.

  • Thanks for the reply Chris!

    The checkpoint thing is already one of the very first things that executes. I tried debugging with the text objects, unfortunately with no insight from them (they kept the right coordinates even when I trigger the bug). Your workaround sounds like it might do the trick and I'll definitely give it a go if I can't find what's really going on.

    The reason I'm thinking it might not be in my code is because the bug is triggered in during the loading period, when my code isn't actually active. But I am still looking because if it is my code then I can actually fix it and no more bug! If not then I'll have use an alternate set up...ugh

  • Try moving the checkpoint check toward end of load events or make a second "verifying" event that simply repeats coordinates input just prior to end.

    I would be happy to look at your capx if you like, maybe another set of eyes might spot something weird goings on. If you don't want to link to it here you can always PM me a dropbox link if you like.

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