Casting Vector Variables to different blueprints

Hi,

Sorry if the formatting of this post is incorrect this is my first time.

I am completely new to programming/unreal engine but I am a quick learner and have basic understanding of code from some work I did with Actionscript 2 back in the day.

So my setup is this:

I have a blueprint called target (which is an actor blueprint). I have placed this in my world and in the events graph placed some code to create a random XYZ vector. Basically I want this target point to randomly generate a new location and every 3 seconds move to that position.

I then want to create an AI mesh/bp or whatever I need and tell it to move to that same target point. What I am trying to achieve is have an AI bot that moves to target points but work with 1 target point that generates new locations on the fly so the behaviour is unpredictable. At a later stage i will tweak the code to check distances and collisions, i’d want it to lerp (still don’t know how that works) so that it doesnt just teleport to each target point etc…

Here are screenshots of my code please if anyone can help, let me know what nodes i should be working with, if i’ve set it up incorrectly and/or if what I want to do is achievable


THIS IS MY TARGET BP which is an actor BP

This is my AI_BP which is also an actor. Notice that the Variable ‘Location1’ is listed as SELF and notice how it is not showing up the variable in the side menu?

Do these actors need to be separate, couldn’t you generate your random vector within the Ai’s blueprint?

Also, look at timers, rather than using tick. Set a timer with a time of 3 seconds, and check “looping”.

If you keep them separate, then your AI needs a reference to the target object. Add a variable which is of the “Target” type (your target blueprint), set this variable to be editable. From this variable you can drag out and get the location vector. If both actors are placed in the map, you will be able to set the value of “Target” in the details panel of the AI placed in the map. Or you could use a Get Actors of Class node to find all the targets and set your target variable to the first one found, for example. But I kind of think it would be best to just generate that vector in the AI, with a timer.

Thank you for that - I havent considered generating it all in the Ai BP.

Am I using the right tools/methods to achieve my desired outcome or is there a better more efficient way to reproduce this?