Alternative to Raycasting?

Good morning fellow devs.

Currently I am using ray casting for monster pathing. ( Both random pathing and pathing to the player when in aggro state )

I have found that ray casting is pretty expensive for the server to perform.

I just want to know if there are best practices with using raycasting or if there are other solutions.

I really like the net result of raycasting and how it works because you get really clean monster movements. But with a number of monsters and 5 players on a map it can start to suffer in performance ( client vs server vs client ), I would be fine with a different approach even if I sacrifice some of the quality that ray cast offers.

I was thinking perhaps one solution is to only have ray casting for when a player aggros a monster and outside of that set pre defined paths for monsters when they are not aggroed, although this would be time consuming to setup so before going down that rabbit hole I just wanted to see how you guys handle it.

Many thanks!

The only best practice for raycasting really is don’t make them longer than necessary. You could also do them in parallel which would improve performance. But really raycasts aren’t that expensive, if you’re finding them to be the main source of lag then see if you can do them less frequently and like I said see if you can do them in parallel.

1 Like

appreciate the response - you have given me some good ideas like maybe I can recast a path, save it and then recycle it for the same monster as a loop.