1
$\begingroup$

So, I have a blender game file with multiple levels, each in a separate scene. I want to have on "Next Level" scene with a button to go to the next level. Can I make the button always go to the the next level or do I have to make separate "Next Level" scenes?

$\endgroup$
3
$\begingroup$

Typically keys and buttons have a purpose dependent on the context.

According to your question the context of "next level" is a current level.

Therefore you need to determine the current level to find out what operation the button is supposed to perform.

It does not need to be complicated. But there are quite a lot of different solutions.

Level Scene switching itself

Assumption: the level scene is still running (e.g. as background scene)

  • on activating your button send a message "switch to next scene" enter image description here

  • on receiving "switch to next scene" let an object of the current level scene switch to the next scene.

Requirements:

  • you start with a level scene, as there is nothing that loads it otherwise

  • each level scene implements a switching object

Menu scene switching level

  • on activating your button send a message "switch to next scene" (see above)

  • an object knows what the current level is (not necessarily the scene) enter image description here

  • on receiving "switch to next scene" this object changes to next level enter image description here

  • on changing the level switch to the according scene enter image description here

I suggest to keep the level in a property either as string or as number. A number is simple as it allows to be incremented.

The important idea is that you first set the level. In reaction of the level change you add, remove or switch scenes (or do other things).

I hope you see this method makes it easy to even add a "previous level" operation.

Remarks:

When you have a lot of scenes you will need to setup a lot of scene setting too. In that case it might be easier to use python to "calculate" the name of the scene that belongs to a level. But this is another topic.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.