Calling python functions from different objects???

Hey,

How do I call functions that one object has running in a script from another object in the bge? I have had a look through the python API and cant see any function to call on the KX_GameObject that will allow me to access scripts functions. Is this even possible in the ge? I would have thought it would be possible, but maybe I’m a bit confused as to how the game engine handles objects with scripts attached to them.

Any tips for this? Or another way of doing it?

Cheers

  1. Turn your script into a module (add the .py extension)
  2. Import the module “import moduleName”
  3. use the function “moduleName.function(dep)”

also possible:

  • attach a script or module to an object and a message sensor. Send a message to that object, this will activate the sensor to call the method.

or:

  • attach a property sensor to an object and change this property from an another object. the sensor will call the method.

Cheers guys. This is exactly what I was looking for. I’m really beginning to see how powerful python is when it’s tied into the game engine.

Thanks