python doubt

any difference in controlling object using:

  • bge.logic.getCurrentController()
  • bge.logic.getCurrentScene().objects[#]

i know 1st one is only for the object where the Python controller is used.
but if i only use the second i should be fine?
any technical detail that I am not aware of.

Should be fine. They’re just gameobject references

There are big differences:

  1. is a controller (the current executed one)
  2. is a gameObject from the current scene

You can get the gameObject that owns the current controller via controller.owner.

You can activate and deactivate actuators only

  • with the connected controller
  • only when this controller is the current one

This means you can’t activate/deactivate other actuators!

Using KX_Scene.objects[“name”] is dangerous if you can’t guaranty there is only one object with that name. Otherwise you would get any object with that name. It is also possible that this object simply does not exist.

You can deal with both situations, but you need to know that they are possible.