Hi everyone, I was wondering if I could do a small public test. Attached is a small stripped down version of the game. It is purely there to debug the path finding system. Could anyone who has a mess about with it see if they could try to spot any trends in the bug described below. I'm also putting a code snippet up and would be appreciative if anyone could help out with the issue.
Bug 1;
The tank when rotating to an angle gets to the angle, and when it hits within 5 degrees either way of the target angle, it should stop rotating. Unfortunately, it seems to ignore the code at times and just jutters at this angle, and tries to rotate back and forth finding this point. I can not understand for the life of me what could begin to cause this, so if people can spot trends and report them, it would be of great help!
Bug 2;
The tank just rotates in a full circle... This means it does pass the designated angle and just ignores the code.
The code which detects if the angle passed has no other parameters. It is not nested in loops of other if-functions, and so the only way to trigger this code inside, which will stop rotations, is by meeting within 5 degrees of the designated angle.
function moveobject(id AS INTEGER)
team = 1
if teamunit(team, id).pathnodes <> 0
` generate a few basic values to save time later
object = teamunit(team, id).id
model = teamunit(team, id).source
path = teamunit(team, id).pathnodes
target = nodetarget(path)
` get the position to move to
x = gridx(node(path, target).xpos) + squaresize / 2
z = gridz(node(path, target).ypos) + squaresize / 2
` get the angle objetc data
objectangle = object angle y(object)
anglemove = 5
` get the angle to move to
dx# = x - object position x(object)
dz# = z - object position z(object)
angle = atanfull(dx#,dz#)
` if on the final node then clear the node available for later use
if nodetarget(path) = 0
exitfunction
teamunit(team, id).pathnodes = 0
nodetarget(path) = 0
endif
` show some debug data
print "Path Number = " ; target ; " out of " ; nodetarget(path)
print "Target = (" ; x ; "," ; y ; ") from (" ; teamunit(1, id).xgrid ; "," ; teamunit(1, id).zgrid ; ")"
print "target angle = " ; str$(wrapvalue(angle))
print "object angle = " ; str$(wrapvalue(objectangle))
` sync so this data can be seen ingame
sync
` rotate the object as necessary
if objectangle - anglemove * 2 < angle and objectangle + anglemove * 2 > angle
yrotate object object, angle
node(path, target+1).status = 0
else
if wrapvalue(object angle y(object) - angle) > 180
yrotate object object, objectangle + anglemove
else
yrotate object object, objectangle - anglemove
endif
`yrotate object object, angle
endif
` see if the object has arrived in the final position, else move it
if object position x(object) <= x + units(model).speed and object position x(object) >= x - units(model).speed and object position z(object) <= z + units(model).speed and object position z(object) >= z - units(model).speed
position object object, x, object position y(object), z
dec nodetarget(path), 1
else
if node(path, target+1).status <> -1 then move object object, units(model).speed
endif
endif
endfunction
Please only report trends with the above errors! There is alot of code removed in an attempt to isolate these, and as a result there are plenty of issues which will be fixed when the code is returned!
To move the tank right click in a new location.
To plant a building use the left mouse to select then place.
A
