Blender game engine random scenes

Hi, I’m making a quiz game that whenever you click the correct answer of your choice it will go to next scene but a random scene… how can I do that? :frowning: Thank you!!!

Import random
create a list of Qscene
if answer ==corrrect:
Setscene to Scelist[randq]

This is not a code. This is just the logic to your question.

sorry double post.

split it into two parts:

A) make a random choice
B) switch to the selected scene

There are many options to do this.
Here is a Logic brick solution:

initial have a property"sceneIdx" as int set to zero

when you want to change scene:
activate a RandomActuator that sets the property “sceneIdx” to an int value in range frame 1 … number of scenes set up

when “sceneIdx” equals 1 -> activate Scene A
when “sceneIdx” equals 2 -> activate Scene B

when “sceneIdx” changed -> set “sceneIdx” to 0

As this is very static it is a lot of work when you have a lot of scenes. With just a few scenes this is no big deal.

You can even combine Python and logic bricks:
-> a Python controller picks the scene name and applies it to a scene actuator

or pure Python
-> a Python controller picks the scene and switches to it a the same time

(I like to see the logic brick that performs a scene change. This is much easier to see than digging through Python code without knowing when this gets triggered. This is my own preference)

so what is “Import random
randq=random.randint()” & “Scelist=[qscene1,qscene2,etc]
if answer ==corrrect:
Setscene to Scelist[randq]”

I know the logic but i dont know the code… thanks

Thank you Monster. I’ll just message you if there is something I wanna ask again… if it is okay… thnks again :slight_smile:

“import random” means Python imports the module “random” to the namespace of your code.

You can find a description of this module in the official Python documentation.

what scene and what object should I declare the property “sceneldx”?
And should I just keep the settings for the Random Actuator and just name its property?

I would like a random scene, not a random choice or maybe I just dont get it and you’re preferring to me was correct.
Is this the easiest way? I’m sorry If I dont get it the way you expect me to understand but I can follow though.