Enemy AI teleport based on player location

Hey, guys. I’m making a Slender-like mini horror game and need some more help with the AI. Does anybody know how I can get my enemy AI to teleport to a random location on the map based on the player’s location? If so, I’d greatly appreciate it if you could show me how. Please and thanks in advance!

U have to have NavMeshBoundsVolume to make as the way i say u. If it is singleplayer u can take the player in AI BP (the character of Slender BP) with Get all Actors Of class (filter ur Character blueprint) and get that array with index 0, it is your player character, now that u have the player, u can get his location with getactorlocation and use Get navigation reachable point, and set the radius you want, the origin as getplayercharacter location (i said before). U have to make SetActorlocation of Slender to that position obtained with Get navigation Reachable point. I said u need NavMesh cause is the best method i found to get points of the landscape and move AIs too without erros on moving, and it uses navigation at all. It only works for AIs, remember, for Playercontrollers u have to activate somethings.

Bye bye and Gz, hope it helps u.

Look into EQS system.

Create function that uses EQS to find best spots around player to teleport in.
Conditions for such location:

  • must be in some nav mesh distance from player
  • hidden from player sight
  • best would be behind player.
  • check for distances to other enemy ais (sum of distances to all AIs from tested spot must be biggest).

So follow some EQS tutorial. Make grid of potential points around player. Test for distance, then test for line of sight, last test direction (dot product of forward vector of player and direction vector from player to potential location). You should have best spot. Teleport enemy ai there.

Only said how to tp an actor easiest way, not taking about it has to be behind. In that case u can do like Nawrot says in last, make 2 components (or whatever you like) and put em behind ur player to teleport the npc. I dont know how distance goes in Slender games xD, but prolly some random, u can use random events to make him appear in some places depending the diffyculty etc.

PD: u should use get navigation points like i said to get the real posittion where Slender will appear, if u move him to a bad location he can go under the ground or things like that. U can check a line trace from player to point and see if there is nothing beetwen, if its something dont teleport there. To do a trace behind u can take a second camera to look where u want. It can be done only when Slender wants to move, so there wouldnt be performance problems with that code.

Gz with ur project.