Hi, I’m very new to unreal and game making in general so my apologies if this isn’t something that is possible but, I have two boxes (that I want to make into triggers) connected to my character controller.
I want to make the ai that is currently following the player to avoid standing in these spaces but if they do I want it to move either left or right.
You could use the begin overlap events for the boxes on the player to call a function on (or send an interface message to) the other actor which tells then where to move.
Basically, on begin overlap, you’d cast to your ai’s class from the “other actor” pin on the overlap event, and call the function from there. If you have a vector as an input on the function you can pass it a target location from the player,and use that as hte location for moveto.
Otherwise, if you want ai to follow the player in some sort of formation, it might be best to create an invisible dummy actor class, and add it to player as a child actor, which is attached to a spring arm that swivels around the player as they move. I use this for my friendly bodyguard/pet actors and have the dummy as the target for MoveToActor on the ai.
So I’ve spent a few good hours trying to set this up myself by making a new merged blueprint. After it was made I moved all the coding to the new blueprint. Problem is The controls are busted (the new blueprint I can’t move on wasd anymore) and the camera isn’t in the place it should be. I’m assuming I’m probably doing this incorrectly.
Could you possibly send screenshots showing how you set yours up? Or maybe a bit more detail on how you did it so I can figure it out?
The part in my bp_player_char is rather basic. Just added another spring arm component that doesn’t directly inherit rotation, but instead has the rotation updated in tick when I move. Dummy is the child actor attached to spring. This is what the spring settings and relevant part of tick look like:
If you want the ai to always goto the location even when turning in place, you could skip the tick part and just set a static relative rotation in the details. I just did it like this so npc friends wouldn’t run around me constantly when standing still lol.
The spring and child shouldn’t affect movement unless the child has collision enabled or if your camera ended up on wrong spring somehow in the procces.
The dummy actor itself just has a capsule (which is probably overkill) and a sphere (to see it while testing):
When I recruit an npc, I call an event on the AI controller which gets the child actor and sets a blackboard key with it. The behavior tree then has a service running which calls a move to task using that key. If you’re not using behavior tree, just set an actor var on the ai somewhere from the child class and plug that into a MoveToActor node.
Sorta like this maybe, using pawn sensing event like your original post:
Oh yeah this helped thanks again! I will add for any future people (probably including myself) to add a child actor you have to add child component to the main object and then choose the actor class.