Preloader Scene

Please tell me:

  1. How best to move from one scene to another. For example, the first scene of the entrance to his account, the second scene of the search server created games, third and fourth - a map of the world and the game menu. In the third stage on hidden layers are all of the objects and characters. Sometimes when downloading third stage game crashed.
  2. How to make download animation of scene.

Hi realivan,

You probably didn’t intend to tag this thread as SOLVED yet, but the other thread instead. Better remove the tag of this thread, so others may know you need some help.

There are several ways to move from one scene to another.

There’s KX_Scene.replace, or bge.logic.addScene() in combination with KX_Scene.end(). Click on the links to read more in the Blender API. It’s recommended to study the API so you know what methods to use for what purpose.

You could also use the logic brick Scene Actuator. Set Scene for replacing the current scene with another scene. Or Add Overlay Scene and Remove Scene to do the same.

I suppose you’re talking about loading animations (actions) of a Scene of another Blend file. Because actions of the Blend file you’re running, can always be loaded, no matter which Scene is active.

You could import data such as actions from other Blend files with bge.logic.LibLoad(). As you can read in the API with the type argument set to “Action” you can load specific actions. By setting the argument to “Scene” you will load all active actions, or all actions if the load_actions argument is set to True.

If you need examples of code, you could search the forums. I’m sure you’ll find plenty. If by any chance it would still be too hard for you to understand, then I’ll make you one myself. So let me know after you did some research. Most of the time this is the best learning route on how to develop games (or demos) in Blender: basic Python knowledge, understanding the API and an healthy portion of patience for trial and error.

Good luck,

Raco

Sorry for my English, I translate through Google. So my questions are not properly understood.
I know about all the ways of transition from one scene to another you described. The question was different. Are there any ways download the scenes so that the game does not crash. For example, I ran the third scene with the first in the background to download all the textures and materials of the third stage. In the transition to the second stage third stage is removed.So when it came time to load the third stage, it loads instantly. If I did not, then the loading of the third stage and the game occasionally crash, in the command prompt link appears to a text file with an error. How to make that even when loading large scenes game not crash. I hope my question is understandable.
On the second question. If you are loading a large stage, the game as it freezes. I want to make an animation when loading a scene that was not the impression that the game freezes. So in any game when loading scenes are any animation. Animation you run any way I know, too, freezes. I hope my second question is to understandable.

Thanks for explaining thoroughly. I hope my English will be understandable to you too.

For your first question. I don’t completely understand yet. With downloading do you mean loading a scene, or LibLoading a scene? Depending on what Blender version you are using, the crash may be caused by freeing the LibLoaded scene. In case you’re just talking about loading a scene, it’s important to keep in mind that Blender occasionally crashes when ending the current scene and adding another at the same time, while no other scenes are running. Or at least, in the past I had this issue myself, and so I used KX_Scene.replace() (or Scene Actuator -> Set Scene) instead. If the scene is too large, causing the game to freeze, you could load the active scene in chunks.

To do this your initial active scene has to be light, and gradually you’ll add objects to the scene until the scene is “built” completely. And so you’ll keep the desired frame rate of 60 fps. You could perfect this technique with asynchronous LibLoading so even inactive objects could be loaded in a separate (processing) thread. Maybe it’s even possible to LibLoad the complete scene (so also objects on active layers) asynchronously, but I never tried that. If so than this would be the all in one solution to your problem.

In any case this process will take time. Let’s say during that time you would like to entertain the player with a funny dancing character. So you’ll add another overlay scene for that, and remove it when everything’s loaded.

If you have more questions, do ask.

Looks to me as if the word ‘stage’ is actually ‘scene’ and ‘downloading’ is just ‘loading.’

So your first scene is a menu, where the user can sign in to his account, the second is the actual game, the third is a map of some type (possibly in overlay?), and the fourth is just storing animations for objects in other scenes.

And sometimes loading the third layer (adding as overlay?), makes the game crash.
I haven’t touched BGE for a while, but you may want to check things like: applied modifiers, no curves, texture paths are valid etc.

Second question is that you want a loading bar? Be warned, this is a complex topic. When I worked with BGE I spent the longest portion of my time trying to get loading bars to work, and I did do it. It requires Libload (which isn’t that stable), as well as breaking your game up into little chunks/separate blend files so that you can load things separately and estimate how much you’ve loaded.
My advice is simply to use a single Libload, and then just have a spinning wheel to indicate progress. I think there is a demo of this in the link in my signature: Sdfgeoff’s Workroom. Look under python for a directory called ‘libload.’

This idea, too, was, but I just want loading animation without freezes…

loading.blend (1.66 MB)

Here’s an async-loading version. Unfortunately, it crashes at the moment, but I need to make the file available for future reference / bugfixing.

libload.zip (2.25 MB)