2D Raycasting using Phaser 3

I came across a method called GeyRaysFromPointToPolygon. As I explored how this method works (my exploration is documented here, if you are interested), I realised the sheer diversity of methods relating to 2D raycasting that Phaser 3 provides. The below example uses Phaser.Geom.Intersects.GetLineToPolygon method.

The example code is available in the Codepen below.

I then went onto find out about Phaser 3’s functionality for 2D raycasting in tilemaps. Among my various experiments (documented here), I implemented a method to reduce the number of polygons that the intersect method checks against.

Finally, I implemented a method to do 2D raycasting in tilemaps based on DDA algorithm. This code is pretty much implemented without relying on Phaser 3 built-in methods (I won’t be too surprised if someone tells me Phaser 3 does indeed have such a method built-in!) but for those interested in how DDA 2D raycasting can be implemented in Javascript, my blog here documents my meanderings to arrive at my version of the algorithm.


Just amazing, very cool, nice work : )

Thank you!!

1 Like