[Bf-committers] GE object instances Id?
Natanael Olaiz
nolaiz at gmail.com
Fri Mar 13 08:51:32 CET 2009
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?
>> Yes and no. If I understand you right, you want to do something like,
>> "if object a is a sheep, do this". (...)
>> own = GameLogic.getCurrentController().getOwner()
>> if hasattr(own, "sheep"):
>> print "I'm a sheep!"
>> On Thu, Mar 12, 2009 at 11:08 AM, Natanael Olaiz <nolaiz at gmail.com
>> <mailto:nolaiz at gmail.com>> wrote:
>>
>> I have a question about the Game Engine: there is a way to identify
>> between different objects of the same type?
>>
>>
>
> that case of 'if is sheep' etc. i would call "identify the types of
> different objects", not "identify different objects of same type", but
> perhaps am just used to a bit different terminology than Natanael :) ..
> the solution with properties is indeed nice for such typing if that was
> your need (identifying type and not an individual instance, in my / oo
> programming terminology).
>
>
>> BTW, I don't know if this is the proper list to ask this question. If
>> not, please tell me where I have to ask...
>>
>>
>
> forgot to mention in the earlier quick reply that usually these usage
> things are asked on the forums, at least some years ago the
> blenderartists GE forum was really active and helpful, ppl knowing all
> sorts of tricks and hacks to weird problems even.
>
> but i guess this kind of talk about IDs perhaps the least off topic kind
> of talk on the coders list :)
>
>
Good to know that. Thanks!!
Best regards,
Natanael.*
*
>> Natanael.
>>
>>
>
> ~Toni
>
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>
>
More information about the Bf-committers
mailing list