Hey everybody, I've been fighting with this bug for almost a full day now. I've got these two functions
function unit_getMouse3DCoord( index as integer , mouse_x as integer , mouse_y as integer )
local null
null=pick object(mouse_x,mouse_y,groundObjID,groundObjID)
if null=0
unit(index).isMoving=false
unit(index).isIdle=true
else
unit(index).tgt.x=camera position x(0)+get pick vector x()
unit(index).tgt.z=camera position z(0)+get pick vector z()
unit(index).isMoving=true
unit(index).isIdle=false
unit(index).angleToTgt=atanfull(unit(i).tgt.x-unit(i).pos.x,unit(i).tgt.z-unit(i).pos.z)
endif
endfunction
and
function bldg_getMouse3DCoord(index as integer , mouse_x as integer , mouse_y as integer )
local null
null=pick object(mouse_y,mouse_y,groundObjID,groundObjID)
if null=0
bldg(index).setSpwnPnt=false
else
bldg(index).spwnpnt.x=camera position x(0)+get pick vector x() //returning weird values
bldg(index).spwnpnt.z=camera position z(0)+get pick vector z() //returning weird values
bldg(index).setSpwnPnt=false
endif
endfunction
.
Although they are very similar in both structure and usage, I'm getting radically different results. I can't explain the bug in words really, so I've uploaded a zip of my project. To reproduce the bug, left-click on the blue rectangular building to the right of the screen and then left-click the flag looking button on the GUI bar along the bottom of the screen. Then right-click somewhere near where you'd want a unit to run to when spawned. The red sphere should be where you click, but it isn't.
If anyone can help I'd greatly appreciate it.
EDIT: To see the difference, select one of the blue boxes like in AoE and right-click to move it.
EDIT2: Forgot some things in the zip.