Look on the devhub about raycasting. Once you have done that, make a loop that loops forever and waits one second and then fires raycasts in each direction looking for a roof, walls and floor.
There are many other posts on this topic that you should have read before creating this post.
Like this one.
1 Like