[Bf-committers] GE object instances Id?

Natanael Olaiz nolaiz at gmail.com
Fri Mar 13 17:37:45 CET 2009


El 03/13/2009 09:01 AM, Campbell Barton escribió:
> On Fri, Mar 13, 2009 at 3:51 AM, Natanael Olaiz <nolaiz at gmail.com> wrote:
>   
>> Hi,
>>
>> First: thanks to all for your answers.
>>
>> El 03/12/2009 09:39 PM, Toni Alatalo escribió:
>>     
>>> Mitchell Stokes kirjoitti:
>>>
>>>       
>>>> All instances of game objects that are made from the same blender
>>>> object, and yes
>>>>
>>>>         
>>> .. "have the same name", i guess you meant to continue there.
>>>
>>> indeed i didn't realize this talk was about the instancing during the
>>> running of the game, was just thinking of objects that have already been
>>> put to a scene on the modelling side before the game is started - those
>>> all have unique names.
>>>
>>>       
>> Yes, that is my question. Let me try to explain a little better with an
>> example:
>>
>> The first level ("level_1_home") have some rats. For instance, at
>> [2.67,21.97,3.97] there is a "rat.010" object, and at [4.21,22.15,3.97]
>> there is a "rat.011".
>> If I put an "allways" sensor on rat and rig_rat on "sheep.blend" file
>> library, triggering a Python script with a "print
>> GameLogic.getCurrentController().getOwner().name", I obtain on every
>> rat: "OBrat", even from the "level_1_home" instantiations of that model.
>>
>> I tried now putting the script on the level, on each object and it works
>> OK (it says rat.010 and rat.011)....
>> But... can I get the instance name (rat.010 / rat.011) from a script
>> within the main library? or I need to duplicate the script on every
>> instance by hand?
>>
>>     
> [...]
>   

> excuse the brief reply,
> - fairly sure there is no way to reference the empty that instances
> groups in the BGE. (benoit will know)
> - In YoFrankie Rat/Sheep/Ram all use the same logic base object. You
> can tell which is which by the 'type' property - will be one of
> shp/ram/rat
> - In YF they each have a unique 'id' int property that should stay the
> same while the level runs.
>   
Great! That was my solution: use the 'id' property.
Could I expect to have the same ("char_init_id" generated) Id for the 
same objects every time that I run the engine?

> - if you want a unique value for the KX_GameObject use
> hash(GameLogic.getCurrentController().getOwner()) - This uses the
> memory address of the class.
>
>   
That was a good solution too. But in this case my previous question is 
negative: I allways will have different numbers, and I don't know how to 
iterate between the items to have an ordered list...



Thank you all again for your answers!


Best regards,
Natanael.


More information about the Bf-committers mailing list