Recall several replicas of the same object

Is there a python example to recreate several replicas of the same object on another layer and place them dynamically in the scene, giving them different names, and applying different textures on each replica?

Sorry this is probably the wrong subforum… I posted the same thread on the python subforum but I can’t delete this one…

in the 2.42a Game demo files there is an array example.

to delete the thread, go to advanced mode, I think there is a delete thread button there.

All the questions regarding the Blender Game Engine should be posted in the Game Engine forums - python or not.

You can have a single object on another layer, and make replicas of that dynamically in the scene. For that, you use the add object actuator.

Why do you need to give them different names? There is no reason to do that with added objects. If you need to get the created object itself, just use the raysensor or anything else that supports the getHitObject() function - then you can alter it’s properties as you wish.

As for dynamic texture assignment, I don’t know. Never had the need to do that in the BGE. What exactly do you need that for? I mean you probably don’t even need to do that in order to accomplish whatever it is you want to accomplish.


I think only admins/mods are allowed to delete threads.

I think only admins/mods are allowed to delete threads.

Yea! thanks, I just tried it, you are right.

Sorry about that Sumo…

Well, it’s for the game of the “jumping keys”… I’d like to use the same object key in another layer and assing the texture of the alphabetical letter and the name…
if after the jump they land outside the keyboard they fall and I’d like to make them disappear… then a key can appear again on the keyboard, with the letter randomly selected and randomly placed by a timer… that’s why I look for some examples of dynamical placement and texture assignement… if you know any could you please give me a link?

I’d like to use the same object key in another layer and assing the texture of the alphabetical letter and the name…

you might be able to use IPO materials for something like this, it wont change the texture, but you can at least change the color.Just hover your mouse over the material window and press I. You can do this with lights too.
to get them to play the colors just use an ipo actuator, with the property option. When they spawn have them roll a random number, and poke it into the same property as the IPO is using. You will get semi random colors that way.

hope that helps.

Are you making a typing tutor game?

I have placed many empty’s on a layer and I’d like to call the addobject actuator possibily in a script for all the empty’s, adding replicas of the same object I have placed on another layer. How can I do that in a script?

Then I’d like to change the Text property for each replica (I suppose creating an array of empty’s, scanning the array in a loop, calling GetLastAddedObject for each empty, and setting the text property to the desired value… is this right?)

Anyway, is there a way to add a mouse over sensor on each replica? If I add a sensor on the original copy of object on the other layer, the sensor won’t be duplicated on each replica… So how can I add a sensor on each replica and then take a reference of which replica has triggered the mouse over sensor?

Here is a .blend to start
A,S,D keys add replicas of the object on layer 2 but I don’t know how to activate mouseover on replicas…

Actually I cannot even access to each replica as a single object, for instance in order to change a property or so… Please help me!

I managed to get a handle to the replica using the getLastCreatedObject method of the EditObject::AddObject actuator and I tryed to apply and impulse on it and it seems to work… Here si the blend

Yet something is still confusing… the objects do not land on the plane, and multiple additions of objects cause them to move, probably because there is a collision, but the direction is not controllable at all and collisions seem to be detected only between replicas created by the same actuator.
Besides this, if I leave the light on layer 1 all the replicas won’t be illuminated, so I had to move the light on layer 2…
And I still have the problem to activate the mouse over sensor on each replica and identify the replica which triggered it (all replicas have the same object name, so I thought to use a property to identify them)

Or maybe you the GE management of objetcs created by EditObject::AddObject actuator is still quite full of bugs and I’d better give up?