4 ms·
Can't get better than 0.88sec? function controlFunction(block) { const max_force=1000000000; const margin=0.01; const friction_comp=0.2; if(block.
by pbazarnik 3y ago
Can't get better than 0.88sec?
function controlFunction(block)
{
const max_force=1000000000;
const margin=0.01;
const friction_comp=0.2;
if(block.x<-1-(margin/2))
return max_force*(1+friction_comp);
else if(block.x<-1.15*margin)
return -max_force;
else
return -block.x;
}
- kavouras 3y agoThe best you can do is 0.42, see a subcomment I made below. max force is limited to +-50
- iNic 3y agoI got 0.4 sec with this: function controlFunction(block) { const maxforce = 100.; if (block.x < -1.01) return maxforce; else if (block.x < -0.01) return -maxforce; else return -block.x - 2 * block.dx; }
- iNic 3y agoInterestingly enough this does not work in every browser. (It worked in Orion, but not in Brave.)