One problem I always seem to run into is getting a blueprint reference node to an actor that is on an entirely different blueprint. Specifically, a static actor I’ve already placed in the world. I’m sure this is simple to do and that my frustrations come from a lack of fundamental understanding, so I’m hoping someone here can help shed a little light on this topic.
The current reference issue I’m having is with an AI task. I’d like to do a simple “Move to Actor Location”, but how do I get a reference to that actor on my Behavior Tree Task blueprint? The actor in question has already been placed in the world. Getting a reference to a component of that actor doesn’t seem to work. If I wanted to move the AI to the player character, no problem, I can use “Get Player Controller” and go from there (which has worked for me). How do I do the same but for another actor that is not related to the player controller? Another actor that already existing in the world? Thanks!
There are tons of ways to do it. You can use get all actors in the class, do traces, pass the reference from the owner, casting, instancing variables, and many more.
The answer to which method to use depends on how you design your blueprint communication.
I recommend watching Mathew Wadstein’s course on Blueprint communication. It teaches you all the fundamentals you need for this issue. Blueprint Communication Overview - Blueprint Communication (epicgames.com)
Thanks for the replies and advice. For this particular situation I had a thought at work to define the static actor in the game mode blueprint (as I’ll only need it on this particular game mode), then in the Behavior Tree Task, cast to the game mode, just as I’ve successfully done with the player controller in other situations, to get my reference. Now I can move my static actor and have the AI move to its location no matter where I put it.
And to further elaborate on the topic, I found this documentation that my help others who stumble upon this thread in the future. Reading, perhaps I change my solution to reference base on the level blueprint and not the game mode blueprint.
Ok, I feel extra dumb now, but I’ve gotta simplify my earlier, overcomplicated solution.
I didn’t need to do anything on the game mode at all, or the level blueprint, or anything like that. I just needed one node: “Get Actor of Class”.