Whats is wrong that script?

I need some help here :

from bge import logic
from bge import logic as GameLogic

c = GameLogic.getCurrentController()
Item  = c.getOwner()                         #error in this line

HandPos = c.objects("Hand").getOwner()

HandPos = Hand.getPosition()

print (Item.position)


The blender console give me this error: AttributeError: ‘SCA_PythonController’ object has no attribute ‘getOwner’

This error appear in line gettting the object “Item”

What is the problem?


Is this for Blender 2.6? If so, there’s no reason to have the ‘GameLogic’ line. Your error’s coming from the fact that there isn’t any c.getOwner() any more - it’s just c.owner.

Thanks! I fix that but i get onother error in the same line.
TypeError: ‘KX_GameObject’ object is not callable
Why is nor callable? Item is the current object. sorry if is simple Im just a beginner.

Not being callable means you put in the brackets () when you shoudn’t have.
There are many changes between the python of 2.49 and 2.6
I suspect that later you may have to chage a () to a [] as well.

Thanks, i changed the brackets

from bge import logic
from bge import logic as GameLogic

c = GameLogic.getCurrentController()
Item  = c.owner                        

HandPos = c.objects["Hand"].owner    #error now in this line, sca_pythoncontroller  object has not 
                                                        #objects  attribute
HandPos = Hand.getPosition()


Now the error is getting the object Hand. Please debug this script?
The idea is make the character pick a item moving to his hand position.

It shouldn’t be c.objects[‘Hand’].owner, as c is the controller, the Python controller running this script.

It should be

sce = logic.getCurrentScene()
handpos = sce.objects['Hand'].worldPosition

However, if the hand is a part of an animated armature, it probably won’t work. I believe you should parent an empty to the hand bone, and then move the item to the empty position.

do this:

import bge

def placeThisObjectToHand(cont):
    objectOwningTheController = cont.owner
    scene = bge.logic.getCurrentScene()
    hand = scene.objects["Hand"] # assuming there is EXACTLY one object called "Hand"!
    handPosition = hand.worldPosition

    print( "the owner of the controller was at", objectOwningTheController.worldPosition)
    objectOwningTheController.worldPosition = handPosition

Then setup a Python controller in Module mode with: demo.placeThisObjectToHand


  • do not use BGE 2.48 API (getOwner).
  • do not use deprecated code (position)
  • avoid short names with ambiguous meaning ©
  • better use module mode

Thanks guy the problem is solved! I have been reading the 2.4 api and am a beginer too.