How to do raytracing (raycasting)

I made an example of how to implement raytracing in GD. This is really useful to check if you’re in the line of sight of an enemy, or for an enemy to check what upcoming obstacles there are. In the scene, you can see the rays being fired. Add a line ‘hide object ray’ just after they are created if you don’t want to see them (it’s better for example purposes if you can see them though).

I didn’t comment the example, as I think a quick video explaining it will be easier. Unfortunately, with the amount of noisy people in this house, that might have to wait until another day…

Edit: I think this might be called raycasting? hmm I’m not sure. lol
rays_example.zip (96 KB)

Nice, it’s a kind of line of sight indeed, it works pretty well! :slight_smile: