Code: Select all
res1, _ = simReadCollision(collisionHandle)
if (res1 == 1) then
res1 = 0
print("Collision!")
simStopSimulation()
res = simStartSimulation()
print(res)
end
It means the if statement loops three times and the operation simStartSimulation could not be performed. I guess there should be time delay to finish the operation, so I change the code like thisCollision!
0
Collision!
0
Collision!
0
Code: Select all
require "socket"
function sleep(sec)
socket.select(nil, nil, sec)
end
res1, _ = simReadCollision(collisionHandle)
if (res1 == 1) then
print("Collision!")
simStopSimulation()
sleep(0.5)
res = simStartSimulation()
print(res)
sleep(0.5)
end