Here is my code, I think I have a way to have it do what I want, just not sure how to access a custom property on an object. I thought the code I had was right, but I feel like I'm missing something (or did something wrong).
The goal is so that whenever I hit Tab it increases the value of the custom property 'unit' by 1, thus changing which trackObject I am placing when I click. (the TAB/Property change is done in the logic bricks). At this point I know I'm trying to use the property in the code, just pretty sure I'm typing it out wrong.
import bge
import bpy
from bge import render
render.showMouse(1)
def main():
cont = bge.logic.getCurrentController()
own = cont.owner
scene = bge.logic.getCurrentScene()
trackObject1 = scene.objects ["trackObject1"]
trackObject2 = scene.objects ["trackObject2"]
trackObject3 = scene.objects ["trackObject3"]
trackObject4 = scene.objects ["trackObject4"]
trackObject5 = scene.objects ["trackObject5"]
unit = bpy.data.objects["player"]["unit"] #pretty sure this isnt right...
mouseOver = cont.sensors ["mouseOver"]
click = cont.sensors ["click"]
readyMove = cont.sensors ["readyMove"]
trackTo = cont.actuators ["trackTo"]
move = cont.actuators ["move"]
if mouseOver.positive:
target = mouseOver.hitObject
if click.positive and unit == 1:
trackObject1.worldPosition = mouseOver.hitPosition
else if click.positive and unit == 2:
trackObject2.worldPosition = mouseOver.hitPosition
else if click.positive and unit == 3:
trackObject3.worldPosition = mouseOver.hitPosition
else if click.positive and unit == 4:
trackObject4.worldPosition = mouseOver.hitPosition
else if click.positive and unit == 5:
trackObject5.worldPosition = mouseOver.hitPosition
if readyMove.positive:
cont.activate(move)
cont.activate(trackTo)
if own.getDistanceTo(trackObject1) < 2:
else if own.getDistanceTo(trackObject2) < 2:
else if own.getDistanceTo(trackObject3) < 2:
else if own.getDistanceTo(trackObject4) < 2:
else if own.getDistanceTo(trackObject5) < 2:
cont.deactivate(move)
cont.deactivate(trackTo)
main()