Alright so I've been stuck on this, I tried to ask earlier, but I didn't explain it very well. I have a new approach, just not sure I'm doing it right.
Here is my code, I think i have a way to have it do what i want, just not sure how to call to a custom property on an object, I thought the code I had was right, but i feel like im 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 im trying to use the property in the code, just pretty sure im typing it out wrong. Anyone able to show me what I'm doing 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()