I am trying to move my AI soldier to a target when he gets spawned. I have one that already starts in game and he moves there fine but when i press a button to spawn another ai soldier copy, he wont move.
I have tried putting code in the soldier and the level blueprint, nothing will make the new spawns move
I have also tried move to location, inputting the location manually, still the new spawn does not move.
This is on every tick and it does print the text but like i said, only the one that loads with the game moves, not a new one that i spawn in game.
The Controller pin of Simple Move to Actor needs to be wired to something. Get All Actors of Class isn’t an ideal input. You would have to iterate through the array it returns, and for each member: (i) cast it to Character, then (ii) look up the Character’s controller.
It would be better to add this code to the soldier blueprint, attached to the Begin Play event. For new spawns, Begin Play will be called once the character is usable, so you should be able to tell it to move at that point. Every soldier will get this Begin Play event called, so you shouldn’t ever have to iterate through the whole list of soldiers in the game.
Does that compile? The “Simple Move to Actor” needs a controller.
Besides that:
In your character blueprint, have you checked if the Auto Possess AI is selected to “Place in World or Spawned”?
How are you spawning your Character?
I’ve encountered some issues “spawn actor from class”, with AI’s.
So I’ve been using the function “spawn AI from class” instead, and using a behavior tree.
You need the controller of the AI guy, not the player controller. If you’re in the AI guy’s character blueprint, there’s a node called Get Controller—or something! I don’t have access to the engine at the moment so I can’t check.
When you use “spawn actor from class” to spawn your character,it’s possible that it is not spawning the AI Controller Class.
Actually this has been answered here: link text
However you can’t use the “Get Player Controller” function to get your AI controller!
A Pawn/Character can controlled either by a “Player Controller” or an “AI Controller”.
You can use the function “Get AIController”, where if you provide your AISoldier it returns its AIController.
If you’re having trouble with making your AI, you can find tutorials that will guide step by step, for example:
[link text][1]
You can also read the documentation about AI, and blueprint debugging.
[link text][2]
There’s plenty of documentation on how to achieve the effect you want.
Meanwhile, if you persist, make sure you have your “navmesh bounds volume” placed in the world.
Yes I had already done everything else, it was just down to the combination and which blueprint to store it. I put this in Level blueprint the way you did it and it works !! IT WORKS THANK YOU
I know this is old but it might help someone else. The reason that he is not moving is because he is spawned into the world rather than being placed via the level editor. As the OP said his current one in level works fine. So all you need to do is go to your AI character’s BP and under Pawn make sure ‘Auto Possess AI’ is set to ‘Placed in World or Spawned’ rather than the default ‘Placed in World’ option it is normally set to.