2
$\begingroup$

I have a game with multiple scenes. I'd like it to always redirect the user to the scene "Opening Scene" on startup, no matter what scene is currently open.

I could use an always sensor hooked up to a scene actuator, but this means that I can't switch back to any of the scenes after startup, because they will automatically redirect back to "Opening Scene".

Is there any way to do this so that the scene gets redirected at startup, but after that allows redirecting to other scenes?

$\endgroup$
  • 5
    $\begingroup$ Welcome to Blender.SE! We're glad to have you! You've received a couple of down votes because your question is poorly asked. Some newcomers get frustrated because they expect this site to work like a forum... but it doesn't. Please take a minute to review the tour and get a feel for how we do things in the StackExchange network (and Blender.SE specifically). Clear, concise, professionally asked questions tend to get better answers. When you put in the effort to use proper sentences, punctuation and capitalization, we feel better about putting in the effort to answer your question ;-) $\endgroup$ – Matt Aug 23 '16 at 14:34
  • 3
    $\begingroup$ If you've been on B.SE for a while, then act like it. I'm offering some advice because what you're doing is "sub-optimal." If you want to do your own thing, lemme know how all that works out for you... $\endgroup$ – Matt Aug 23 '16 at 20:24
  • 4
    $\begingroup$ Strangely, that response doesn't make me more eager to help, either... $\endgroup$ – Matt Aug 23 '16 at 20:34
  • 2
    $\begingroup$ I think that what @Matt was trying to say, was that when you use terms such as,"This is difficult because I can like on every scene," it makes your question look "unprofessional". Also, you have only two sentences in your question. "(three if you count, "how can I fix this") One of your sentences is a run-on. Essentially, your question just looks poorly written. However, that is how it is now. The edit history shows that when you posted the question, it looked like it was sent to the Stack Exchange network as a text-message. $\endgroup$ – X-27 the fluffy unicorn Aug 24 '16 at 3:11
  • 3
    $\begingroup$ Also, the title you used was, "Complicated scene stuff" When most users see a vague title like that, they read it as, "I'm a noob, I can't figure this out, and I'm not going to put much effort into figuring out what I'm trying to do, or explain it in a question so I'll just say - HHEEELLLPP!!!!" $\endgroup$ – X-27 the fluffy unicorn Aug 24 '16 at 3:13
1
$\begingroup$

In general I suggest to start the game with the current scene. A dependency to a specific scene will make development much harder as you always need to go through this opening scene. Switching right at the beginning increases load time.

Logic handler

For easier handling I suggest to create a group with one object that performs the switch. This way you can easily create one instance at each single scene without creating it again and again.

Another option is to link an object between the scenes.

Concept

At game start you want to switch to the opening scene when: - the opening scene was not visited before

You need a sort of store/restore method.

Storage

As you switch scenes, I suggest to store such information in a Python module. It will survive any scene switch (in difference to object properties). The storage will survive as long as the game session runs.

Code

The code is pretty simple. Please keep in mind it should run in module mode (script mode will not work this way).

caller.py

alreadyCalled = False

def isFirstCall(controller):
    global alreadyCalled

    if alreadyCalled:
        return 

    alreadyCalled = True

    for actuator in controller.actuators:
        controller.activate(actuator)

Setup

Always Sensor -> Python Controller Module: caller.isFirstCall -> Scene Actuator: to opening scene

Remarks

This will work with the first call "caller.py". Any subsequent execution of "isFirstCall" will not activate the actuators even when executed within the same frame.

$\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.