#gameplay-ai
1 messages · Page 52 of 1
I don't think navigation is particularly expensive, most of it is when the path is initially calculated
Yea so I guess if there was a cost related to it, it would more likely be settings on the character movement component? Regardless, seems like more of time is spent in the execution of the behavior tree and even more on just ticks in general. So I should probably look there first
hi everyone! I'm experimenting with StateTrees in my game and I wanted to keep the StateTreeComponent in the AiController (as the BrainComponent) to leverage the existing code in it (and also because it seems more organized this way). The problem I'm facing however is:
- With the component inside of the controller, becomes a lot harder to set tree parameters in the StateTreeComponent compared to when the component is in the pawn itself
- Having the component in the controller, I cannot reference any level actors in the parameters
Does anyone have a good suggestion on how to handle it? Should I just move the state tree component to the actor and have part of the AI in the actor, and part in the AIController (like other components - e.g. the perception component)
anyone?
hi, my AI doesn't play montage
why?
Default slot is set propertly
skeleton is correct
Have you actually profiled and found that the sight sense is causing problems? Or is this a premature optimization? The sight sense has a lot of optimization already built in including early outs and time slicing.
We don't use the parallel composite node, because I find that a service works better in nearly every case. However I have never actually needed to have two behaviors run at the same time and put them into the tree, if that makes sense. If an NPC needs to move while attacking, that's in the attack ability and not the BT.
There's a built-in plug-in called Common Conversation you might want to look at instead. It uses some of the BT tech to build a dialogue tree, but it'd be a much better option. There are also marketplace plug-ins that you can try. Building a dialogue tree using a BT is going to be really painful.
Dynamic navmesh is more expensive performance wise. When the geo changes only the tiles affected will be regenerated, but any path through those tiles are invalidated.
I need to try common conversation sometime 🤔 I replaced my janky BT-conversation with FlowGraph which works better
But at least out of the box I don't know if flowgraph is entirely ideal for it either
RVO is only the avoidance part of BOIDS.
What debugging have you done?
alright might be too much oversimplified but how exactly you add avoidance for non-Character Movement Component?
If it was possible by design I'd like to use BT as controller itself so I like parallel composite option more, gameplayframework makes other options more available
You have to build it into however you are doing your movement.
New to this group. Was wondering if anyone has some resources that lead me to the answer to having vehicles turn naturally? My main use cases are vehicles (think cars) and aircraft (jets/helicopters). I'd just like them naturally rotate between each target point instead of just direct line of sight. Any help is appreciated.
But only when that happens right? not constantly?
Correct
i have a playable character that i created its for a 2d fighter game and i want to test things in game on a dummy character i tried to duplicate the character but it seems to be working
what would be the best method for testing in game systems
It's possibly premature optimization... but... I've found issues in the past where I didn't worry about optimization and then when it became a problem had to go back and design something completely differently and literally start over and wished I knew the better way to do it in the beginning. I don't need the sight to be checking on every frame so I'm just wondering if there is an option to reduce the frequency. Sounds like the answer is no so I'd need to build my own thing if I want that.
It is premature optimization. This is why you profile early and often, so you are optimizing what actually matters instead of guessing.
Contexts have overrideable functions, one of which is to provide a single location.
Is there an AI question you have?
Thank you, it makes more sense now
Anyone?
just watching the AI with Blueprints course to see if i am missing anything or not.....
and one thing caught my sight..
he was using Perception Component directly on the AI Pawn,
i am there is nothing wrong in it, but its my first time watching anyone using Perception Component on the AI pawn...
so is there any reason for this? or its same whether we use it on controller or pawn?
You should use it on the controller. I think there's an error now if you use it on the pawn
ok, Thank you...
this kinda confused me
wait so if i want my AI to move and shoot at the same time, i should make a separate Task for that?
as till now i have been using parallel node for this behavior ...
You can do that if you want. That's not how we set up abilities, but that doesn't mean it's the only way to do things.
oh ok. so its like a personal preference thing, like how we want to handle the task(different for everyone)
was asking just to know if there was a better way to do this...
It's not so much personal preference. It's what's best for the project and team. I work on large games with many different types of AI. So my BTs are agnostic to the types of attacks they can do. That's better for the type of game I'm making. That's not necessarily the best for the type of game you are making.
will i agree with this...
things changes from project to project and working solo vs working in a team..
A question how do you exactly replace avoidance system with your own and make sure UE picks your own derivative?
I need to replace all these
There is two ways to access RVO system
that is Movement Comp and Character Movement Comp
No 3rd way
all internal
other way is making own Avoidance Manager but the question is where it is to make it call your own derivative Avoidance Manager
didn't saw anywhere at UE?
You may be out of luck. A lot of these systems are heavily integrated into CMC and such. Your best bet would be to look where the engine initializes the builtin avoidance manager and see if it actually pulls the class from some property you can change
If it can't be changed, you may have to customize the engine code or roll your own CMC and such
Hi Guys
I'm trying to spawn NavMeshBoundsVolume and RecastNavMesh during runtime using c++. I want to do it because my AI agent can be spawned in various locations on large map. Making NavMeshBoundsVolume big enough to contain whole map would be very computationally expensive. I was using this code to spawn NavMeshBoundsVolume:
FActorSpawnParameters SpawnParams;
FTransform NavMeshTransform = FTransform();
NavMeshTransform.SetScale3D(FVector(100, 100, 20));
NavMeshTransform.SetLocation(FVector(4480, 11360, 530));
ANavMeshBoundsVolume* BoundsVolume = GetWorld()->SpawnActor<ANavMeshBoundsVolume>(ANavMeshBoundsVolume::StaticClass(), NavMeshTransform);
UCubeBuilder* CubeBuilder = Cast<UCubeBuilder>(GEditor->FindBrushBuilder(UCubeBuilder::StaticClass()));
CubeBuilder->X = 200;
CubeBuilder->Y = 200;
CubeBuilder->Z = 200;
CubeBuilder->Build(GetWorld(), BoundsVolume);
BoundsVolume->BrushBuilder = CubeBuilder;
The problem is when I start simulation it is spawned and I can see it in outliner but I can't see it in scene. There is nor bounding box of this volume nor green texture on ground in place where this actor is spawned. I can also tell that it doesn't work because my character which can travel using NavMeshBoundsVolume which was added in editor can't travel using NavMeshBoundsVolume spawned in runtime. I did set Runtime generation to dynamic in navigation mesh.
Not 100% sure on this as I've not really done levels that large, but people do mention navigation streaming so maybe that's something you should be looking at rather than generating navmeshbounds at runtime
What do you mean?
Why would a function have a built-in function?
(I know simple move to is just a K2Node!)
Okay, this is something completely different than your original comment
Also, what Laura said.
Is there a way to get vertices of a nav mesh?
C++?
it would give you every face?
not just like bounds or something?
assumed they would come hand in hand
all I want to do is dump the mesh to an .obj
I think it does, might be like On Path Completed or something like that.
It's been awhile since I've looked
Just explore the component
That's the character movement component, not the path following component
I don't think it can cast your player controller to an ai controller any more than you can
The class hierarchy isn't there
Look at the else branch which handles the case where it can't cast it
I've neaver heard about navigation streaming. Could you provide any link?
Ah I see it does both. Thank you
I believe that function doesn't work in a packaged build when debugging is disabled.
Yes, but only in C++. I'm not sure what you are trying to do with a nav mesh bounds volume, but that's not the nav mesh. The bounds volume only defines the area where the nav mesh will be built, it's not the actual nav mesh.
Ah. I assume the nav mesh is built as the game itself is built, as in it’s not like I could extract the nav mesh from a .uasset?
Making a nav mesh bounds volume for a large map isn't actually computationally expensive. It's just a bounds volume.
I do not believe you can add new bounds volumes at runtime without making engine changes. However any changes to the bounds volume(s) requires a call to the navigation system: OnBounds Updated.
Generating a nav mesh is what is expensive, which is why it's not usually done at runtime.
The nav mesh is built when you use the build paths functionality. You can extract the data from the nav data, but it is not exposed to BP.
Do you know of any existing plugins to extract the nav data? I found one for ue4 but it’s not updated for 5.3 https://github.com/hxhb/ue4-export-nav-data, I’ve attempted to update it but get several error messages I haven’t been able to figure out. I presume a significant amount of the backend was changed between the two versions, and so it might actually be easier to remake the plugin from scratch
I doubt much has changed in the way of navigation mesh stuff to be honest
Why are you trying to extract the nav data?
How it's saved changed with 5 with world partition.
Yeah, that part. But the stuff Mophead is trying to examine, doubtful
I don't see how extracting it will tell you how it's built better than just looking at the code.
But getting to that data has changed
Yeah probably doesn’t make much sense without more explanation on my part. It’s a bit of a long story but I’m convinced that the mesh seen in the viewport doesn’t match what’s used in game. I just want to extract the mesh to prove or disprove my theory.
You know it's not an actual mesh, right?
There are some bugs with the visualization of it but 95% of the time it should be displaying it correctly
Wdym exactly?
It has vertices, edges and faces does it not?
If it doesn’t it would be the first game engine I’ve seen which doesn’t
The nav mesh also isn't how they move exactly. A path is built as a set of waypoints and it's moved by the movement component.
And what data structure do these waypoints use?
FNavPathPoint
To be fair, I did say "not much". So as long as it was a big refactor, I can still be considered correctish
I mean that it's not what many people think of when they say a mesh. You'd have to extract the data and then draw it if you wanted to see it outside the engine. I don't believe that the data structures used are the same as a standard mesh.
I would recommend looking into the debug drawing functionality first, because as zomg said it's not actually precise.
Why do you have an AI controller owned by the player controller?
Why would you want client side prediction for pathfinding and behavior tree?
Hey guys, im new to ai and Im trying to test the decorator but the print not work at all how can I call the decorator?
Client side prediction is mostly for making the local player feel responsive to input. AI do not have local player input.
If you have 10 players how would you even decide which AI is local to each player? You can't have them local to all of them.
Why does the local player have an AI controller?
You don't directly call the decorator. The BT component does it for you. Is the tree running?
That's not how AI works. There is no client prediction built-in to the AI functionality as it's only run on the server.
The movement component has prediction built-in to it. It doesn't magically work. The path following component doesn't actually move the pawn, it uses the movement component to do it, so all the prediction is done by the movement component.
There is no prediction with the path following component either
Because non player characters are server owned actors
The AI controller won't even spawn on the client
It's not arbitrary. Players are the exception, not the rule. Anything that's not a player is server owned
Player bots are server owned actors
Yeah the tree is running except decorator
Lol
Is the task that's under the decorator running? Have you tried to use a breakpoint?
oh ok btw the under decorator was running
im not familiar with ue5 breakpoint soo.. yeah
Ok good. Sounds like the print just wasn't showing? Which is what I was hoping for.
Yeah exactly
when I tried to received that event via Perform condition check it wasn't work well, am I have to use blackboard to use any decorator?
The only reason for possesing pawns by AI player is to use AI functions and features right ?
/imagine car
Version: 3.1.1
Last Login: <t:1710812574> • <t:1710812574:R>
Heartbeat: 73ms
Memory Usage: 88.44 MB
—
Source Code • Report a Bug • Contribute
Hey, im checking if a bench is available and assigning it for an npc to sit on it and i use a Native MoveTo task to reach the bench but if i block the npc and the MoveTo task fail the bench is already assigned and i dont know how to unassign the bench since i can't modify the Native MoveTo task to unassign the bench if failed.
I need the native MoveTo cause it have cool feature built in in cpp
Any idea on a better way to process the action ? Or React in an other way to the Task failing ?
@harsh storm Hello! I've been on an adventure to find out how to modify state tree parameters, and I stumbled on your messages from 2022 haha. I saw you managed to have it working somewhat, I was wondering if you ever found a better way? At my previous job we also had a system for modifying state tree parameters, instead though we modified them inside state tree tasks themselves rather than outside of the state tree - our company has since closed and neither me or my colleagues who made the system remember exactly how we accomplished it 😄 So here I am on a new journey to recover the lost knowledge
In a sense, I also have the same interest as you once did - to make state tree parameters to operate as a blackboard of sorts
Honestly, a dumb idea and it's deifnitely better to store those variables elsewhere but still
Nah, I didn't investigate much further because the editor was too buggy for me back then. Bindings kept getting lost and I couldn't set them back up unless I created a whole new state tree. But my goal also wasn't to have the ST itself update the params. I very specifically was curious how we could update the params from outside of the ST. Most of my reasoning stimmed from figuring out how to notify the ST about something with AIPerception. But because of the editor buggyness, I just dropped it and stayed in BT and/or custom state machine.
StateTree does seem to have potential, atleast for me, but rather troublesome to get started with so far
Currently using a custom score based task system
I just use my own state machine personally. It's not all that difficult to build a rudimentary one.
Does it handle ~5k checks per frame? 😅
Guess one can allow for some frame slicing , but not to much
I dont really need that many checks , was mostly stress testing it to see a 'worst case scenario'
Idk, never checked or cared; because my state machine's are only used for boss enemies.
In which case like...3 might exist at a given time.
Sounds like a troublesome boss
I see. Yeah, especially since you were doing all that State Tree stuff back in 2022, and I would say only now they are kind of "usable". We also had the problems with bindings getting lost but those were Epic bugs, which they fixed in the next engine upgrades
We basically had to stay super up to date / backport state tree changes from unreal branches in order to fix those bugs
Hi guys, My AI shoots through walls, basically i am checking the distance to player for setting the IsInGunRange bool and i also have a strange behaviour were the AI simply forgets the player and romes around. THIS AI IS BUILD ON TOP OF EPIC'S AI TUTORIAL PLEASE HELP
Sorry that it took me a while to get back to you on this. But I see you found an answer already! So with the PropertyRef, were you able to use the child state setup or multiple task in the same state setup? In my case, I wasn't aware of that setup, so I had a boolean flag informing that the results were ready in one task, and the next one would keep checking for that boolean, even though like you said they were running in parallel. But your solution seems to be very nice! Good find!
Interesting. We have done a similar setup with my previous team in our project, basically if I am not wrong running the query is also async? You can prevent the task from finishing the state by having a tick checking some condition for whether the query results are ready. Same with the MoveTo task, you only return success inside that move to task once the pathing has been done (keep checking some condition on tick as well). Is that how you are doing it already?
And yes you can't have both running the query and move to in the same task. I'd make them into 2 separate states as well and don't make one be a child of the other
ooo very nice. RHI thread parallelization is massive as well, huge perf gains
Yeah, I saw that they said the parallelization has done like 50% perf improvements to the city demo 🧠
I have a character BP that spawns 4 more characters, all the same character bp, but different meshes etc. When the game starts, I get 1 player character and the 4 alternatives fine. I can run around and they follow me. All follow code is simple AI Move To at the moment.
If I switch characters using "Possess", the new player runs around fine, but the old one stops moving and seems to never get an AI controller.
If I add "Spawn Default Controller" to its Event UnPossessed, it starts moving, although only at walking speed, but if I keep doing this and switch characters a bunch of times, I end up with lots and lots of AI controllers in the scene.
What am I doing wrong here? There must be a way to turn back on the old AI controller after it get possessed and then unpossessed again?
Yes, but you need to keep track of your controllers
Eg. when the char is possessed by an AI Controller, save it in a variable, so that next time you don't need to spawn a new one as you can just repossess using the one you stored
Thanks for responding. I actually just got that working after realizing Possess isn't just for the player but can possess with an AI controller. Now I have a small bug with the first player character because it doesn't spawn with an AI controller. I'm sure this is a simple fix though.
Good for them.
Use a service to clear and instead of using the tick function, use the on receive deactivation function.
You are only checking line of sight once and then looping the shooting task. Why are you looping that anyway?
Also looks like they're adding proper subtrees to statetrees 🤔
No the line of sight is actually checked every frame by on Target perception updated is it that's why it used or am I wrong
thx
In NavLocalGridData.cpp I don't understand what PostProcessPath which gets called in FindPath is supposed to do exactly?
I would think in an uninterrupted path that it should include the PathIndices but it does not, instead it wants to only reference them if their is an obstruction. But the returned processed PathCoords with no obstructions is just the Start and End coord which is not the path to go from Start to end? @uneven cloud or @celest python Maybe some insight?
can we create a blackboard key as type Vector Array using UBlackboardKeyType?
i am going to try it, but thought to ask first ..
but its looks like a long task....
i have to add getters and setters both in Blackboard component and BTFunctionLibrary....
so i proceed with it?
or is there any other way for this?
@neat summit @latent geode I have the EQS and the Move task as sibilings, seperate states
The EQS task just checks on tick if it's done, and returns succeeded when it is. It then transitions to the NextState, MoveTo.
The FStateTreePropertyRef allows me to bind to a variable and change it from within the task. That variable can live in the parameters section of a parent state, the parameters of the whole state tree, or anywhere else you can access parameters.
The RefType tells UE what types of parameters it supports binding to.
That PropertyRef is also supported in blueprint. Pretty neat stuff.
Woah woah are you saying you can modify actual default state tree parameters using that? And what is that FStateTreePropertyRef struct, I've never seen it before and i can also see it's not a part of the engine?
And if you are modifying actual state tree parameters from within that task, could you share that code please? I've been trying to do it with an InstancedPropertyBag but no luck
Yes, and I guess it's in 5.4 or 5.5
I'm on ue5-main
I'll get the code
Because I know it's possible, me and my colleagues have done it before but we don't have access to our source code anymore lol, and no one can recall exactly what we did
Isn't that the stable branch? Or do they push stuff that is beyond 5.3.2 on there?
It's not supposed to be stable, but it's been shockingly stable for me for a few years
Here's how you use it in blueprint
That is.... Unbelievably handy
Here's a vid showing how I'm using the same thing but for Vectors/Actors, just like in the c++ screenshot
But can you do that with the default parameters that are on the left hand side
Yes
As well as evaluators
Sick, are you hosting your project on GitHub or something? Will also play around with this stuff in Lyra, convert their bots to use state trees and etc..
I will need to pull that branch I guess since I need that FStateTreePropertyRef stuff
Not hosting this projecto n github, but if I find the time, I'd love to make an example that uses state tree for AI and SmartObjects, since the LyraExplorer update that has those isn't coming with 5.4
This property reference shit is massive for state trees
Yeah, it's kind of a pain to do data fetching and using otherwise
And just in general state trees just need a blackboard
Nice :)
I am so surprised that they didn't put them in the engine along with some sort of blackboard
Here's how it's used. In this example, the ref can be a vector, actor, or an array of either.
EStateTreeRunStatus FStateTreeRunEnvQueryTask::Tick(FStateTreeExecutionContext& Context, const float DeltaTime) const
{
FInstanceDataType& InstanceData = Context.GetInstanceData(*this);
if (InstanceData.QueryResult)
{
if (InstanceData.QueryResult->IsSuccessful())
{
auto [VectorPtr, ActorPtr, ArrayOfVector, ArrayOfActor] = InstanceData.Result.GetMutablePtrTuple<FVector, AActor*, TArray<FVector>, TArray<AActor*>>(Context);
if (VectorPtr)
{
*VectorPtr = InstanceData.QueryResult->GetItemAsLocation(0);
}
else if (ActorPtr)
{
*ActorPtr = InstanceData.QueryResult->GetItemAsActor(0);
}
else if (ArrayOfVector)
{
InstanceData.QueryResult->GetAllAsLocations(*ArrayOfVector);
}
else if (ArrayOfActor)
{
InstanceData.QueryResult->GetAllAsActors(*ArrayOfActor);
}
return EStateTreeRunStatus::Succeeded;
}
else
{
return EStateTreeRunStatus::Failed;
}
}
return EStateTreeRunStatus::Running;
}
And this is the InstanceData.Result, that the MutablePtrTuple comes from
// Result of the query. If an array is binded, it will output all the created values otherwise it will output the best one.
UPROPERTY(EditAnywhere, Category = Out, meta = (RefType = "Vector, Actor", CanRefToArray))
FStateTreePropertyRef Result;
I don't understand your question. An unobstructed path just has the start and end locations, because that's all it needs. It's been a long time since I've dug into PostProcessPath though.
My god, this is everything I've ever wanted lol, took them long enough
They're also adding proper subtrees to state trees in 5.4 which seems like a great feature
but then again, just ffs introduce a blackboard for state trees
This is essentially what this is anyways
It seems the reason it works in this way is for optimization purposes but I can only speculate
Like... You can specify state tree assets inside another tree? Like you can with behavior trees?
Yes
It's listed as beta I think so not sure how stable it's gonna be but at least it's a step in the right direction
For sure. Ahhh, it's a pity that our team just started reworking everything into state trees too early as soon as 5.1 hit (where they were deemed "production ready"), but oh boy let me tell you, they were not 😔
We ran into all these limitations, and they are only getting resolved just now
Yeah
I only used it for testing since 5.3 and while it seems to work pretty well now it did have a lot of cases where the behavior was just very confusing and undocumented
Imo state trees in their "perfect form" are definitely superior
Just the concept of transitions alone puts it above, not having to re-evaluate the entire tree if some decorator condition is not passed just to get to the right place, that alone is a massive advantage.
it performs string pulling
Hi, my AI is behaving strange when i package the Game. It seems like the Pathfinding is off. My enemies which are perfectly able to find a path around walls in the Editor, are getting stuck in packaged game. I have a Drone that is spawned by my character and just follows him. In editor no issue. In packaged game its floating randomly around. The drone just moves to the owner. BB key owner is set and valid in the packaged game. It draws the debug sphere at his location but does not move to him, instead moving somewhere. Anything i am missing with AI, Navigation and path finding when packaging?
What type of package build are you testing? A development packaged build will still have debugging turned on so you can use the gameplay debugger (apostrophe while playing) to see the BT and pathfinding debug information.
You might also want to try and delete any recast actors and in the world outliner and rebuild paths. Sometimes the nav mesh just weirdly breaks.
tried shipping (because thats the only way my gamepad works) as well as development. I already deleted the RecastNavMesh, created everything from scratch, played with some options for the navmesh...nothing helps. This cant just be me. Or i am doing a extremely dump error
I even disabled the Behavior tree and just used a simple AI Move to Task. Same outcome...so its not an issue with the BTT or BB, it has to be something withing the Navigation/Pathfinding
YO
was thinking if anyone worked on cover AI kinda like The Division ?
i have a couple of doubts to ask..
I used to. I used smart objects (i.e, you have predefined cover places around the environment that you specifically place), and then you code all the "take cover, crouch/uncrouch" logic inside the smart object itself
that what i am doing....
all the covers are hand placed..
So how do you search the covers ?Or like what are the conditions for cover searching >
Well, you can always do an EQS query that will get you the nearest cover smart object
I think smart object system also has its' own way to search for them as well, need to look into the documentation again
As for the conditions - that is completely up you. Like, at what point do you want your AI to start looking for cover? Can be anything, low health, low ammo, that can even be the default behavior when they are aggro'd, and then fallback to some other form of fighting if there are no nearby cover smart objects
I personally like the last suggestion the most, but it's always subjective
Is Event graph disabled in blueprint is AI possesed it right ?
I update speed in event for blueprint so animation can play
for condition i mean to say how will AI select a better cover?
That can get difficult. Again, up to you for how you want the AI to decide which one to take. I personally would not complicate this and make a small system for detecting whether the cover is partially or completely destroyed. I would not try to make difficult conditions for AI to choose which cover suits them the best, I would just make it random. And of course, smart objects already have the "reserved" system implemented so they should not choose covers that are already selected by other AI.
If the cover is destroyable, always keep track of how destroyed it is, and when it reaches a specific destruction threshold, you can send an event from that smart object to the AI agent that is using that cover - the AI agent gets that event, queries for another nearby non destroyed smart object cover - if there's none, again, fallback to another mode of fighting
That should be good enough?
my prototype doesn't have destructible cover,
and as for the cover search
i am doing in this pattern and choosing the closest cover to AI and player and ignoring the already taken covers
I have 5 characters that all use the same BP class but have different meshes and animations. One of them is set to the default pawn, but in it's Begin Play it spawns in the other 4 and stores them all in an array that it shares with everyone so they all have a list of each other.
Using the Possess node I can switch between each character by pressing keys 1 to 5 and the ones that are not being controlled are set to follow the main player. This all works, except when I first start the game, the one that is set as the default pawn gets the wrong movement speed after it's unpossessed from the player controller. If I switch back and away again, it starts moving at the correct speed?
Any thoughts on why after possessing another character the original moves so slowly?
Hello, Is there a way to access a key from the BT in my AIController class?
I have a task that sets the Direction the AI is walking in but I don't know how to actually pass that direction key to my AIController!
Iirc you can get the blackboard and get value as object from that bb key.
how do i actually get the key tho from my AIController?
i need to get the direction key to update my direction vector
Hello everyone. I was curious if any AI guru can advise me on NavLinks. In the first image the nav link is set up and ready to use, however, if I drag the left position further away from the box, the NavLink is no longer useable. Does anyone know what is controlling this? I have delved into the NavigationSystem and RecastNavGenerator, but to no avail. Is it based on the agent step height? Sorry images, are in reverse. Right is working, left is not.
Like @dense owl said. You get the blackboard (which is a function) and then get value as (which is also a function).
Why are you calling move to on tick?! This is not how to use a latent function. I also don't understand why you are setting the direction in the blackboard, as that's an easy thing to figure out.
No it is not based on step height. You'd have to dig further into the generation code to find out where it's failing at.
@uneven cloud Yeah, digging into it it might be Id related? Still working on it. Also, in this situtation I posted earlier, I ended up looking at the NavMesh tiles and when I pulled the NavLink back onto another tile, it would disappear. Do you know if NavLinks only work on neighboring tiles?
Ids are for smart links. You are using a point link. No nav links don't just work on neighboring tiles.
@uneven cloud Yeah, sorry, it is a SmartNavLink with my own custom component. Hmmm, then I am confused.
The pictures say point links.
@uneven cloud So I am using my own derived ANavProxy, using the point links to determine where the smart link points are by copying them, and then using the bSmartLinkRelevant flag on.
I would first check to make sure it isn't your custom logic that is broken.
@uneven cloud My custom logic has nothing to do with the rendering or the path. It is simply listening for when the SmartLink has been reached by an agent.
If that is all it needs, then how does one use the information to draw out the path? You'd just highlight for example the start and end not a path from start to end. That said, I think I've re-written it to suit my use case I just don't get the original intent.
Why is Unreal clipping the navmesh through the stairs so poorly? It's like a multimodal failure where 1) the navmesh can't find a connection from the top floor to the top of the stairs, so it leaves an inset (incorrect), 2) the navmesh generation recognizes that it should connect the stairs to the top floor, but because it is inset, it clips through the stairs (incorrect). As a result, NPCs can go up the stairs, but as soon as they try to cross from the stairs to the top floor, they decide it's impossible and try to find alternate routes
Hi All, quick question, can I use RVO and Crowd Detour at the same time?
hello I have a problem launching the games I created it tells me that I do not know how to build a game for win64 while I have a great pc
Afaik you shouldn’t
Start in #rules
Yeah I finally got it to work, thanks for the answer
I need to send a reference of a BTTask as self to the controller so the controller has a reference of current running task, ive done this before but forgot. Can anyone advise?
☝️ by using an interface message
Why do yoy need to know the current running task? Shouldbt that be opaque?
In this case i want to trigger an event in that task from the controller.
I dont know. I have an AI controller that possessed the player pawn when the race is complete so it drives the track for a race recap screen before exit. So that task is the default one that all my CPU drivers use to race but so its all running by default but i just need to trigger an event that overrides a bound event that was not assigned because that controller spawns in after the race has started.
Do not do this.
Another reason would be to have ability to finish tasks from the controller using interface messages.
And do what
Event dispatcher (BP) or delegate (C++) on the AI controller.
If you want to finish a task early you can use a decorator or setvice
Yeah, delegate is the better choice if you really want to respond to a gameplay event
Essential for making games that work well.
It is unsafe to make direct calls to bt nodes from outside the BT.
To finish a task early you can also use a delegate. Or a decorator as has been mentioned.
Fine I will go with the event dispatcher, less moving parts, thanks
Greetings everyone, I have a question regarding state tree evaluators. Evaluators can either run on tree enter or on tick, but can they also run on demand? I would like to only run an evaluator on tree enter and if a specific task succeeds (find a target on tree enter and find another target if I successfully destroyed my target). How would I implement that? Should I define a global task instead of an evaluator and call that task once my other task succeeds?
Is it acceptable to frequently change behavior trees during runtime? I wanted to divide my trees into "subtrees" so they're not all in 1 big behavior tree. But I wonder if running a new tree is still performant, especially if I have say 50 AIs in the level.
You can run subtrees
hi, I changed bland space 1D, I just copied the default one and set my animations and I don't know why but the lower part of the body (Legs) AI doesn't move them at all
someone can help?
someone can help?
you might want #animation instead
this is more for the actual AI logic, not animation so much
has anyone tried the improved navmesh generation for large worlds in 5.4? It sounds amazing
nice to see navmesh generation doesn't respect the Can Step Up On property :/
It looks like it does, there’s some over your static mesh
It’s likely just too close so the nav agent can’t fit, you need to make custom ones
I need this MoveTo to abort if the value changes. I think I know why this doesn't work, but I don't know a solution that would
That selected decorator needed to be on the sequence, not the MoveTo
any idea why ProjectPointToNavigation returns false on client every time when server return true?
how to use use blackboard actor as context?
I am facing a navigation problem, Repath works correctly but it uses the old location to regenerate the path, I even tried deleting points but it doesn't help, Repath always re-generates points from where FindPathToActorSynchronously was originally called if the GoalActor changes location
bool AAIPawn::MoveToActor(class AActor* Actor, float TetherDistance)
{
if (IsValid(Actor))
{
if (UWorld* World = GetWorld())
{
if (UNavigationSystemV1* NavigationSystemV1 = UNavigationSystemV1::GetNavigationSystem(World))
{
if (UNavigationPath* NavPath = NavigationSystemV1->FindPathToActorSynchronously(World, GetActorLocation(), Actor, TetherDistance, this))
{
SetTargetNavigationPath(NavPath);
return true;
}
}
}
}
return false;
}
void AAIPawn::SetTargetNavigationPath(class UNavigationPath* InTargetNavigationPath)
{
if (IsValid(TargetNavigationPath))
{
TargetNavigationPath->PathUpdatedNotifier.RemoveDynamic(this, &AAIPawn::OnNavigationPathUpdated);
TargetNavigationPath->EnableDebugDrawing(false, FLinearColor::Yellow);
}
if (IsValid(InTargetNavigationPath))
{
TargetNavigationPath = InTargetNavigationPath;
TargetNavigationPath->PathUpdatedNotifier.AddDynamic(this, &AAIPawn::OnNavigationPathUpdated);
TargetNavigationPath->EnableDebugDrawing(bDrawDebugPath, FLinearColor::Yellow);
}
else
{
TargetNavigationPath = nullptr;
}
}
//On tick i remove point, if AI close this point
float ScaledCapsuleHalfHeight = RootCapsuleComponent->GetScaledCapsuleHalfHeight();
if (FVector::Dist2D(CurrentLocation, TargetLocation) <= 20.f && FMath::IsNearlyEqual(CurrentLocation.Z, TargetLocation.Z, ScaledCapsuleHalfHeight * 2.f))
{
TargetNavigationPath->PathPoints.RemoveAt(0);
FNavPathSharedPtr NavPathSharedPtr = TargetNavigationPath->GetPath();
NavPathSharedPtr->GetPathPoints().RemoveAt(0);
FPathFindingQueryData NewQueryData = NavPathSharedPtr->GetQueryData();
NewQueryData.StartLocation = GetNavAgentLocation();
NavPathSharedPtr->SetQueryData(NewQueryData);
if (TargetNavigationPath->PathPoints.IsEmpty())
{
TargetNavigationPath->PathUpdatedNotifier.RemoveDynamic(this, &AAIPawn::OnNavigationPathUpdated);
TargetNavigationPath = nullptr;
OnMoveFinished();
}
}
Are there different identifiers for each cut off area in the nav mesh? Like if there's a gap or obstacle between them. I ask because I'm thinking I could use an A* pathfinding for AI parkour/climbing if I could just distinguish each separate section of the nav mesh.
Currently I can make my AI parkour using EQS. But it becomes less accurate the more obstacles there are between the AI and the target location
Quick Question : I have problems with my AI enemies ( FPS drops by 2 for every enemy ). So im making a FPS game and all the enemies spawn via triggers. So just running around the level with 0 enemies gives me constant 80 FPS. When I start spawning enemies, the FPS decreases drastically. My enemy actor ( for testing ) has 0 blueprint logic except at begin play it has a command to walk to me. It has no animations, no shadows and is very low poly. Still the FPS drops. When 20 enemies are spawned, it goes to 40 and if you look directly at them, it goes to 30 making it unplayable. Am i missing something here? How can literally any game spawn 100+ actors that chase me and there is literally 0 change in FPS? I must be missing something. Chat GPT always suggests dooing LODs, easier animations, off lumen etc.. but none of those things help in any way. The problem lies in the movement of the skeletal mesh. If they stand still, I get almost no FPS drop, even when looking at them.. this only occurs when they start moving in any way. Did anyone have similar problems? Or am i the only one? Please help if anyone knows what could be chauseing this.. Im running a GTX 1060 6GB and i7-6700. Thank you so much:)
The nav mesh is on the server only.
If you mean an EQS context. Then you make a class that is a child of the EQS context and get the blackboard from the quierer actor
Why aren't you using the built-in functionality?
No there is not.
You need to profile what is causing the perf problems instead of guessing. Look up how to use Unreal Insights.
i did that and the profiler just says cpu stall wait for event and that doesnt tell my anything.. 😦
I guarantee that's not all it says
this is what it shows.. am i missing something obvious?
That is not insights. Also it looks like you are profiling with the editor instead of packaged test build, which you should not do.
oh yeah, as i couldnt package the build i was waiting for 10 hours and it didnt complete but no errors so i gotta i guess try again.. ok ill google up insights and try and learn that . thx
#profiling might have some pinned advice as well.
I am trying to make a horror game with one of my friend and we are having a little problem with the enemy ai, can someone help me with it
Not without you stating the problem, no
well the enemy doesnt stop following the player no matter what
it also follows us if we hide behind walls
which we want but not throughout 50 corners
this is the enemy ai code we put together
Ah - you followed Gorka Games tutorial eh?
- You're using an outdated/deprecated sensing system (PawnSensing). You should be using AIPerception.
- You are always setting the
Is Seeing Playerto true. So the true branch will always execute.
oh thx we will try to fix those two and report back if it worked
@uneven cloud Blog please 🙏
@runic stream Check the first pinned post in this channel and have your friend go through that course in order to actually learn the tools of AI in UE.
ok will do
At no point are you stopping following the player either.
yeah we are both idiots
It's not your fault. Gorka Games just should've done a lot better research before pushing content.
But the YT algorithm is more important
¯_(ツ)_/¯
Gorka enjoyers having problems again? :D
We need a command on the bot like !gorka or something
lol
Is it from a gorka tutorial? Cause I don't see how that could ever work, even in a short video
Yeah - it's his "make a full horror game" tutorial or w/e
He's the main reason for the resurgence of PawnSensing
I suspect it probably works if you set it up exactly like in the video and as soon as you deviate at all it fails
Per usual
so basically for anyone attempting to adapt it to their own project it fails :P
at least Gorka's new videos use AI Perception
Tbf all tutorials use pawn sensing
I want to watch it to better be able to help people when they come in, but I also don't want to give the view. The conundrum
Like I said - push content, doesn't matter if its right; eventually it will be
Anyone using Statetrees?
Having issues with the Statetree just running an evaluator check once
If its hooked up to a blueprint and the evaluator is using things under Event Tick, it should recheck everything, no?
hey so I have an AI that looks for certain objects in my world. currently it destroys the object and then runs an EQS to find the next one. I don't want to destroy the object anymore. how would I make the AI know it has already touched a certain object?
would it be a gameplay tag or?
I currently am setting a bool on the object and using a decorator to check that bool but it doesnt seem to work as expected
Sure, gameplay tags would prly work fine for this. You’ll need to expose the interface
Hello! I have an issue with an AI inside of my game, and I'm not sure what it causing it and I hope someone here can help me how to better debug or what the potential error could be.
I have an AI that spawns in-front of the player, and start running towards the player. In editor (and PIE), this works, the AI spawns and start running towards the player.
However, when I package the game for Windows and play the game. One or two of my AI's spawns but then does NOT move towards the player, and I can't find any reason why this is happening. The same AI works in other places and it works in PIE but not in the packaged game. Does anyone have an idea why?
@uneven cloud i'm using Pawn, with self movement logic
Using the Behavior Tree?
Sorry! Yes I am
Run the BT on possession and not on BeginPlay
Why are you using the pawn for AI behavior? That also doesn't answer the question of why aren't you using the built-in path following functionality.
Tried changing to that, but the AI in this one particular spot still doesn't move. It feels (but I can't debug it since I can't find how) like the nav-mesh is broken in a packaged build but no when player in editor. Thanks for the suggestion though! Since that seems safer anyway. 🙂
In the world outliner, search for it and then delete it. Then recreate the navmesh
Oh, yeah, already did that as well.
I tried deleting both the nav-mesh and the AI and place them again, but still same issue. That is partly why I believe it must be something there. but I just do not really know why.
@uneven cloud What is the built-in pathfinding function? I'm confused, for my AI I use Actor, a movement written from scratch with movement replication based on data extrapolation, since the standard Character is not capable of delivering good performance
Well... it's recommended to use the AI task. Are you not even using the AI controller? You don't have to use the CMC, but you should derrive your movement functionality from the nav movement component and override the functions there.
I see. Would you happen to know how some people were able to setup auto nav link generation? Like detecting the edges of each nav section? That one seems to be related
I am having some slight issues with my Behavior Tree.
I have it finding a certain actor and setting that to the Blackboard, and it does find and set this correctly.
I then have it call the MoveTo and give it the key to that actor, however it is always aborted and then tries to restart the loop.
Yes, you can hook into the navigation generator and get all the edges and do whatever tests you want on them.
you can try pressing P which will show all navigable areas using your navmesh
if that area is green, it's probably not an issue in your navmesh
The thing is that it works inside of the editor (playing in PIE and all of that) and the nav-mesh looks fine there. But once I'm inside of a packaged game it no longer works, and there I don't think P works?
The command Show Navigation in Debug/Test build should work
Will do a test and see if I can make it work!
Hey, I am trying to come up with a positioning logic in which the AI finds a position where there is nothing else between the point and the target(PlayerStart). I am doing this with a trace test. However, the points generated between the courier also get filtered out because it's self in between. So I basically need the Ignore self option for this trace test. Does anyone know a walk around this? And no I can't change the collision setting of the courier, then other AI's would position themselves on a wrong point.
Does Run Behavior use a copy of the same instance of the tree calling it? I guess I'm asking, is there a performance cost to using Run Behavior to structure your tree and avoid duplication?
i would have created a custom eqs test for this....
like copied all the code of trace test into my custom one, and will then add a ignore self option there...
You could create a new CPP test deriving from UEnvQueryTest_Trace. Then add a new Boolean field to your test such as bShouldIgnoreSelf. You can then add the logic you want in RunTest to ignore or not the querier for example
i do the same whenever there is something missing from an eqs test
I did exactly that.
For some reason, it did not let me compile when I created the child class. It was giving an error about reaching protected functions. Which doesn't make any sense to me..
do you have the AI_Module in your build.cs ?
I had I believe. The error was basically telling "you can't reach protected class of the parent class".
can you share the code?
.h and .cpp
I can't, it is gone. I created another class which is almost 1 : 1 copy and on there I added ignore self option. So it is fixed but not with the most elegant way.
Is there a easy way to make an not clump up so much when they move to something to attack it
I've adopted Luthage's approach. Pretty much, use EQS to "claim" a spot around the target. Then have them move to that "claimed" spot.
Ah yea that would be good idea
If there are no spots available, have them do something else. Like go somewhere and taunt or something.
What would be the best way to share the spot info between the ai?
I'm trying to think how to implement it. I know how to do eqs but not sure how to not do it per ai
Awesome ty
You can follow that talking points in that convo
It's not exact because, again, it was thrown together in like 5 minutes
That is awesome and super helpful just glancing at it that makes a lot of sense
I appreciate the help
Sounds like the move to is failing. If you use the visual logger to debug, the navigation errors will be easier to find.
There is a not a noticeable performance cost to it.
Thanks!
Also a flocking calc to use as influence is quick n easy if you have a decent algorithm
probably as cheap as it gets too
Is there a way to smooth out movement? I have a flying AI and it's just a straight shot to each target point, rotate, then on to the next. Left is what I see, right is what I want (sorry for bad programmer art)
This is mostly for airplanes/helicopters, they would bank after hitting their target point in anticipation for the next one
you can create a ticket system for this....
every AI before attacking the player ask for a ticket, if the ticket is available assign that ticket to the AI, and then he will do an action and after that acting it will go back to its initial position and will release the ticket...
and for the positioning i was using donut eqs,
also you can implement a location reservation system, so like whenever AI moves to a point it will reserve that location, and now when another AI search for the location for standing it will search all those points which are x distance form the already reserved location by other AI...
you can store all the reserved location in a globally accessible array ( make a subsystem for this), and use that array to find out locations ...
https://www.youtube.com/watch?v=GiQJw3Mg0qY
this is what i created with using these systems.
Thank you for this. I haven't heard of a subsystem I'll look into it. The problem I had figuring out is how to make all the ai aware of one eqs and what spots are taken and not. This will help a lot thank you
you can make a manager class for this,
run the eqs from the manager class and assign location to the AIs
Oooh that makes sense
But that would have to track every single thing that's attackable?
Wonder if I could have the target have it's spots somehow and serve them out to people attacking it
I have been eyeing this for quite a while in the "indefinite" forward-looking roadmap. anyone knows if this is actually in the works and what will it include?
https://portal.productboard.com/epicgames/1-unreal-engine-public-roadmap/c/1285-navmesh-and-navlinks-improvements?utm_medium=social&utm_source=portal_share
Hi, i need some help with optimisation on my AIs, they are a lot of them (about 95 on the map but i'd say 30 present on the screen at the start). They make the game very laggy and it is because of the movement component and the animations (at least that what unreal insights says). Does anyone have an idea to optimize it?
Use Unreal Insights to find out where the time is being consumed
It's hard to say without information from profiling
so other than player there are also other target ?
can I somehow make EQS debug not get disabled if I unpossess the player in the viewport (e.g hit f8) ?
so I upgraded my project from UE5.3.2 to UE5.4 preview, and now when compiling I get these errors in built-in BT nodes. has anyone had these problems?
Also it seems these compilation error occur for nodes for which I have my own versions where I inherit the UE version and extend it in some ways. It's like the compiler demands me to override every virtual member of inherited nodes even if I don't need to wtf
Have you checked if they shuffled things around to new modules?
the unresolved external symbol often occurs if you are missing a dependency in build.cs
yeah, everything seems to still be in the AIModule
I am getting beaten by hehavior trees
i hope someone can helpe
i want this wait to ONLY trigger once the character is at the END of the spline path i have
instead of, every single time it reaches a spline point :8
The enemies spawn and they attack towards the main base and they attack anything on player team along the way. Things like turrets, buildings, minions
fixed.
I would not recommend this direction. It limits you to making generic tests instead of favouring locations that are best for a specific NPC. Instead of over engineering a subsystem that needs to track every target, you can use a context to get the claimed location of the NPCs allys.
Context? I will look into that
looks like i can make a custom context and set it to the currently assigned target in the enemy AI, but then if multiple AI are attacking this target will they be referencing the same context or different instances of same context. does that make sense?
The assigned target will be a reference, so they reference the same actor instance
If you are getting the target from the quierer, then the target will be different if they have different targets.
It doesn't matter if the context is a different instance.
Okay I think I can figure it out
Hi Luthage, I swapped to Ai perception and it is much better but how do i make it so that when i am in the closet, the AI cant catch me? Please advice me on what i need to add in the BP
for some reason he can catch me when i am hiding. Perhaps there is a way to make my character invisible or a simpler method to go about this?
the reason for the subsystem is whenever an AI claims a location, it will then tell the subsystem to store that location,
and then we can create a context and passes all the claimed locations(which we can directly access from the subsystem) as location set.
this is who i am using it
I was adjusting some project settings for the High fidelity Nav Mesh resolution and at some point I had a crash.
Since then, all my nav mesh displays are gray instead of green and all characters fail (abort) when trying a MoveTo. Any idea what this might be and how one could fix it?
I've tried things like restarting UE(5.2), deleting the NavMeshBoundsVolume actor and the RecastNavMesh actor. Still generates a gray nav mesh that deosn't seem to work with MoveTo
Which is unnecessary to have a subsystem to do that.
Do you have any functionality for when the AI stops perceiving the target?
so how do we get the location of other AIs?
i mean there are so many ways, but what would you suggest?
Yes it continues to roam around the map
You're already storing it in the BB, so you can do an actor iterator over all the AI controllers. If you don't want to directly access the BB, use a function. Your way has so much overhead to set the location, update and clear it.
Are you disabling sight stimulus source when the target is hidden?
How would I go vaout doing that-?
You need to use the stimulus source component. I also recommend disabling making every pawn a sight source in the ini. You can Google for the exact thing you need to add.
but iterating over all the AIController isn't heavy too(depending how many Controller exits at the same time), if the no. is low that i guess no issue with it)?
like every time an AI wants to grab other location it will iterate over all the AI controller, but with sub system its already stored in it...
Are you expecting to have thousands of AI controllers active? If so, you'll have a lot more problems than just iterating over them.
no i mean that according to his game, he might be having 15-20 AI, as it kinda looks like tower defence type game, so iterating over is don't give an overhead?(just asking)
Plus you have to iterate over the list every time you update their location, so you aren't actually reducing how much you are iterating
Iterating over 15-20 AI controllers is going to be so low of a perf hit that you'll unlikely to ever see it in Insights. This is a problem of premature optimization. Don't optimize when you don't need to.
i am not updating their locations....
like first I am just removing that AI entity from my location Map, and then readding it with new location...
Which is more expensive than updating them. Map find is cheaper than array, but not by much when n is small. It has to find it to remove it.
so like this way it will be better than subsystem?
i am already storing all the controller as the combat starts, so don't need to search for the controllers every time
Hello,
i got questions regarding IA related assets (Tasks, services, BTs and BBs) :
- can you make childs of those ?
what i mean is (e.g.):
- having
AI1andAI2having a same BT - this BT has a task "do stuff"
- but "do stuff" for
AI1would be "count to 100" and "do stuff" forAI2would be "run towards player"
like overriding a function in BP
also, is there some place to better understand the pros & cons between BTs and STs ?
Okay, so when I fiddled with Nav mesh generation project settings, it added a lot to DefaultEngine.ini, in the section:
[/Script/NavigationSystem.RecastNavMesh]
Clearing that out to the state it was before I messed with it (which was 3-4 lines), seemed to fix it... soo.... problem solved?
The issue seems to come from the presence of the "Low, Default, High" nav resolution settings in DefaultEngine.ini
NavMeshResolutionParams[0]=(CellSize=38.076923,CellHeight=10.000000)
NavMeshResolutionParams[1]=(CellSize=19.038462,CellHeight=10.000000)
NavMeshResolutionParams[2]=(CellSize=19.000000,CellHeight=10.000000)
^These lines become present when I try to adjust the nav mesh rez fidelity in project settings.
idk why but when these lines are in the .ini, the navigation aborts on MoveTo. I can live without it for this project, but would like to know why
So, today I was testing the State Tree.
- I created a State Tree asset and then parameters.
- I assigned this asset to the State Tree Component and saw that my parameters were exposed. That looked really cool.
- Then I configurated these parameters through the component's default values.
- I placed my character in the world, and these values were reflected in the State Tree properly.
- Then I changed the default value from the component, namely, the animation I wanted to play for death.
- The animation didn't change in the game. That was strange.
- So I took a look at the placed actor and realized that changes in the class are not reflected in the placed actors for State Tree parameters.
Really weird. But I believe that's extremely prone to errors. Luckily, I noticed this sooner.
is there an easy way of enable and disable the behavior tree?
or somekind of resume
Brain component - stop logic/restart logic
it would work nicely if there code in it
Huh?
these functions dont do anything?
Do you really think I’d tell you to use these if they didn’t do anything?
What’d you do, ctrl+F in the solution instead of actually using them?
BehaviorTreeComponent is a subclass of BrainComponent and it implements these functions
Ahaha, nice one 😁
You should not have a BT task that is "do stuff" that is different for each AI. Instead you use dynamic subtrees.
Anyway, depending on your use case you can just call these on the brain component from blueprint, no need to delve into c++ just for starting stopping the behavior
for this kind of logic, should i use BT or ST ?
i didnt know dynamic subtrees was a thing
Not enough information has been given to make that decision. Try them both out and see which one works better for what you are trying to do.
for example, lets says that i got a main AI that holds a gun
depending of the gun, he will act differently (movements, shouting, etc)
how can i make the used conditions, tasks changing depending of that ?
i cant warp my mind around the BTs and STs regarding reusability and inheritance
Sounds like the same tasks just different anim blendspace, sound cues etc...
another example :
for a prison game, lets say we have prisoners and guards AI
they have 2 state : "walking around" and fighting
those 2 state are then used for both, so i could make one BT/ST to hold this
but, the "walking around" and fighting rules wont be the same
guards have more area access then prisoners
prisonner can only fight wit hhands, but guards can get to the locker room to get guns to shoot
its not only cosmetic changes, its also behavior logic changes
the last example shows it more
Put the logic that is weapon specific in the weapon/systems around it. And have the behavior tree tasks use those systems
for the mentioned example this would work, but what about the other example ?
Taking your example in this case i would just have different (sub)trees. It seems that the array of tasks available to prisoners is different than the one available to guards. Then, let them do different tasks
hi we're having weird issues with a nav mesh in ue5.3
it works perfectly fine in the editor but once built it doesn't seem to generate properly. It's in a world partitioned map with dynamic nav generation around navigation invokers
there's nothing that should be able to block generation in these areas just flat landscape with some generated grass
It sounds like you are asking for generic advice that works in all cases, but you aren't going to find that. It always depends on what you are doing.
There are a bunch of different ways you can have reusability that isn't inheritance.
I don't have an actual solution for you but I have seen they are working on support for navmesh generation with world partition in 5.4. mmmmaybe worth giving a look into that soon when it rolls out
that's good to know, thanks! still super annoying
is there a way to set an AI focus to a point in 3d space? SetFocalPoint on the AI controller only sets the yaw and not the pitch. for example
if the AI sees the player up on a ledge and the player moves out of sight, I want them to lock their focus on the last known location of the player, but currently they look directly forward regardless of the Z position of the focal point location
If you are using control rotation on the character, yaw is the only one on by default.
any tips on enabling pitch by chance?
have you implemented aim offset?
I have yes, but the issue is I dont want to have to do 2 separate calculations if I can just set the focal point and have them look at something using the control rotation
There should be a check box. If this is a normal biped character, this is probably not what you want. There's a difference between looking at something with the head and rotating the entire character.
use controller pitch and yaw?
SetFocus works fine when looking at a target, but set focal point is constrained to the x,y plane for some reason. I have an aim offset setup already, when the AI Sets focus to the target it looks using yaw and pitch just fine, but focal point is just the x,y plane
are you constantly changing the focal point?
sometimes yes, but most of the time no. either way they look straight forward towards the focal point, but there is no pitch
z position seems to have no effect
thats strange...
as for the SetFocus inside the code it takes the location of the Focus actor...
so in the end it is focusing at a location...
Let me check in my system
ye thats why im confused, it should in theory set the control rotation to point at the focus point, just like it would a focus actor lol
ah shit...
its not working in mine also 😂
its been a thing since early versions of UE4 and ive always wondered why it doesnt include pitch. it would be so useful and avoid duplicate calculations lol
i was about to go to sleep...
now i have to look into it 😅
haha dont tire yourself out, but if you find a solution I would be super happy to hear! 😄 its been driving me nuts for so long
heres an example video of whats happening. maybe this will help clarify the issue for others! 😄
Hey, can anyone help me understand creating multiple enemies? I've created an enemy that attacks pawn on site but when I drop a 2nd instance they won't both attack, only one will attack, and the other randomly stops
It sounds like your perception setup could be incorrect and they are detecting each other as enemies as well, but it's kind of hard to say for sure
what is a good way to set BB keys value from a BP outside of the AIC ? for example, the game state
You’d have to get the AICon, get the blackboard and set the value of the BB key
Why would the game state be managing AI data?
Hi, I'm having an issue with state tree evaluators not ticking between states? If a state's task doesn't tick more than once, ie enter's state and leaves, and goes to next state, the STE's aren't getting called between one state and the next.
That's leading to an issue of the state tree using the wrong state because when I reach the end of the state tree, and go to root, it doesn't read the ste and therefore acts on old information on deciding on course of action.
Without adding a state with a task that literally is just a slight delay to give the ste a chance to tick, are there other solutions?
Some data used for decision making is authored from the GS
im building something similar right now and finding this discussion useful. but let's say i have the claimed locations of nearby allies as a context...how do you exclude those points? not sure i can see a test i can use for this
Can someone help me figure out why my Is Low Health sequence isn't running? Not sure if it keeps trying for a split second.
It's true so why isn't it cancelling the others?
It runs Run EQS Query but Move To doesn't run. Then It picks another sequence. Can the EQS query fail and it selects something else?
I'm a duffus. The blackboard key wasn't set to the correct value 🤦♂️
Does anyone know what would cause a navmesh to not work in-game, despite being fine in editor? (UE 4.27)
What would be the best way for this to only heal if it's hidden? If it's not hidden then keep trying to move to a hidden place.
why is check hidden a service? i think a decorator would be best to check this. it would make the node fail if not hidden so the tree has a chance to re-evaulate the findhiddenlocation
is there a way to debug the "ai move to" ?
such as, drawing a sphere at the goal location, and having some draw lines to see the path of the AI
- black lines are walls
- cyan circle is the AI
- red circle is goa location
- red lines are the path the AI will follow
if its not built in, i would like to do it myself but idk if i can get the AI "path" from a "AI move to" request
Visual Logger should allow you to see information like this related to pathing
where can i find it ?
Tools->Debug
What do you mean? The Visual Logger should be able to display the path the AI is trying to take
For MoveTo I'm not sure if it's exposed to BP's, but I think there should be a way to ask the navigation system to calculate a path which it can then return
okay ill try to find that
Has anyone noticed any of the improvements to large world navmesh generation in 5.4? Diving in now to see if I can spot any myself
try this one
Nice, that looks like it should do the trick :)
ty
found it
it won't change the pitch if focus is not an actor
strange, why would that even be a thing? haha
is that in the AI controller class?
yeah
who knows 😂
on editor utility widget, when i get selected actors and get AI controller it returns null
but i am selecting the AI character that is controlled by an AI controller
I dont know C++ very good atm, but would I just create a child class of this and then override the function?
i fixed the issue..
just overload the UpdateControlRotation() fuction and remove this code..
yup
Pretty sure controller's aren't created in the editor, because they don't really need to be.
while playing in PIE its null
When do you get the controller?
thanks for finding that! gonna try and fix it now lol
Does the AI move around?
the AI works fine
looks like a editor widget issue
when i click a button
What are you trying to do exactly. Be as specific as possible and include as much information as possible.
Because you're talking about an editor widget and then referring to gameplay stuff
i want to get the ref of the AI controller to get some data from it
i am doing this through the editor utility widget
for debuggin purposes
I don't believe editor widgets are meant for runtime things.
Also, #editor-scripting
check hidden actually finds out if the actor is hidden. yea I guess that should be one step above in "Hide and Heal" and have a decorator there! cheers.
Distance test.
The visual logger and the gameplay debugger already have the navigation debugging set up.
didnt realize how easy it was to override a function in C++. learned something new along the way, thanks again! got it working now lol
cant make it work,
but i still want to access the AI controller for other stuff
What can't you make work? What other stuff? You aren't explaining what it is you are trying to do.
well i dont see any path when recording with the visua l logger
also, i cant find what the "gameplay debugger"
knowing c++ always helps...
you can do things like these ..
happy to help you 🙂
It’s the AI debugger (‘)
There are navigation categories you can use by turning off the other ones, so you only get navigation logs.
With the gameplay debugger there is also a navigation category if you look at the top of the screen.
the nav "section" shows big rectanlges, i was more looking for some lines
also, the "get path point" only returns 2 points (start & end), i though it would have more points if there is something blocking the way (e.g: a wall)
is "find path to location" what the AI uses with Move to ?
oh it now feels silly i didnt think of that 🙃
It's better if you @ people when you ask a follow up question.
The gameplay debugger does show lines when they are pathing.
okay sorry
i dont see the lines, or they are very small
btw, do you have the answer for this ?
Hey guys, I'm trying to make the ai which riding some tree (Like, grab a branches of tree and jump) How can I do this with AI? Please gimme any idea
There's a GDC presentation about how Assassins Creed Devs did it for the one with the trees (american one?)
visualize what exactly you want this ai to do. decompose it in single tasks..the things your agent will need to do. then see if you are able to make all those things. if not ask for help on a that specific thing. repeat until everything works.
or just give a better description of your overall goal if you want high level advice
Anyone have an idea as to the direction I could go to make something similar to a Sims Moodlet and Needs System? Any tutorials for some kind of start would work as well!
Gameai pro has an article about utility theory which specifically references the Sims as a sample
If I get to my computer and don't forget I'll share it
OOHH that'd be extremely helpful!! Thank you so much
🙏
Hey there, does anyone know how to toggle next AI character when debugging state machine on PIE? I’d like to use a keyboard shortcut rather than switching windows for selection if possible
how can i get an AI to sense a chaos agent and walk up to it and destroy it ( i already have the attack logic done )
I turned the chaos agent ( geomotry collection ) into its own actor i just dk what i need to put into the components tab for it to be recongized
If you are using the perception system, you would add a stimulus source component
can I create categories (or at least sub ones) ?
What sort of separation on concerns are people using for AI? If you have a character doing something it seems you need awareness of state in 3 to 4 places
- Behaviour tree blackboard or State Tree
- AI Controller
- Character Actor
- Animation blueprint
Now these don't all need exactly the same info, but there is still quite a lot of common info- so what's the best way to manage that without creating variables in four places?
The alternative is tighter coupling between levels- e.g. making everything read from the actor itself or the blackboard for example- but that tightly ties all four together
I'm puttting an enemy ai together and i'm trying to get an enemy to move out of visibility of it's target (player) but it stopswhen its out of view leaving half it's body showing. Is there a way i can make an ai character takes its capsule radius into account or something? or something similar before i start hacking something together? lol
If you're using behaviour trees you can make a behaviour tree service that does the check at intervals
i have an array of points for a flying AI, i want the AI to follow the path
i got it working rn with "Move To Location", thge issue is that it isnt following the Y values, its staying on ground
setting up the AI Character to Can Fly didnt change anything.
what is the proper way to do that ?
Yeah my problem is i'm using an eqs to find spots where the enemy has cover but it always chooses a spot where half it's mesh is still in view as its doing a line trace from root to root
You can modify the trace type
Just looking at it now- in the EQS trace there is an 'item height offset' setting under 'advanced'
how can i make a chicken ai for my game
I want it so the chicken will wander a little bit and if it sees the player it will chase him and try to kill him
Depends how advanced you want it. You can just use the perception system and onTargetPerceptionUpdated, but if you want it a bit more advanced you can use behaviour trees, watch the pinned video on Behaviour Trees, 6th pin I believe
How does one filter AI, animation physics for actors not visible in current scene due to distance or occluders.
Why do you have such specific tasks?
In the pinned messages there is a link for the intro to AI course on the learning library.
Depends on what you are doing. The character shouldn't need anything from the BT/State Tree and the anim bp shouldn't need anything from the AI at all.
when possible i create reusable tasks, but some of them are just to specific to be reused
Move to location uses navigation, which is for walking. If you are using the BT you can use move directly towards.
i have more stuff inside then a simple move to
but this doesnt answer the original question that is about create categories
Then it sounds like you are trying to do too much within a task. Moving to shouldn't need multiple tasks.
I've never needed categories, because even with making AAA games we don't have that many different tasks.
where do you put your AI stuff then?
in events in the AIC or Pawn ?
i dont see why i shouldnt do all my logic in BTs
A significant amount of the logic is in the BT. Just organized a lot better. You don't need multiple movement tasks.
Using an object is a single task, regardless of the object
its an old screen, i combined the "move to" to a modular task
but still, forget about my "move to" task : i will have lots of tasks over time, where do you put your AI stuff then?
There a few different ways to do that. Line of sight checks is a line trace. You can either do a shape trace instead or multiple lines. The former is easier but the latter is more performant.
should this be just a event on the AIC/AIP ?
No that should not be an event. All of your tasks are ultra specific instead of actually using variables to make them generic.
this cant be done with vars
Well it seems to me that for example MoveToBed has no reason to be MoveTo Bed when it could just be.. Move To and the target just happens to be the bed
Same with move to player, is there some reason it can't be Move To with the player as a target?
Let's say we have a character and we want it to attack. The 'brain' bit needs to trigger the attack and know it is attacking- so either the controller, the behaviour tree, or both; the actor itself needs to play an animation and make sounds; the animation blueprint needs to do some work, listening for events on the animation, possibly firing events back to the character when the animation is complete, or when the 'lethal' bit of the animation is playing. So, as far as I can tell, all four of those need some sort of awareness of state
It's not exactly the same info and not the same logic getting run on all four, but it's the same mode
The BT tells the character to attack. The character does the attack. At no point does the character need to know what the AI is doing, other than it was told to attack. The AI doesn't need to know about animation or hits or whatever. It just needs to know when the attack is complete.
Yes 100%.
But for all those things you need to be in the 'attack' state
If you are using a BT, there is no "attack state".
There's an attack task though
I'm not trying to recreate a state machine here btw
Sure, but the character (body) doesn't need to know what task the AI is in. Just that it's attacking.
Again, I get that. What I'm trying to get at here is that each one of the bits needs to know, at some point, what it is supposed to be doing, and all those need to sync up
I'm probably just being stupid!
It just seems like there's either necessarily a fair bit of duplication of state along the chain, or there's a clever way of abstracting that out that I've not thought of
You literally have a BT task that is specifically for a staff care center to pickup a player. You really can't think of a way to make that a generic task?
We use GAS, so the BT tells the character to execute a specific GAS ability. Then it binds to that ability being done. The ability is executed and an animation is played via a montage. The ability handles listening for hit events, doing damage and any other animation notifies. Once it ends, the BT task moves on. At no point in time does the ability know anything about the AI.
no
since its specific to that moment
Then you either need to learn more about programming or trying to do too much in the BT. Probably a bit of both.
so tasks cant be specific ?
for e.g. the "drop player in bed" will never be used somewhere else
so i dont see how I can make it generic
What is the pick up player task doing? Exactly?
its temporary, i'll add some root motion anims and other stuff later on
Right, thanks, I'll have a look at GAS
Your BT task is doing everything instead of telling other things to do something. This work would be much better done in a GAS ability task. I also recommend looking up "separation of concerns", because that's a programming concept that you should really learn about.
that why i was asking about events in AIC or AIP
to know what to put where
Notice how at no point in time have I said "event in AIC or AIP"
if you want to redirect those actions somewhere else, i will probably end with event in the AIC or AIP or GAS or interfaces with player
is there any way to reset all the values in the blackboard?
Do these really work in a StateTree task? Unchecking "Should State Change on Reselect" still lets EnterState to fire repeatedly even though the state hasn't changed.
Anyone have a simple example of using utility ai with behavior trees? Idling, eat, sleep.. I'm also wondering if using enumerators would help or gametags for what state/action they'd currently be in
Did some more research, and realized a simple example tutorial is asking for a lot LOL
but i got to something I can start with for anyone curious, https://medium.com/@morganwalkupdev/easy-ai-in-unreal-engine-c0f4ba1998cc
Stop struggling with behavior trees and learn to create complex AI behavior entirely in blueprints
Also this video https://www.youtube.com/watch?v=d63hbJYYqM8
I took the time to explore this AI pattern I wanted to try for some time.
Utility systems are interesting decision making algorithms to model NPC behaviour. Here is a quick intro with examples and sample code for Godot.
Source code: https://github.com/viniciusgerevini/godot-utility-ai
Assets: https://analogstudios.itch.io/fantasy
My site: https...
As someone who has used a Utility/BT hybrid professionally for over a decade, it is easy to set up but incredibly hard to do well.
I would recommend the articles in Game AI Pro (free online) and the various GDC talks on the topic instead of tutorials.
Which part is the hard part, if you dont mine elaborating some
Debugging feels a bit weird, and calculating/tuning weights can prob get tricky in larger setups
First one can prob easily be mitigated by some custom tools
The vast majority of people want to do AI in a scripted way. If x is true, always do y. That's why you see a lot of BTs that are forced into FSMs or scripted AI.
With Utility, it's more thinking about it as "the utility is higher for x when y conditions are met" And express that with math. True utility is also used with curves. So instead of "attack when the target is X distance away" it's "the curve of the attack is higher the closer you are to the target". I see a lot of people trying to fight the system, because what they actually want is to "do X when y happens".
Utility really only shines when you have a lot of actions that are reasonable to do. It's perf is a lot worse than a FSM and a BT, so if you only have a handful of actions you're wasting a lot of perf.
Im basically using utility ai, and can currently handle quite a fe æw task checks on some unoptimized tick,
I do limit the avaliable actions tho, and do early returns
Ty for elaborating 🙂
Hello, i have a possibly supper beginner question, i am trying to use nav mesh volume in a paper-2d project, it seems to not work, using the show>Navigation (or clicking on P) i still dont see the green thingy
solution found: lower the RecastMesh-Default>Nav Mesh Resolution Params>Default>Cell size to 1,0
It's most likely collision related
either your collisions/collision settings are incorrect, or some navigation involker is blocking that area
overall there's not enough information to give a clear response
me again. months later. turns out yes, the navmesh was checking every single sprite in the group, because the GetNavigationPerInstanceTransfrorms method of PaperGroupedSpriteComponent is unfinished. if you ever have this problem, just disable 'can ever affect navigation' on your sprites, and use an instanced static mesh for collisions. or, fix the method below.
Interesting
I guess they didn't assume anyone to use a grouped sprite for something like trees spread across a larger navmesh
Hey all! I'm wondering if somebody knows a good solution for 2D multithreaded pathfinding. I've seen a couple of plugins that are for 3D which I could adapt, but nothing very promising, to be honest. Any help here would be appreciated 😄
you wanna know the best part? the fix was just && AreaBox.IsInside(InstanceToComponent.GetLocation())
at least, I think that fixed it. I did see huge performance improvements and my navmesh is still generating fine, but I'm still seeing some weird numbers
Is there a console command for AI debugger?
you mean vislog?
I guess what I need is named Gameplay Debugger, the one that you can view perception, behavior tree, nav mesh etc.
hmm, not that I know
Hmm, I couldn't find it anywhere as well. Thanks!
No. You use apostrophe (') to turn it on.
What would the easiest way to make my AI be able to Open doors?
The first image is my Door BP, All you need to do is press E to open the door. But how would i make the BP_AI able to open the door?
Depends on how you want it to work. For example you could make the doors not affect navigation and have the AI detect when it bumps into a door and open it, or you can make the door have a custom smart nav link which handles it
i think the first option would be better no?
do you need to see my AI blackboard or anything like that?
Well I can't really tell you exactly how to do it because it depends on how your character etc. works - but you would basically just set it up so that your character blueprint has logic that detects when it collides with something, and if the thing it collided with is a door, it would try to open it
adding to the 1st points,
you can make you door so that If AI overlaps the door, it will automatically open up...(only if you don't want your AI to manually open it)
Yeah that too. Generally it depends on how much you want the AI to actually look like it's opening the door, or whether it doesn't matter so much :)
(Smart links are good if you want to do something like play an animation so it actually looks "right")
yeah smart link will be a proper one, so that AI can do a specific action while opening/ closin the door
Anyone using smart objects? I'm kinda looking at my SO systems again and I'm wondering if there's some intended way to use multiple different gameplay behaviors on it
Basically my SO slots support two different kinds of actions, but there doesn't seem to be any builtin way that allows you to choose from multiple behavior definitions (eg. if you have one per action type)
I had some workarounds for it but they're not great.... maybe I just need to make a custom behavior config type that allows defining a map of gameplay behaviors and when using the slot the appropriate one is loaded from the map or something...
Hi guys! any good tool to work with behavior trees in 5.3? as far as I know state trees are still experimental
What exactly is it you're looking for? There's already a BT editor and everything in the engine as far as I can tell
State trees are quite functional, but have some rough edges you may have to be careful with
I'm experienced with BT, however I've heard of some other devs using State Tree kind of tools to work along with it
and yeah I heard State Trees aren't production ready yet in 5.3
I was just curious about what tools are out there in the marketplace to improve BT, Task and services workflow 🙂
Ah I see, I've not really used anything from the marketplace for this. I think there's a few AI related tools there though
Like some people said, add a SmartLink component to the door BP, and subscribe to the "OnSmartLinkReached" event to trigger the door opening.
It works like a charm.
IIRC the NavLink component isn't Blueprint exposed by default, but some wonderful person here created a little wrapper a while back that I've been using to great success.
I wish I could give credit but unfortunately I've forgotten the original poster, so may they receive their credit in good karma or something instead
Actually, we still have some issues with NPC:s getting stuck behind the now open door, so clearly doors aren't a very simple problem :D
ok
I am using paper 2d and want to create a nav mesh but it seems like the navmesh volume isnt picking up
any assistance would be awesome
Im working on a co-op rpg. I use behavior trees for my enemy AI, and GAS for abilities / attributes. So far so good. But im looking to create a more complex AI. But not really sure what the best practice for storing the relationships and data that I need to store would be. Ive been thinking about gamestate or perhaps the gamemode.
I want my enemies to be a part of a species. Some species will have naturual allies and enemies, but I want those relationships to evolve over time. For instance, if my player has positive interactions with one species they could gain trust, or if they attack species, eventually the game will send out bounty hunters after the player.
How would you go about storing the relationship data?
Currently, most of the data I have / need is either stored in the player state, the blackboard or on the actor/enemy directly.
i ahve a problem, my NPC sometimes always tuck in this place
Gamestate sounds reasonable 👌
Navmesh is prly too narrow there, make custom nav agents to make it snug against the walls
Or make your npc smaller
But also, you should use the visual logger to find out exactly what’s happening
is there any way i can get the switch case functionality in behavior tree? like selector will select on the value of enum. I tried finding tutorials for it but didnt find any if anyone knows any video or blog post about it that would be a big help too]
my behavior tree detects correctly when Player1 (left) is close to Ai character (Right side)
as you can see, I have a Task that inside has a Ai MoveTo (because a normal MoveTo in the tree didnt work)
I think is something related to my ai BP, which works perfectly with Simple MoveTo
but I need to use Behavior trees etc
my Ai Bp, is the same BP for Both, normal for player and ai, this shouldnt be te problem, as the detection is happening, right?
I used my normal BP of the player just to test fast because everything is setup to spawn this BP and so on
Thank you. That’s what I was leaning towards but I wasn’t sure if there might have been a more appropriate way.
you can try something like this
You can store data anywhere, it doesn't need to be in a built-in class. I would put it in it's own class instead of the game state or game mode. If you use C++, a subsystem would be best.
Yea my game is in c++ for most of the business logic. Ill look into a subsystem. 🙂
Sometimes and always are very different. Are they getting stuck or is it picking random locations that you don't like? Use the visual logger to debug.
Subsystems are really easy to make and use. I recommend a world subsystem or game instance subsystem for a relationship system
You can use a selector with a decorator that is an enum type
That is forcing the BT in a state machine.
If your character BPs are the same, how are you setting up the AI controller? If you aren't using an AI controller, then you are going to have a lot of problems. If you don't know what an AI controller is, I recommend you do the introduction to AI course that is linked in the pinned messages
tyvm ill check it out! Since co-op is my main worry, how does replication work with them?
maybe the data might not even need replicated though... since it would be stored on the server anyways.
Unfortunately there isn't a built-in subsystem type that is replicated. It's not hard to make one though. What clients would need that data?
Thinking more about it I think mostly just the server would need to know and store the relationship data. The clients would just need to be able to know if an actor is an ally or enemy. The actors behavior would be determined by it.
is it good or bad way of doing this?
as this was the only way that came to my mind
Bad way
If you want a state machine - use a state machine
BT's are priority selectors pretty much
so how should i select the nodes depending on my AI state?
Stop thinking in "states"
The first pinned post has a course on AI. It covers the theory.
You layout your BT according to behavior priority
You gate the branches via decorators really
yeah I have done that one..
its pretty good one....
i am lil bit confused now,
as you said stop thinking in "states"....
so should i create a separate BTs for each of them...
like if i want my AI to throw grenade, it will be become its priority to perform this task, or like if it wants to reload, then reload will become its priority...
so its like priority is changing everytime depending what AI whats....
to enum was the only thing that came to my mind to perform this
I have a boolean that I expose in spawn, isBot?, the player is false, the ai is true
is working in a normal BP_ThirdPerson but not in my BP to move
so there is something in my BP
as I said everything else works fine, it trigger jumps or montages through the Blackboard
In what way is that stopping of thinking about it as states?
You aren't making a lot of sense. How is exposing a boolean setting up an AI controller? In what ways are you debugging the move to functionality?
i am thinking them as states like...
like in FSM if we select a walking state, means than the pawn perform the walking ...
thats how i am thinking it here...
like if the mag is empty, AI will switch to Reload State, and stop everything and will reload,
same goes for grenade, if i am selecting an AI to throw a grenade(based on certain condition), then i am switching it to grenade throw, so that it can perform certain action to throw the grenade...
A BT is not a FSM.
this is the AiController class that the BP_ThirdPersonCharacter has linked in it Class Defaults
BP_ThirdPersonCharacter has a variable isBot?
by default is False
so when player spawn, is false
but my already in map BPs has setup this variable to true
this works like that
so should i create separate BT's for each of them, and handle it from controller...
or make its something like...
during shooting check for bullet for each fire, if mag not empty then continue fire else abort fire and switch to next sequence of actions
as of now things are working, but i a doing them is a wrong way...
No. You need to think of them as a sequence of actions instead of states. You shouldn't be handling them from the controller either.
Why are you getting all actors of class? Do all of your AI not have an AI controller?
You do checks with decorators and services. Not the AI controller. You need to rewatch that introduction to AI with Blueprints course, because you lack a basic understanding of how a BT works.
so like if my shooting action fails(which as of now only fails if AI dies, or runs out of bullets or player dies), I should move on to my next action...
yeah doing that right now...
i really need to understand the basics
btw is it different to what I am doing?
Using an enum blackboard decorator isn't just used to force a BT into a FSM.
Hi everyone. I'm currently making a game in which I push enemy AI via an impulse. I discovered that, sometimes, when pushed at the border of my level, enemies may fall off the navmesh and then they can't come back and follow me just because they were pushed to an area that didn't have it
Is there a function that gets triggered if an AI falls of the navmesh? so that I could maybe fin a navigable point in a radius and teleport my enemy there
I don't think the navmesh is scanned in that sense unless you're usinv NavMeshWalking as the movement mode
But when movement fails, you could probably either use the failure reason or test it there
Or potentially just test it after applying impulses
oh ok, thanks!
@uneven cloud and thank you for pointing out my wrong methods of working...I'll work on them
Hello, with StateTree, does anyone know if it is possible to use an Output parameter from a task, as a bind input parameter for another task, on the same level ? I'm trying, but the binding contextual menu doesn't shows the variable I'm looking for
This is the ouput variable, which I would like to use in the Join Closest Patrol Location
Not on the same level no, only tasks in child states can use outputs from other tasks
It may also work if you put both tasks into the same state in order, but the behavior of this will be different than having them in separate states (they will run simultaneously)
So the UserTagFilter on SmartObjectDefinitions is something we can't change at runtime?
having a dynamic nav mesh change issue and build paths doesn't fix it, prly cause of the dynamic generation part.
Essentially, depending on how I scale the navmesh volume I get weird results. Too tall, and I get it on the roof, but not in the last 1 to 1/2 floors. Too short and it's either not covering the bottom or the top floor. I had it covering the floors fine when it was static but because I'm making the rooms spawn gradually, the dynamic generation seems to make it break.
better angle for the tall part, seems to start occurring on the last 2 floors
in the right image, the last room hasn't spawned yet, but that right part disappears once it's no longer a "roof" and it appears on the next room's roof instead
I tried deleting and readding the navmesh and making it even bigger but similar issues. Is there some kind of navmesh bounds volume height restriction?
I noticed that if I move those specific floors down while Simulating, the mesh dynamically generates on them again (but this doesn’t help me)
You can check if an AI is not on the nav mesh by doing a project to nav mesh at its location. There is nothing that is constantly checking for an event to get sent, you have to add that functionality.
anyone had this issue? was working fine before idk why stop logic is none
This is called on death of my AI on the AI controller. how does this comeback as none? stop logic is a default node right?
Hello! I have a node that changes the distance a character wants to stay away from their home base. I need to be able to run a node that randomizes it, then have that node not run again until a different node/branch (they get into a fight) is reached at least once. Anyone done this before?
We can’t see your code
Show a screenshot of where the problem is. Based on that tho, your AICEnemybase is not set properly
I've had my head down for a few years as I was stuck on a pinned engine version, so I'm a bit ignorant of the state of things in UE5.
StateTrees: What's the general thought of them? I grepped the last 6-12 months of conversations here and there's not a whole lot of substance to parse through.
StateTrees appeared to skip the experimental phase and popped out of nowhere in 5.0. My job tends to be a bit timid when approaching most of Epic's half-baked feat.. er, uh... whimsy. So, I'm curious about the general zeitgeist. Are they planned to supersede Blackboard/BT?
Doubtful. They’re an alternative not a replacement
Or better yet, a different tool for a different job
Bump. Should I be using another navmesh volume to get around this? Is that even “allowed” ? 😀
Hi, does anyone have any experience with the new Learning Agents by Unreal, I have already done the drive demo but there is nothing else online, and I still don't really get it
any help?
in visual logger they show a large space for the AI walk
Are there any errors with navigation in the vis log or are the points it's moving to not what you want?
no errors
this happen sometimes
So it's just not finding locations that look good? Welcome to random. I prefer using the EQS for this reason. You can do more intelligent random instead.
yes the walk location isn't good
only sometimes accros that place
With the EQS you generate a bunch of possible locations and do tests on them. Like filtering out points that are too close. It scores the locations based on the tests and then picks the best one.
hwo to do that
You create an EQS query. There are BT nodes you can use to run them - Run EQS task and a service. There is documentation on how to set it up.
small bug, when ai walks into the player or eachother they kind of get sent flying, not sure how to fix this
having 2 nav meshes has the same effect as having one tall one. Ngl @uneven cloud could use some guidance here if you've ever experienced this weird height dependent navmesh generation issue
anyone know why "Spawn AIFrom Class" would be ignoring "Is Spatially Loaded"?
manually dropping an actor bp into the world spatially loads and unloads fine, but spawning that same actor bp dynamically, from another bp, it stops working...
Hey guys, is it possible to attach an AIController to a non-character actor? I'd like to use a Behavior Tree+EQS for enemy spawning, and I want to run the BT off a basic actor that won't be moving around the level, is this possible?
Controller's possess pawns, so at minimum, it needs to be a pawn
You don't have 2 nav meshes. Not sure what is happening, because I've never seen issues with height before.
There was one in the screenshot, I tried two after, same result. Np, I’ll keep digging
You still don't have 2 nav meshes. Multiple volumes doesn't create multiple nav meshes.
Ah I see what you mean now
You need to make the owner something that is spacially loaded for that to work.
Why do you want to run a BT for spawning? Spawning is simple.
Well I was thinking that it would be cool to use AI in some way to determine good places to spawn enemies, but I think I'll probably use EQS and Timers in a regular blueprint graph
you know if there's an example of this somewhere? not sure where to do that
Dumb question how would I possess a spawn based on a bool please ?
I have a AIController but am unsure how I get that Controller to possess this pawn if it,s an AI Character
thought would be something like this but not sure what i plug into the cast
The EQS is the best system for determining good places to spawn.
One of the variables when spawning is to give it an owner.
You use the auto possession functionality.
yeah I found that, I'm just not sure what the owner should be or what that should reference
also, my spawner is setup as an actor, and my spawned enemy is setup as a character (for the movement stuff), I'm assuming that's what it should be
Any actor can be the owner. If you have an actor in the world that is a spawner, then that is the best choice.
yeah my spawner actor bp, I'm manually adding that to the level
Once the owner is spacially unloaded, the NPC will be unloaded
It doesn't matter how you are adding that to the level
it's not working for some reason, the spawner IS unloading spatially, and has spatially loaded checked
the stuff it's spawning still isn't unloading
I'm losing my mind
either way, I know the issue now is that the stuff spawned using spawn actor node puts it in the persistent level by default
and it's just not crossing over for some reason
welp, that works, just needed to drop the "get owner" part, I guess that wasn't setup right
and plug self directly in, oi
Do you not understand what Get Owner does? Of course it's not going to work when you pass in a null reference.
hey guys, when im using the ai move to node is there a reason why the ai will not go to the correct z level until after it has gotten to the correct x and y and is there a solution. Im just using the Ai move to node
Is there something it can climb on to get there?
I have it set to ignore grav, an i put a nav link on every differnt level but other than that, no.
The built-in navmesh does not include free flying movement, you’d need to either make your own solution or fake it
yeah im currently trying to fake it but the more time that goes on the more i think i may just needto create my own pathfiding system
I adjusted the relative position of the mesh and turned off collision on the capsule. Not ideal but yeah
AI Move To projects the location onto the nav mesh. What do you mean it doesn't go to the correct Z until it gets to the correct XY? That doesn't make any sense.
Anyone here can help me with denbugging/troubleshooting why my NavMesh is not showing up in PIE or Packaged projects?
Below are a few images of comparisons between PIE and the Editor Viewport
The PIE has the Show Navigation command on.
More information: I'm using a Static Navmesh, I have several NavMesh Bounds in my OpenWorld level, level is World Partition Enabled, Nacmesh is NOT Partition enabled.
Also Screenshots of the RecastNavMesh settings.
I've used the Build Paths etc.
Would love to get some insight, if more info is needed, please lemme know!
I’ll give it a try thank you
I mean if the AI is set to move to somewhere on a different Z level then it will go to the projected XY and then wait for the delay I have set then move to that Z value
afaik the nav mesh only shows out if you simulate or eject and press P.
Why are you using a non partitioned nav mesh in a partitioned world?
That sounds like something you added. Because that's not how it works.
Gotcha thank you
Idk what it could be as changes I’ve made is a nav link as it’s ignoring gravity
It doesn't matter if it's ignoring gravity. The nav mesh is a 2d graph of points. It will project the goal location down to the nav mesh on the ground and build a path of points that are also on the ground.
Hey guys, I'm new to unreal and I need some help. Is there any way to stop a Move to Blackboard node (thereby resetting the tree and try to find a new target) if the AI doesnt reach the location after some x seconds. Due to the smaller corridors in my level, the AIs are just hanging back trying to move to a location they cant anymore since other AIs have occupied the location they were trying to move to.
Ok I wonder why that’s happening then
Anyone run into an issue where actors move on a navmesh just fine in editor, but not in the built game?
are you using level streaming?
this happened with me when i was using level streaming
No, just one big boy level on my end, no streaming.
Works with one of the AI controllers, not the other.
It's so weird, their behavior trees are operating as it should, they just don't move. And only on the build.
Hi, I don't know if I missed something, but I'm trying to develop a patrolling behavior with State Tree, but I don't succeed right now, the screen shows my setup right now, the issue is on the Join Closest Patrol Location (I think), I've added as a screen the MoveTo Task which is really simple. My State Tree is looping over the JoinClosestPatrolLocation state, never going into the Patrolling State, even if I reach the FinishTask on the MoveTo
Hi would someone be able to advise how I can use a Navmesh in a 2D project I have the Tilemap Thickness set to 200 but seems the navmesh cant seem to generate on sloped sprites or platforms
anyone have any tips for generating EQS points around a location instead of an actor?
create a new EQS context which returns the location you want to generate around
is there a way to update the location of the context at runtime?
Ie. currently im just getting a specific vector from a state machine, but would be nice to make it usable with any "input" vector
You can pull the value from somewhere else in the context, such as the querier actor
Unfortunately there is no particularly straightforward way to parametrize these things in EQS
Riot has a PR out there that apparently does. But its sittin' in limbo 😢
fair enough, I suppose making a context for each isnt too hard, just trying to give the AI the closest location to a point that may or may not be reachable lol
suspicion, last known loc, etc
Yeah you can manually insert it into a property in the context for in C++ and it'll work just fine... but that requires you to find the appropriate bits off the query which can be a bit iffy code-wise
I'm curious what the Riot PR for it does 🤔
Ah, dynamic context
TSharedPtr<FEnvQueryInstance> QueryInst = Manager->PrepareQueryInstance(SomeQuery, EEnvQueryRunMode::SingleResult);
UEnvQueryTest_WeaponLOS* LOSTest = Cast<UEnvQueryTest_WeaponLOS>(QueryInst->Options[0].Tests[0]);
LOSTest->AttackTag = FGameplayTag::EmptyTag;
This is what I was doing to pass parameters directly into a test :P
It'd be nice if Epic would revisit this stuff
Didn't see anything about it in Tim's tweet about Metaverse and flying unicorns and shit
Hey yall I am just starting out with Behavior Trees and I imagine this is basic, but I'm having a bit of trouble with cooldown
What I expect to happen here is that it waits for 5 seconds, and then enters cooldown for 5 seconds, and does this on loop
it waits 5s first doesn't it
having a Wait of 5s and a Cooldown of 5s is prly not ideal lol
That's not really the point
yeah ik
The cooldown node starts in cooldown and only unlocks it after for one execution
I'd assume that's what your problem is although you didn't really describe what it is actually doing
Yes
just tested and it works as intended
I used different timings so it's actually clear what is going on
Yeah the cooldown starts in cooldown which is rather counterintuitive but that's just how it works
I created an EQS Testing Pawn, I then created an EQ that im going to use to spawn enemies depending on location / distance to the player. I want my enemies to spawn only if the player cant be seen. Ive done it before so I was trying to retrace my steps. BUT Pathing Grid doesnt render the orbs. Ive tried jiggling the actor because sometimes thatll make it render. Itll render all the other generators, just not this one.
Waits for 1s, then cooldown kicks in, and Waits for 3s, in 5.4
Really? I keep hearing people say it starts in cooldown and I vaguely remember having that same result 🤔
yeah I also rmbr it being broken that way
well test with the code I posted and see what happens
Hard to tell the difference between the cooldown's 5s and the Wait's 5s as it stands, which was my initial point
I think it's been that way since at least 5.0
Waits for 3 seconds, finishes the cooldown, waits for 1 second
Yeah, so they must've ghost fixed it in 5.4 (mind you there's no release notes yet so prly not ghost)
I also rmbr it doing what @misty wharf said and what you're seeing
someone prly forgot one ! in the code lol
Okay thanks for helping me out, I'll update to 5.4 😄
I also have another question, if Test_Bool is not set here, should I expect the 20 second wait to run?
afaik, yeah
keep in mind it's got some stability issues
have source control setup so you can revert if needed
Soooo lol after I rebuilt my paths and restarted the editor the generator actors appeared. Unreal man… crazy.
How many AI Controller, Behavior Tree, and Behavior Blackboard files per enemy do you guys have?
Assuming each enemy is unique enough, doesn't that mean 3 files per enemy?
I seldom have entirely different BB's for each enemy
Find the commonality in everything and see how you can have it data driven more
Right now, I can have bosses with different functionality and regular enemies, all with like 2 data assets.
I see, I guess BBs can be more shared
The 2 data assets, you mean 2 AIC and 2 BT?
No, I mean I create a data asset and just define all the changable data in there.
I don't use multiple AC's either
Generally just one.
I see, so like one AIC_Generic_Enemy, which uses BT_Generic_Enemy and BB_Generic_Enemy.
AIC_Generic_Enemy: Reads data asset, depending on a particular enemy
BT_Generic_Enemy: All behaviors of all enemies, using selectors for behavior determined by data asset
BB_Generic_Enemy: All variables of all enemies, some are unused, depending on data asset
That way all enemies share the same AIC, BT, and BB. But the data asset controls which behavior gets enabled/disabled.
Is what you what mean?
1 AI controller, 1 blackboard and a handful of BTs. Hundreds of different NPCS.
I really hope that's not what @harsh storm means, because that's a really naive way to structure the BT and BB.
It's not 😔
Figured as much
Why is data driving so difficult for some people?
So 1 AI Controller, 1 BB, a few BT
These being controlled by Data Assets, is that right?
Driven by data that is set up in a data asset
I have a BT for different actual types of enemies. The BT is in the enemy data asset. So the AC will get the BT from the pawn. Because the pawn is what holds the data asset. I do generally have one AC, but it's really just a vessel to run pathing and brain component logic (Keep in mind though, I mainly do zombie games 😛). It's my pawn's that actually do the actions and BT decide which actions should be done. And the tasks are designed in such a way that I can change the data based on BB values or w/e else I may need.
I also have sub-trees so general BT logic can be reused.
Our AI definition data asset has things like the BT to use, the perception settings, team and any other variables we want to change on a per enemy type.
Yup. Same.
We have a few different BTs, because some NPCs don't do combat and others do combat, but don't navigate (some bosses).
I also do use BB inheritance. Because there are some things that like, every BB will be using.
We only have 1 BB.
I think it's because it's not well covered or talked about in readily available tutorials to be honest.
99% of the time, I do as well if I'm being perfectly honest. It does make things soooo much easier. But I have used BB inheritance in the past. So I just mentioned it so people know it's not completely outlandish.
Nice technique
Pawn implements BPI_AIControllable which has Get_BehaviorTree
Pawn uses AIC_Generic, which simply calls Get_BehaviorTree to get and then Run Behavior Tree
Clever
hey! I've been looking into giving a go at State Trees, and moving our Behavior Trees to STs. But there is a fundamental thing that is unclear to me. With BTs you can update the blackboard from outside of them (and it's a huge clusterfuck with the whole bbkey name in a string thing). With State Trees it seems the idea is to have an evaluator that "pulls data" from other places (like the context actor) on tick. Is that so?
This can be used or your tasks can pull data directly from outside as well
what is confusing coming from a BT mindset is that there is no blackboard. Or at least there is no way to set the state tree schema parameters. but it seems like you can bind tasks inputs to other tasks outputs
does the On See Pawn Function in Pawn Sensing Component gets called everyframe? I wanna know when ai stops detecting pawn
Hey,
I'm making an RTS game with auto fight mechanics
I have a lot of Units and I would like to know how to implement a good Enemy detection / fight system
Today I have a Sphere collision and I update an array of detected enemies on Overlapped event.
But maybe AI perception is better or tracing or anything else ?
You should use AI perception, pawn sensing is old and crap. With AI perception you can check the perceived successfully bool to determine when something is no longer detected
This depends on how you want it to work. AI perception does line traces based on sight radius. If you only care about radius and not about obstacles like walls, using a sphere collision on it probably would work just fine
Yes I totally don't care about walls etc, but I will probably have 100-200 units
Hard to say what would be best in terms of perf tbh
The spheres should use the engine's internal collision detection stuff which I think should be fairly well optimized and avoids doing lookups on stuff that is far etc.
thx, will let it with collision sphere and I guess the bottleneck will be more on the qty of actors / replication and probably not on this aspect.
I will make the tests and see if I have issue here, maybe I will need to switch on MassUnit
Hard to say what's going on in that thread because there's a ton of information missing about the other tasks and no debugger info or anything... but I don't think there are bugs related to this really, the execution flow of the state tree seems to just be kinda confusing if you don't know how it works
Iirc if a parent state's task finishes, then it can finish the entire subtree
there's some completely unobvious things like that which can cause confusing behavior like in the thread
It should be fairly easy to test if you set it up so that you have a parent task which finishes immediately and look at the ST debugger and see how the execution goes
Basically there are some situations where you need to have tasks that never finish
There's some info on it that I wrote here https://zomgmoz.tv/unreal/State-Tree/Custom-StateTree-tasks
But yeah I don't think there are any bugs related to the state/task execution, it's just... super confusing because it's poorly/confusingly documented
Yeah because of how the node selection behavior works I think
The parent state is never entered alone, it immediately also enters the first leaf state
And the parent completing can trigger the whole subtree to also to consider it as complete
Ah, yeah I don't recall how those affect the behavior
I didn't play with the options for that so not sure
I vaguely recall there's an explanation of the behavior if you hover over the option, but it could be poorly worded just like every other piece of docs related to this seems to be
Best bet is to check the C++ code for it :P
Good or bad idea ?
Refact my behaviors trees to StateTree, I don't like blackboard 😇
Refer to discussion above
Be prepared to be confused at least somewhat and ideally know C++ to figure stuff out from source
also note that things like support to run state tree assets as subtrees is only available in 5.4 and unclear how good the support is at the initial release, so if that's something you want it might not be ideal just yet
But if all of that is acceptable then go for it, at least in my testing project it works pretty well
The idea of StateTree is way more cleaner and make way more sense for me I guess
Will use it for small actors first
is it necessary to attach ai perception component to AI Controller Class? or its okay if i attach it to the ai pawn??
cuz i saw few videos and they all adding it to the controller
It's intended to be in the controller but if you must it will work in a pawn, although this will generate warnings
I would recommend putting it in the controller as who knows they might deprecate the pawn support at some point
(plus warnings should usually be heeded and fixed)
How do I increase the avoidance radius on the Detour crowd avoidance AI controller? Enemies not running face first into each other is an improvement, but they really need to stay further apart than the radius of their hitbox. 🤔
I'm not sure what it uses to determine the dimensions of the character on the navmesh...
iirc it uses the collision capsule by default
😦
You can override the function GetCrowdAgentCollisions and set it to whatever I think
I think this in the AI controller by default
Thanks 🙂
still having this weird height restriction issue during runtime navmesh generation. At this point, all I can think of is to make invisible floors and leave it on modifiers only, so the navmesh is pre-generated before the rooms even get spawned in
Hey @lyric flint , sorry to tag you directly but I saw that you've been fixing some state tree binding issues (e.g https://github.com/EpicGames/UnrealEngine/commit/526060671189fcc8bff1671e138e697a675c1538).
I'm running into the same issue that was described here: https://forums.unrealengine.com/t/state-tree-any-enum-doesnt-work-with-any-enum-enum-compare-in-ue5-3-2/1406962.
If I just create a blank state tree and create an enter condition on the root node, set it to Enum compare and then pick any enum to bind it to, the editor crashes. Just as an example, you can try setting it to the "Role" enum in the Context actor.
If I just "run" the editor from source, it doesn't crash and instead shows a red warning "Property is bound to Context 'Actor' property Role but binding source type 'ENet Role' does not match property type 'State Tree Any Enum'.
However usually I run the editor from source in "debug" mode and in that case, anytime I select an enum in "Enum compare" or select a state that already contains an Enum compare it crashes on this line in StateTreePropertyBindings.cpp:
ensureMsgf(false, TEXT("Couldnt determine property copy type (%s -> %s)"), *SourceProperty->GetNameCPP(), *TargetProperty->GetNameCPP());
Looks like this is similar to a lot of the issues you've been fixing in the last 6 months or so. Do you know if this is one of the cases you've fixed? If so, do you happen to know what the commit was? I'm hoping to be able to pull in just that fix without upgrading to 5.4 (I'm currently on 5.3.1)
Are you using BP? If not then having an interface is completely unnecessary.
Using a sphere collision in that way actually is really expensive. Especially with that many units. It has to do a sweep every time it moves.