Changing scenes are bugged

Project link:

What is happening in the project, and what do you want to happen instead?
If you lose in the game, and try to go back to the levels menu, the levels menu no longer work.

4 Likes

Putting “when game starts create a clone” is not a very good idea since every time it switches to that scene it will create a clone.
I’m not sure, but it could have to do with the ‘repeat forever”s in every ‘when clone index” block.
Or it could’ve been the fact that it’s checking for a clone index when you tap it, but it’s made a couple of clones already, blocking the original. I don’t think that’s happening tho since iirc you can tap through blank text objects (lol hopefully this is helpful)
Or it could be a hopscotch bug idk /lh

Edit: lol I couldn’t fix it, either I’m bad at coding or it’s a hopscotch bug. I mean, I did manage to fix it once but it started flashing so it probably wasn’t a very good fix

5 Likes

Whenever you do When Game Starts { repeat 10 { clone object } }, every time you enter that scene, it’ll clone exponentially (because every clone will clone 10 times each ; 1 to 11 to 110 to 1100 to 4096). This will cause your game to lag and crash for no apparent reason.

The only way to fix this is to do

When (self) total clones < 10 { # will keep cloning until it reaches 10 total clones
     Create a clone of this object
}

This will prevent excessive cloning, which is why the menus (and possibly every other scene) kept breaking.

You can also change when game starts to when (self) total clones = 1 to do the same thing, just slower.

5 Likes

So that’s the design flaw FOR ALMOST ALL MY GAMES, thank you!
But there;s 1 tiny issue, idk how to fix the cube falling when you go back and the score turning all purple

3 Likes

Not sure how to fix the cube clipping through the ground, but as for the score, you just need to add a check once if self total clones = 1. I also recommend moving the when game starts rule above where you do the cloning.

So the when game starts rule actually runs for all active objects (like the clones), not just the original object. Adding a check once if self total clones = 1 will force it to only run if there’s just the original object (which, if done correctly, will make it run only once for the entire project, until restart)

Do this in all objects where you have cloning involved.

Example:

When Game Starts {
     Check once if (self) total clones = 1 {
          Do code here # will only run once and only for the original object
     }
}

Edit: this may sound crazy, but defining a variable outside a rule only sets it once. To set it every time you enter the level, use a when game starts rule. You never actually reset the YVelocity Local Variable.

3 Likes

Still didn’t work, check new version’s code

3 Likes

What color is the score supposed to be? In the code, it’s clearly set to purple, and it’s purple to begin with.

3 Likes

Before going back


After goimg back

3 Likes

All you literally did was make the cloning process slower.

2 Likes

Its supposed to be white and look 3d with purple

2 Likes

Well guess what: that when game starts rule made all clones go to the same exact location when going back. Like I said, that rule runs for ALL objects, including objects that were already cloned.

So literally like this:

2 Likes

Ok, I fixed the score.
But idk how to fix the clipping cube

2 Likes

I did this (set yvelocity to 0), and it seemed to work, but the cube was still spinning because of the repeat forever rule, which will never make it stop spinning. The best way around that would be to use a variable to control when it should spin or not.

Also, I sometimes get into a situation where I instantly touch a spike on return.

Still confused? Here’s what the location of set variables mean:

It’s probably best to keep the solution unmarked until all issues are resolved.

2 Likes

I fixed the spin and clipping cube, but now the cube LITERALLY ascends into the heavens (:joy:) when it dies when you go back

2 Likes

At least it’s not descending into the underworld. /s

There’s always gonna be a problem when you fix a different problem…

2 Likes

So how will i fix it?
Also the cube stops descending or ascending if it hits spikes even if you don’t reset the game by menu

2 Likes

Did it die when it was upside down? If so, then a simple switch variable reset will fix that.

Before you say “I already do that at the top”, that won’t actually work. See the image above to see why.

2 Likes

Yeah, i fixed the ascending cube but the cube wouldn’t descend anymore (game is more like bug mayhem)

2 Likes

You also do have a lot of these:

Are they even necessary? One, I can understand, but three?! I know they’re slightly different, but that’s besides the point. These do actually add up.

2 Likes

Wait, I just fixed it
I realised the local Y Velocity variable was in the game start so i defined it outside it and it now works
2 issues though

  1. No sound when dying when game restarts in menu
  2. It just, uhh, dies, weirdly when the game restarts in menu and doesent restart
2 Likes