Hi, its been a while I didnt played in blender so I went back trying to do some stuff and I went on on making a gridLock system in python… but I had some problems:
##### Mico27's gridLock system ####
controller = GameLogic.getCurrentController()
##Mouse sensor##
mouseOverStage = controller.getSensor("Mouse_Over_Stage")
Pos = mouseOverStage.getHitPosition()
x,y,z = Pos
##Rounding the x and y coordinates##
x = int(x)
y = int(y)
##Rounding z to 4 digits after dot##
z = (((float(int(z*10000+0.1)))/10000))
##get the terrain's cursor##
scene = GameLogic.getCurrentScene()
objList = scene.getObjectList()
PlaneCursor = objList["OBPlaneCursor"]
##set it to the Rounded coordinate of the mouse's cursor##
PlaneCursor.setPosition([ x, y, (z+0.1)])
##Check for flat terrain##
z %= 0.1
print z
##>>##in the next line, (z==0.1) doesnt work even when it shows 0.1 in the console##<<##
if (z == 0) or (z == 0.1):
##Flat terrain so put green cursor##
PlaneCursorColor = controller.getActuator("replace_PlaneCursor")
PlaneCursorColor.setMesh("PlaneCursorGreen")
GameLogic.addActiveActuator(PlaneCursorColor, True)
else:
##sloppy terrain so put red cursor##
PlaneCursorColor = controller.getActuator("replace_PlaneCursor")
PlaneCursorColor.setMesh("PlaneCursorRed")
GameLogic.addActiveActuator(PlaneCursorColor, True)
the problem is explainned in the code.
thanks in advance for helping.