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)
Item.setPosition(Handpos)
The blender console give me this error: AttributeError: ‘SCA_PythonController’ object has no attribute ‘getOwner’
This error appear in line gettting the object “Item”
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.
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()
Item.setPosition(Handpos)
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.
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.
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