HOW TO - Spawn object from diferent scenes

Hi dear members of the forum. I use Blender long time ago, but I’m totally new with the Game Engine.

In my game (similar to Bomberman in the pic), they’ll be 20 different stages, with 10 different maps each one. All maps from same stage uses the SAME objects (bombs, items, blocks, etc) and only difference are blocks arrangement basically.

I did all objects in a Scene called ‘Objects’. And did Stages in Scenes called Stage01, Stage02, etc… and put in each layer the different arrangement of how blocks will be organized.

My question is, how can I spawn an object from a scene (‘Objects’) to other scene (‘Stage 01’)? As u can see in the pic, in the actuator ‘edit object’ says I can add objects from other scenes, but when PRESS PLAY, nothing appears (until I put in the same scene).

  • I know I can do this by making ‘linked copies’ of all needed object from one scene to other, but for me makes no much sense copy same object so many times (20 stages x 10 maps = 200 times same object), is there and easier and cleaner way?

Thanks a lot to all for your valuable help.

Attachments



As far as I know the drop down box for object only displays all objects that are present in that scene. Maybe ‘Cube’ showed up because you made a instance of that object in the current scene?

Anyway, looking at your problem, I think you could do it two ways. You could ‘Make Links…-> Objects to Scene… (select Scene)’, which you already suggested. Or you could create your game in just one scene, but update it from one state to the next. For this you would probably need Python. A third way would be to use Python too (bge.logic.LibLoad()).

I hope someone would correct me if I there’s another way with logic bricks only.

You can only add objects that exist in the current scene. Basicly addObject creates a copy of an existing object.

You can dynamically load objects from a blend file into the current scene with LibLoad.

If you are thinking about an inventory or selection menu, keep in mind that such things usually contain representations only.

Anyway linked copies are a way to have one editable instance of an object while using it at different places. I usually prever to use linked groups. This way I have the content residing in separate blend files for exactly that purpose. Level blend can link these objects without caring the details. If i change the object in its blend the change will appear in each linking/using blend file (after reload). You can read about this in my signature. If you want to see an example have look at WALL-E ;).

Btw you can addObject instances as long as they exist in the scene :D.

Hi Raco and Monster, in the drop down box for object, they appear ALL objects from other scene: ‘Cube’ showed up is not in same scene (that’s why I think is weird that objects appear in drop down menu, but won’t display when PLAY unless copied in same scene).

  1. About creating the game in just one scene: If I put different stages in a ‘same scene’ but into ‘different layers’ (ex. stage 1 in layer 1, stage 2 in layer 2… and all objects in layer 10) *** HOW CAN I CHANGE LAYERS WHEN PLAY ??? *** (I only know how to change scene with actuator like the picture)

  2. Otherwise, this means I can only play a layer per scene when PLAY, and means if I will have 200 different levels (20 stage x 10 maps each), *** WILL NEED TO CREATE *** 200 different scenes, with same linked object copies in each one??? (bombs, items, blocks, etc.)

Thanks for the help and patience.


In terms of logic there are no layers. They act as helper structure to determine ehat object is active (residing in visible layers) and inactive ( residing in hidden layers). And no you can’t change an object from one set to the other.

Imagine the hidden objects as your content set. You can create active copies of them with addObject any time in game (as mentioned before … Within the same scene).

As I wrote you can link in groups. Check the guide to linked Libraries in my signature ;). You will see they are an extreme powerful tool especially when creating levels with shared content.

I’m checking the guides Monster, but I don’t know Python (is in ‘things to do’ list, hehe). Sorry for being stubborn, but just to put it clear:

-> So, unsing Logic Bricks (0% Python), if I need to do 200 different levels then I’ll need to create 200 different Scenes (one scene per each level) ???

This option is independent from Python.

Indeed if you want 200 levels it is a good idea to have a scene for each of them. It might be even worth to have them in single .blends.

Thanks you so much Monster. And I’m reading your Guides, so helpful!. Greetings. SOLVED.