Whats wrong with my code?
I used the correct code. angle / 4 is better than angle / 2.
Oh by the way, here’s my code:
loop {
var angle = Math.PI / 2 - Math.PI / 16;
while(angle >= -Math.PI / 2) {
var targetX = this.pos.x + 5 * Math.cos(angle);
var targetY = this.pos.y + 5 * Math.sin(angle);
if(this.isPathClear({x: 76 ,y: 35}, this.pos)) {
this.move({x: targetX, y: targetY});
}
else {
angle -= Math.PI / 4;
}
}
}