Hello everyone, I am trying to make my AI to move to an actor that I am spawning from a widget button or that I am actually placing in the world from the widget button. So, does anyone know the code of that? I have tried Move to Location or Actor, it doesn’t work, I have tried AI move to, it doesn’t work. Does anyone know how can this be done?
In order for you to get the idea of what I am trying to create, it’s a waypoint system that the AI will follow once a waypoint actor is placed in the world. Each waypoint is placed during play time so it’s not pre placed from the editor mode.
From what I understand you want your AI to engage waypoints in runtime and would like to see an example of it. I have attempted this myself and this is my result.
On my AI:
On begin play, just once, I clear my array of waypoint BPs in case anything was left over.
In those two functions you see:
in: “GetsTheNewPoints” I get all actors of class (I made an actor class named BP_WayPoint) and add a unique value to the Master Waypoint array.
To explain the above image:
I have a integer that I use to keep track of which element we are on. I make sure it isn’t greater than the last index and if it is, set the current element to 0. If its isn’t, then we just move to the waypoint.
After reaching the waypoint, I will increment the order to ensure we are using the next element in line. The delay isn’t needed, as far as I can tell, but I like having them. After that, we GetsTheNewPoints, and GoToLocaleWithMod again to recycle the Ai move to.
The downside: Depending on when you place the waypoint, the AI might skip it if its currently not looking for it. It will catch it on its next cycle though. The player BP is just spawning waypoints at a trace hit location.
One thing I did not explain was when you have no waypoints in the map. I strongly encourage you to use the logic I have here and consider how you would implement that.
Hey Polite_Muon, thanks so much for replying to my post, it looks like it’s the answer, though, I have found a different way to do it which is through component etc.
So, I have one more question. I want to spawn a waypoint on click. I have a widget button and when I click it, it spawns in a specific location. I want to make it so that the waypoint spawns on where the player clicks.
An example is this video:
You see that whenever he clicks, an actor is spawned which is the waypoint