1 # This script must be assigned to a python controller
2 # where it can access the object that owns it and the sensors/actuators that it connects to.
6 # support for Vector(), Matrix() types and advanced functions like Matrix.Scale(...) and Matrix.Rotation(...)
9 # for functions like getWindowWidth(), getWindowHeight()
14 cont = bge.logic.getCurrentController()
16 # The KX_GameObject that owns this controller.
19 # for scripts that deal with spacial logic
20 own_pos = own.worldPosition
22 # Some example functions, remove to write your own script.
23 # check for a positive sensor, will run on any object without errors.
24 print("Logic info for KX_GameObject", own.name)
27 for sens in cont.sensors:
28 # The sensor can be on another object, we may want to use it
30 print(" sensor:", sens.name, end=" ")
37 for actu in cont.actuators:
38 # The actuator can be on another object, we may want to use it
40 print(" actuator:", actu.name)
42 # This runs the actuator or turns it off
43 # note that actuators will continue to run unless explicitly turned off.
49 # Its also good practice to get sensors and actuators by name
50 # rather then index so any changes to their order wont break the script.
52 # sens_key = cont.sensors["key_sensor"]
53 # actu_motion = cont.actuators["motion"]
55 # Loop through all other objects in the scene
56 sce = bge.logic.getCurrentScene()
57 print("Scene Objects:", sce.name)
58 for ob in sce.objects:
59 print(" ", ob.name, ob.worldPosition)
61 # Example where collision objects are checked for their properties
62 # adding to our objects "life" property
64 actu_collide = cont.sensors["collision_sens"]
65 for ob in actu_collide.objectHitList:
66 # Check to see the object has this property
68 own["life"] += ob["life"]