@ExpectedYou (ExpectedYou) posted a new topic, subject "Ai Moveto cant find the target actor?". It read:

   Ive been working on a project where the Hunter of HunterActor spawns in and scans the area for an apple from the AppleActor. The scanning works but for some reason my AI MoveTo doesnt  
    I wish to make the pawn Hunter go towards the Apple and collide with it. (Yes, I have put navmesh around the area for the AI to work)
    
    Heres a picture of the AI MoveTo blueprint in the level blueprint:  
    
    
    image1121×380 96.1 KB
    
    Heres a picture of the Scanner blueprint in the HunterActor blueprint:  
    
    
    image1000×497 118 KB

So @aliemci (aliemci) replied

    I don't know if cast works. Alternatively you can drag and drop your apple actor into level blueprint.

After which, @ExpectedYou (ExpectedYou) added

    It didnt work
    
    Its only supposed to hunt the specific apple it finds first with its scanner
    
    I also have to say that there are multiple apples and hunters in this projects spawning

@Fuchsnerichen (Fuchsnerichen) replied

    Where do you set the Hunter?  
    (you cast to the cast but I can't see where you set the variable)

@dorusoftware (dorusoftware) replied

    I think you need this node
    
    docs.unrealengine.com
    
    ### Get Actor Of Class
    
    Get Actor Of Class

@ExpectedYou (ExpectedYou) replied

    The hunter variable is an object reference to the hunter pawn

So @ExpectedYou (ExpectedYou) replied

    Where should I use this node?

After which, @dorusoftware (dorusoftware) added

    in place of the cast to class node
    
    but only if you have one of those hunter actors. the node will find the first in the scene. which may be not what you want

After which, @ExpectedYou (ExpectedYou) added

    Unfortunately I need all of the hunters detections 
    
    there are currently only 3 hunters but since this is a sort of “evolution” project which means there will certaintly be more afterwards

So @dorusoftware (dorusoftware) replied

    well then find a way to keep track of them. if you spawn them at runtime create a list variable or similar and add them there. or, if you add them manually inside the scene then create a public list and drag the scene actors in that list so you know about them in the scene

@Fuchsnerichen (Fuchsnerichen) replied

    If the hunter spawns, I assume you use “spawn actor from class”?  
    Because from there you can possess the pawn (either player controller or ai controller) and set the variable to the possessed pawn. From there on, you can use the variable

After which, @ExpectedYou (ExpectedYou) added

    Already tried this before, did not work sadly

@ExpectedYou (ExpectedYou) replied

    I dont think this would be necessary since I am checking if a certain hunter detected a certain apple. I do sort of have a list where I know where every hunter spawns in coords but I dont really know how creating a list would detect these kind of things

@JVStorck (JVStorck) replied

    casting is a heavy operation, doing it on tick in the level blueprint is not good. Since the hunter is the actor that will see the apple and then move, he can trigger the movement himself.
    
    try this, when he sees an actor he checks if it has an apple Tag. if thats true the hunter gets the controller thats controlling him and triggers the movement to the seen actor, now that he confirmed its actually an apple.
    
    Untitled-11080×405 75.2 KB
    
    if you dont know how to put tags in actors you can see this video

@dorusoftware (dorusoftware) replied

    if you are using AI unreal has all sort of specialized components that are made to be used to detect stuff in the level.
    
    so if you have a hunter that needs to detect an apple and then you need to know about it i think this can be done using the AI tools as those are made to avoid writing repeating tasks to check every frame if an apple was found or not.
    
    docs.unrealengine.com
    
    ### AI Perception
    
    Documents the AI Perception Component and how it is used to generate awareness for AI.

Then @ExpectedYou (ExpectedYou) said

    This one was close, They dont move but they do however find the apple due to the “actor has tag” giving out true:  
    
    
    image1113×557 20.5 KB

@ExpectedYou (ExpectedYou) replied

    Well I figured out how to get information of the apple but now the apple needs to be hunted by the Hunter. Ive found out that the AI MoveTo cant make the Hunter move.
    
    I assume its something to do with the pawn itself or that it doesnt get the controller but idk

So @dorusoftware (dorusoftware) replied

    for the MoveTo to work you need a character. Like the standard character that is included when you create a third person project. It has all the components required by the AI to move the character. Also you need navigation data in the level

After which, @ExpectedYou (ExpectedYou) added

    How do I add that mannequin to my project?

So @dorusoftware (dorusoftware) replied

    I don't know. Try creating a new project and then migrate the character from there

To which @ExpectedYou (ExpectedYou) replied

    I could not find any difference between my pawn and the mannequin however I did try to change my Hunter to a character instead of a pawn which did absolutely nothing.

@dorusoftware (dorusoftware) replied

    when you opne your character blueprint in the top right corner what class is listed as Parent Class?
    
    Do you have Character there?

To which @ExpectedYou (ExpectedYou) replied

    

@dorusoftware (dorusoftware) replied

    have no idea then

After which, @ExpectedYou (ExpectedYou) added

    SOLUTION:
    
    The problem wasnt because it was a pawn or character. The problem was how the actor was spawned. I spawned the hunter in by doing the “Spawn actor from class”
    
    I found in this youtube video: How to Setup AI Spawn Actor in Unreal Engine 4 - YouTube  
    that the correct node is called “spawn AI from class” this is to give a spawnable actor a working AI.
    
    CONCLUSION:  
    If youre gonna spawn actors and want to give it an AI at runtime then do “Spawn AI from class” and not “Spawn actor from class” as the second one only spawns as solid objects.

@Fuchsnerichen (Fuchsnerichen) replied

    Or you use spawn actor from class and within the AI set “spawned or placed in world”. Default is “placed in world” so the AI does nothing


{'source': 'discourse', 'url': 'https://forums.unrealengine.com/t/ai-moveto-cant-find-the-target-actor/589924', 'title': 'Ai Moveto cant find the target actor?', 'views': 285, 'has_accepted_answer': True, 'word_count': 965, 'like_count': 2, 'reply_count': 12, 'participant_count': 5, 'posts': 26, 'tags': 'question Blueprint UE4 UE5-0 AI', 'author': '@ExpectedYou (ExpectedYou)', 'participants': '@ExpectedYou (ExpectedYou), @aliemci (aliemci), @Fuchsnerichen (Fuchsnerichen), @dorusoftware (dorusoftware), @JVStorck (JVStorck)', 'image_url': ['https://d3kjluh73b9h9o.cloudfront.net/optimized/4X/9/7/4/974bdc541dc09833b36a1d584352911e352ae812_2_1024x347.png'], 'created_at': '2022-06-25T06:58:22.567Z', 'last_posted_at': '2022-07-02T06:04:20.184Z'}