1

# How to control ray cast thickness?

I'm currently trying to make a mob to follow a player and move around obstacles using ray casting. However, there was been a problem with it not checking whether or not the space that it can walk through will fit because the ray is like 1 millimeter thick. So I was wondering if there was a way to change the thickness of the ray to fit the entire width of the mob.

2

I don't think there is a way to control the thickness of a ray, however, you can use TWO rays.

Here's how it works, create 2 rays, one at the very far left of the mob, and one at the very far right.

Cast them in the direction the mob is currently moving at, then check if BOTH of the rays return nil, if one of them returns a hit, it would mean the path is too narrow to move through.

An example would be like this:

local Way1 = Ray.new(Start + Vector.RightVector*Radius, (Vector.LookVector+Vector.RightVector*Radius) * (Start-End).magnitude)