getObject

Hello, is there a way to get the Object just knowing the name of the Object, Like
Object = GameLogic.getObject(“the Object”).getOwner()

Is this posible?

well, it is now, with the addition of scenes in the GameLogic module

[this should really be documented by now, 2.34 came out last week]

# $Id: KX_Scene.py,v 1.2 2004/06/26 09:15:40 kester Exp $
# Documentation for KX_Scene.py

class KX_Scene:
"""
Scene.

The activity culling stuff is supposed to disable logic bricks when their owner gets too far
from the active camera.  It was taken from some code lurking at the back of KX_Scene - who knows 
what it does!

Example::
import GameLogic

# get the scene
scene = GameLogic.getCurrentScene()

# print all the objects in the scene
for obj in scene.getObjectList():
print obj.getName()

# get an object named 'Cube'
obj = scene.getObjectList()["OBCube"]

# get the first object in the scene.
obj = scene.getObjectList()[0]

Example::
# Get the depth of an object in the camera view.
import GameLogic

obj = GameLogic.getCurrentController().getOwner()
cam = GameLogic.getCurrentScene().active_camera

# Depth is negative and decreasing further from the camera
depth = obj.position[0]*cam.world_to_camera[2][0] + obj.position[1]*cam.world_to_camera[2][1] + obj.position[2]*cam.world_to_camera[2][2] + cam.world_to_camera[2][3]

@bug: All attributes are read only at the moment.

@ivar name: The scene's name
@type name: string
@ivar active_camera: The current active camera
@type active_camera: L{KX_Camera}
@ivar suspended: True if the scene is suspended.
@type suspended: boolean
@ivar activity_culling: True if the scene is activity culling
@type activity_culling: boolean
@ivar activity_culling_radius: The distance outside which to do activity culling.  Measured in manhattan distance.
@type activity_culling_radius: float
"""

def getLightList():
"""
Returns the list of lights in the scene.

@rtype: list [L{KX_Light}]
"""
def getObjectList():
"""
Returns the list of objects in the scene.

@rtype: list [L{KX_GameObject}]
"""
def getName():
"""
Returns the name of the scene.

@rtype: string
"""

that is, blender/source/gameengine/PyDoc/KX_Scene.py

[all indentation seems to be lost, but you aren’t missing much]

NOR.J doesnt use 2.34 yet :stuck_out_tongue: he’s sticking with 2.25 till his game is done. seee j i do listen :D.

I know about the new stuff in 2.34
But Just by knowing the name of the Object, Can you do get the Owner ?
For example

Object = GameLogic.getObject(“Plane”).getOwner()

Is this posible?

Or this?

Object = GameLogic.getObject(“Plane”).getCurrentController()

Is it posible to get The Owner of an Object just by knowing its name?
If not, it would be Awsom to Inplant a function like that :slight_smile:

I always try out the newest versions, But i will not make my game in them, becaus i have alredy started with it in 2.25

But i will move on when my game is finnished.
So if what i ask can be done in 2.34 or 2.25 dosent matter.

yea i know j :). u told me :D.

In 2.25 You can use a huge Sensor (Near/Radar) which overviews the whole Scene. From this Sensor You can get a List of all (Mesh) Objects. This List can be stored in the GameLogic Module and You can have access to it from each Script.
Maybe this helps.
Doc

Well, Doc
It is a Good aidea to get All the Objects Name But i want to get the Owner of the Objects, so i can get the Positions Of them :frowning:
But this dosent seems to work, so Thanks anyway

NOR.J,

idea, that Doc suggested, really works. You will get references to game objects from near sensor, so you can get their position (and all other properties) immediately.

@ivar activity_culling: True if the scene is activity culling
@type activity_culling: boolean
@ivar activity_culling_radius: The distance outside which to do activity culling. Measured in manhattan distance.
@type activity_culling_radius: float

Hey , what about that culling lines?
Its not working right now, right?

So, Will Blender have maybe in the next version a culling script working and integrated?

Cu.

oOO, Now i See how it works, Thanks Doc!! 8) :stuck_out_tongue:

But how can i do it? i havent seen or Heared about this. Can you help me? give an example to me?

Try download file getObjects.blend. I hope it will help you. It lists names and positions of all game objects (actors) in 100 range around empty with near sensor.

That was Exactly what i needed ashsid
Thank you all for helping me :slight_smile: