can someone help me make a smart-ish AI, so it doesnt just walk straight toward you, but goes along the buildings so it doesn’t get stuck.
Hi @Gavin_Durbin! Unfortunately, this is not easy to achieve with PlayCanvas. For my own game I use sensors (raycasts) around the AI that determine whether an obstacle should be avoided. If there is no obstacle to avoid, you can turn the AI towards the destination. It took me a long time to find the right balance. The system now works fine, but by no means flawless. That is why I am going to develop the system further. I’m curious if anyone on the forum has a better idea for this.
back in the early 2000 I’d liked to make maps for unreal. They used pathpoints (little apples) and something like hide- and sniperpoints. The bots walked from pathpoint to pathpoint. Made random decisions at a fork or attak if shot at or spot an enemy. Implemented these in my ai. Quite a simple approach, so my bots are not smart…
There are a couple of path finding libraries out there. Eg https://qiao.github.io/PathFinding.js/visual/ works for 2D but you will have to create the nodes/graph yourself.
The pathfinding system can be achieved if you have a tiled terrain, without it the thing become more complicated the only way i can think of is a system using raycasting but head ache come just thinking about it. If the map is tiled you can achieve it with a pathfinding script like in tower defence game by @will in playcanvas projects.
thank you, this will help alot