OK the weirdness begins.
First the offending robot o is not a corpse. Second, it is
fixed so it isn't even moving even though its .vy is showing 66085.34.
Pretty fast for a bot that is rooted to the spot don't you think? :blink:
What is even weirder is that after tracing where the call to "Lookoccur" comes from, I found it comes from the very top of "Writesenses" (senses module) before any manipulation of variable could take place.
Tracing back further shows the call to "Writesenses" comes from "Updatepos" (Robots module)
A few lines up "Updatepos" I find this chunk of code.
If .mem(216) <> 0 Then
.Fixed = True
.vx = 0
.vy = 0
Else
This sets .fixed to true (as it is in the offending rob(o)). It sets both .vx and .vy to zero also
You know what is missing? :D
Something to reset .vx and .ax if the bot is
already fixed.
The code I examined earlier (updatepos in the physics module) doesn't do this. Here it is again
If t <> moving And Not rob(t).Fixed Then
Maxspeed = 30 / (.mass / 2) 'Set maximum speed. Absolute max = 60
You see it specifically excludes fixed robots from this entire calculation routine to save processing time.
We have two choices.
- remove "And Not Rob(t).Fixed" from this line of code
- Add another little catch all condition in "Updatepos" to make sure that .vx and .vy are set to zero if a robot is fixed
I think the latter will run faster
find this section of code in "Updatepos"
If .mem(216) <> 0 Then
.Fixed = True
.vx = 0
.vy = 0
Else
.Fixed = False
End If
and change it to
If .mem(216) <> 0 Then
.Fixed = True
Else
.Fixed = False
End If
if .Fixed then
.vx = 0
.vy = 0
Endif
That should hopefully put this problem to bed once and for all.