I’m trying to program an AI that is spawned once the player spawns and places an object on the ground. The AI would then move towards the newly spawned object.
So far all the tutorials I am finding are showing how to make an AI follow a player. I don’t know how to input the location of a newly spawned object to the target location in the Behavior Tree and Blackboard. Can anyone help me out here? I’m fairly new to AI blueprints and thought this would be an easy task to start it off with. Thanks!
the issue here is getting a reference to the spawned actor then setting that as a key for the black board. now this all will be very dependent on your particular use case but the basic idea is as stated you need to update the black board key thats associated with the move to location.
one way you could do this would be to have a event in the ai character that runs a script to update the key based on a input parameter. then when the player spawns the actor you would call the event in the ai and pass the reference to the actor.
as you can see in the picture below, the top is the player which spawns a actor (apple) then calls a custom event in the ai (update move to key). The ai is the bottom area, here we have the custom event with the input parameter of type actor, then we simply get the black board and update the key.
this is a extremely simplified example so you could add to this easily and modify it for your needs.
do note its also incomplete as i didn’t specify the key name to affect and i left the spawn location at 000.
Can I ask how did you call the custom event from the AI in the ThirdPersonCharacter blueprint ? I created the custom event in the AI event graph but can’t find it when trying to call it in the Player Character blueprint
theres many ways to do it, the method i used was to get a reference to the ai. or rather i was lazy and referenced every actor of the ai class with the get all of class.
you could also use things like a public variable, overlaps, traces, etc to get a reference that you can then save to a variable. then you just need to make sure you identify the class via a cast for example so that you can get the functionality (events) in that specific class.
theres a really good video about blueprint communication on the unreal engine youtube channel. the video covers this kind of thing if i remember right. in any case its worth the watch.
Could you please give more clarification? I’m having the same issue. My AI goes to a random point as programmed and from there I dunno how to get the AI to take possession of the spawned house and live in it