I want an enemy to teleport to designated locations around my map, but at random. I intend to use invisible cubes as the movement points but I cannot find a comprehensive tutorial on how to actually make an AI that randomly teleports around on its own.
Which part are you not understanding exactly? like the AI decision making? The logistics of making the enemy find and move to these points?
Well I’ve never made an AI before so I wouldn’t understand either, but I am currently focused on making an enemy randomly teleport to points I designate around the map, yes.
I have found tutorials on how to spawn enemies that chase the player physically through the world but that is not what I want, specifically. At least not for this project. I want my enemy to spawn in the same place each level (I know how to do this), and then periodically teleport from one point to another based on random chance, as they try to enclose on the player’s point, which would trigger the game over condition (I also know how to do game overs).
So, it would mainly be the logistic of making the enemy move to the designated points, and at random, yes. I just cannot find any tutorials that do this specific thing for some reason.
Easiest way to do it would probably be in the level blueprint. Add the port marker actors to the level bp as an array, then have a looping timer that fires every 10s or whatevs, select a random index from the marker array, and set the enemy location.
You’d make an actor class, called like “BP_TeleportationPoint” or something. In your enemy AI controller, you’ll want to “GetActorsOfClass” of type “BP_TeleportationPoint” on begin play (Please note: this will cause bad performance at larger scale, i.e. whenever you have a lot of AI in your scene at once. If performance is a massive concern, I can provide a better, more involved solution that reduces the strain on your system). Save the output of “GetActorsOfClass” as a global array variable (I called mine “TeleportPoints”).
You’ll also want an event that triggers a teleportation (Trigger this however you want. A looping timer is a good place to start). This event finds a random integer in the range of your array. You’ll then get the TeleportationPoint at this index and use it to teleport the character to this TeleportationPoint.
