Best strategy for AI stalking/chasing movement?

I’m trying to create a game where the Ai stalks you from behind trees as you walk through the forest and sometimes attacks you. This has multiple complicated parts which is why I don’t know the best way to create it.

First, I want the AI to follow the player; however, it also hides behind trees and not just follow out in the open. In addition to this I want the Ai to progressively get closer to the player from one tree to another even while the player may be moving away from it. Then after a bit of stalking for it to jump out and run straight for the player.

What would the best strategy/strategies for this if I have a big map with tons of trees. I have experimented with waypoints, splines, and Ai moves but for the long term I don’t know which I should try and use or if I should use something else.

Please give me all help you can in solving this.

you can use EQS to find ‘cover’ (trees) outside the players field of view.

chase logic is easy but

with this you can just cheat and teleport it when the player isnt looking :wink:

You need a collision sphere around the player to determine the “relevant” trees. Then you need to find trees that are located at the collision boundary (those whose distance from the player, for example, is more than 0.8 of the sphere radius), so that the monster does not immediately run to the player, but keeps its distance. Then FindLookAtRotation(Player position - tree position)->GetForwardVector * (approximately 100-200) + GetWorldLocation of the tree - to determine the point “behind the tree” where the monster can come. Next - choose any point and send the monster there (AIMoveTo), If the player is not looking towards the monster(?).

You can change the size of the tree search collision over time (timeline?), then we will get closer and closer.