hello, i need help to understand the ai perception and pathfinding in unreal. I made a behavior tree service for the enemy if the player is in certain ranges, either the enemy will shoot or melee attack. I’m trying to figure out how to see these different ranges in the debug menu or im not sure if i have make a blueprint just to see theses set ranges?
Hey @ybenjamin0!
I’m not sure about the debug menu for this. I know it can be used for a lot of things, but I don’t think a visualizer is one of them. I’d just add two sphere collisions (Set to ignore all) that are the appropriate size and activate “Hidden In Game” and “Visible” when necessary. Extremely low overhead and easier to remember as it’s on the AI’s base blueprint.
Hope that helps!
Do i need to code into the range blueprint service to reference the sphere collisions as well? Or reference these ranges with pawn sensing can work better? The ai perception and path finding for my enemy can be inconsistent at times. The path finding and perception detects when it can see the player and in certain ranges, but sometimes it won’t. Even the path finding when i play and see it through the debug menu, it breaks up whenever the player moves to certain location. Then the enemy can detect it sporadically and not consistent all the time, unless the player is right next to the enemy.
Nope, none of that! Those are different problems.
Adding the spheres with NO collision is the point: It’s just to show you what the ranges are, and if “Hidden In Game” is False and “Visible” is true, you can see them while playing the game.
It’s just a little method to visualize the enemy’s sense distance.
If you want something more direct you could also use a line trace that only returns pawn, with a distance of your maximum range on it, drawn from the enemy’s “eye” to the player, on tick.
These things are very low overhead (nigh negligible) so they’re great for testing and can be removed with no consequence once things are done!
The other problems you’re having might seem related and they could be, but unfortunately “Sometimes the pathfinding works and sometimes the perception works and sometimes they won’t” really just says you need ways to gather more information, like the aforementioned range spheres.
I can continue to try to guide you through that process, but one thing at a time, an AI is not a simple thing and you’re doing great to get this far.
Guiding me would definitely help. I’m more of a visual learner, any sketches to explain would help more @Mind-Brain
The end product:
We have a yellow threshold and a green distance threshold.
These are NOT LINKED TO ANYTHING!!!
They’re just debug lines.
They are added directly to the collision capsule (not the root since the root is on the ground)
And the settings here allow you to change many settings of the spheres but typically these would be the only ones you want to mess with, and I think they’re pretty self-explanatory.
To get the radius to match the sense you just have to put whatever number into Sphere Radius you need.
Past that, the other stuff you mentioned need their own threads. They’re individual problems. A good tip to remember going forward: Try to break down a problem into the smallest version of itself and ask for that, because you’re going to get a lot more responses that way! So instead of “How do I do AI” or something like that, say “My character is twitching when using AIMoveTo” and supply video, code, anything you can so we have the info we need to help you!
But mainly, one problem, one thread, at a time, then move on to the next one! Don’t be afraid to post 5 times or more in a day as long as they’re problems to be solved.
thanks @Mind-Brain for your help. Ill definitely asked you any questions when i need help next time
nevermind i figured out how to change the keys. ( my computer doesnt have the numpad key)