Skip to content

Commit 8d8cb20

Browse files
committed
fixed get_distance not accounting for radius of robot
1 parent 8c06138 commit 8d8cb20

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/bundles/robot_minigame/functions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ export function get_distance() : number {
265265
const obstacleCollisions: Collision[] = robot_raycast((area: Area) => area.isObstacle);
266266

267267
// If an obstacle is found, return its distance
268-
if (obstacleCollisions.length > 0) return obstacleCollisions[0].distance;
268+
if (obstacleCollisions.length > 0) return obstacleCollisions[0].distance - robot.radius;
269269

270270
// Find the distance to the bounds
271271
const boundsCollision: Collision | null = robot_raycast_area({
@@ -274,7 +274,7 @@ export function get_distance() : number {
274274
flags: {}
275275
});
276276

277-
return boundsCollision === null ? Infinity : boundsCollision.distance;
277+
return boundsCollision === null ? Infinity : boundsCollision.distance - robot.radius;
278278
}
279279

280280
/**

0 commit comments

Comments
 (0)