Download

[Q]A little help with AI: Node: AIMoveTo Issues

Good morning Unreal Community! So, again, I am taking a Game Prototyping class at my school, I have managed to figure everything out, and I am happy to say the game is looking pretty good for a first timer. It is due this Wednesday and I have but only one issue I was hoping someone could help me with. For my BT I have a specific task to have the AI run away on a key stroke, to simulate the AI reacting to fire, being scared by it, and running away. I know that’s a little cheat, but my teacher told me it was alright because it is an intro class. Anyway! I have provided an image to my Blueprint, and it seems to be having an issue actually having the AI move to a random location. I set up a print string on failed to tell me what the issue was. I was hoping to get some feedback, I followed a tutorial, and literally did everything he did, it worked for him but it didn’t work for me. Any and all help would be great!

If you don’t see a “not valid” message pop up, then the movement completed and succeeded OR the cast has failed, in which case the movement would not be run. Does the AI actually move when the key is pressed? Is the RunAwayTask actually connected in the Behavior Tree to a branch that would actually run?

Always make some debug feedback when something does not work.

But first in editor in level preview, hit “P” key. If floor does not turn all green like this, it means you did not added navigation volume.

Now i am watching your graph

Add nodes “IsValid” and check both PlayertorunFrom and EnemyAiController, print if they are valid or not.
Then print that resulting vector Value, or for testing “hardcode” that destination vector to some target area like [500,500,0] put there some mesh to see if enemy will run there or not.
If that AI guy does not run, you either do not have navigation mesh or pawn reference is wrong.

I do get the Not Valid message sadly. He moves when I get into view, because that’s what I have on his BT, but when I clicked G to make him run away, he just stops moving. I’ll try switching it to a branch that has worked already and get back to you. My debug information will be in a reply to Nawrot, thank you again for taking the time to help me!

I apologize for not giving details on my debugging. I attached an ? IsValid to the On Fail that’s on my AI MoveTo node. And it said it wasn’t valid, I then attached the Input Object on my ? IsValid to the Get Blackboard Value as Actor that the Player to Run From is attached to, and it said Player to Run From is Valid. I then attached the Input Object to Get Controlled Pawn’s Return Value, and again it said it was valid. I then attached it to the As Enemy AIControl that’s on my Cast to EnemyAIControl, and it said it was valid. Finally I attached the Input Object to Owner Actor on the Event Receive Execute event and it said it was valid. The task is on my BT and my Nav Mesh is all green. The Enemy AI, when I am in view, runs at me to attack, but when I press G, to make him run away, he just stops moving. When I play the game, I clicked ’ to bring up the debug tool, when I get into his view and he runs at me, everything works fine, the task move to fires, but when I clicked G to make him run away, his active task switches to None and Path Following goes to Idle. I think something is wrong with the AI MoveTo, which is odd because I literally did it the exact same way he did it in the tutorial, and we are both on 4.10. I apologize for asking this, but how do I print vector values?

Print String, attach the vector value to it.

Thanks! So, I attached the print string to the Make Vector Return Value, and it gives an endless amount of X values, but he still isn’t moving. I now attached a Get Random Point in Navigable Radius, set the Radius to 500, and now he is moving, but he is always moving to the same point, even though he is getting tons of different x values, and he kind of spins around. Extremely weird, because in this tutorial (link below) he didn’t do anything of that stuff. And even after the AI moves, and I move away from him for awhile, I come back and he will not chase my character anymore.

https://www.youtube.com/watch?v=4jpACNWcvV8

Sounds like the AI is changing his mind. Constantly. Almost without end.

Any idea of how I may be able to resolve this? It is just so weird that the man who made the tutorial didn’t have this issue and we literally have the exact same set up :open_mouth:

The AI* is* changing his mind constantly. It’s because you can’t reset a vector in a blackboard to a null state like you can an object. Make certain you have the LocationNotDefault custom decorator created correctly, because the BT relies upon that to stop the flipping back and forth as the system freaks out. Also set the vector to 0,0,0 int he begin play of the Enemy AI.

(sorry - rushing to add some insight between other duties. Will check back when I can!)

No need to apologize, you’re doing me a huge favor, especially after providing an amazing tutorial! I double checked my LocationNotDefault Decorator, and it matches what you did in the video. How would I go about setting the Vector to 0,0,0? Would this be placed in the Enemy Character BP or the EnemyAIController BP? Because the noise simulation works perfect, it’s just the running away from the player aspect that isn’t working. I cheated a little bit, just in case I can’t figure this out on time. Since the IsValid? Always says the AI MoveTo and Finish Execute isn’t valid, on my AI MoveTo’s “On Fail” I linked up a 5 second delay, and then I have it set the value as object to none, for PlayerAfraidOf literal name. That way, after he runs away, it resets, and then I can have him attack/follow me after 5 seconds. However, the AI always seems to pick one location, and the same location every time, to run to, and doesn’t run away from me after that. Thanks again for all your help!

I’m an idiot… LOL

I forgot to upload the Tutorial Files to the site once I made the new Course pages. Here’s a link so you can download the project as it was at the end of the tutorial: http://mindlesspursuits.com/ProjectFiles/BasicAI.zip

I hope it helps!