Sounds like you need to upgrade to 2.49 API
With a python controller:
collider.py:
#--- BGE callables
def copyProperty(cont):
if not allPositive(cont):
return
hitObjectSensor = findHitObject(cont)
if hitObjectSensor is None:
return
hitObject = hitObjectSensor.hitObject
if hitObject is None:
return
collider = cont.owner
copySensorProperty(collider, hitObject)
#--- Internals
def copySensorProperty(destination, sourceSensor):
'''Copies the property named by the sensor'''
propertyName = sourceSensor.propName
source = sourceSensor.hitObject
destination[propertyName] = source
def getHitObjectSensor(cont):
for sensor in cont.sensors:
try:
return sensor
except AttributeError:
pass
def allPositive(cont):
for sensor in cont.sensors:
if not sensor.positive:
return False
return True
(untested)
Python Module: collider.copyProperty
You forgot to mention how you want to decide which property to copy. The above code copies the property set up in the sensor.
If you want another method, modify the function copySensorProperty() or add another one.
For what do you need the Id? it is pretty useless except you want to manually compare two objects.
Which one?
Controllers do not have properties. I guess you mean the controllers owner = game object.
As shown above:
- get the reference of the hit object from the sensor
- get the reference of the controller’s owner (or the sensor’s owner)
- identify the property names you are looking for
- identify the property names you want to receive the value
- read the values from the source object
- write the values to the destination object