#gameplay-ai
1 messages · Page 75 of 1
thank you very much, this will give me food for thought. can you tell me in what format exactly should the EQS be used? Search for the end point of the path or should it work somehow differently? I tried to search for some articles on this topic but did not find anything suitable
maybe you can also suggest some effective way to set up avoidance for AI so that they don't get stuck in each other?
EQS can give you target locations for your creatures to move to, but not how they get there.. so they could still walk through each other on the way.
You are right that you need avoidance to solve that issue. Unreal has Detour, so I suggest also learning that.
do you mean DetourCrowdAiController?
hi Siggi, I think it could compile
I skipped the module of "GameplayStateTreeModule" so there was an error
ok I was just able to make a subclass just fine, I think you are missing a header
by right clicking and adding an unreal class ?
Its important to include both "AIModule" and "GameplayStateTreeModule" in your .Build.cs file
Yeah I included AIModule
I first did it manually, by including this in my header:
#include "Components/StateTreeAIComponent.h"
Only two changes I did to my clean project:
- Added the GameplayStateTree plugion
- Added to PublicDependencyModuleNames in my .Build.cs: GameplayStateTreeModule", "AIModule"
If you are not seeing the components after that, then perhaps you are on an older version of Rider or you are not using the .uproject support and forgot to generate project files?
Did you open the .sln or .uproject in Rider?
Search on google or youtube for "Unreal Detour" 🙂
Yeah I open my .uproject using Rider on my mac
what version of Unreal are you using? Just eliminating whats different here
same as me then
Okay Thank you very much
I will create my project from scratch see what is going wrong
not sure what to tell you, it worked with very minimal project setup here?
What happens when you add a new class with actor base class and change it? does it compile?
this is from my Build.cs:
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput", "GameplayStateTreeModule", "AIModule" });
Okay
This is what the top of my header file for a new class looks like:
`#include "CoreMinimal.h"
#include "Components/StateTreeAIComponent.h"
#include "MyTreeClass.generated.h"
UCLASS()
class STATETREETESTS55_API UMyTreeClass : public UStateTreeAIComponent `
compiles just fine
yeah I can find the statetreecomponent in my rider too
using your configuration
quite weird
Thank you very much
Hi Siggi, I found the solution I had to include the header of the classes in a cpp file compile it
then I can find it in the Rider's "add unreal class"
ok then its a Rider bug 🙂 glad you found a solution
I never even use that function in Rider, it requires so much clicking around
Easier to just pick actor or one of the uobject bases it offers immediately, and change the class the boilerplate inherits from :D
I'm very curious abut this image. What's this about?
I thought you were asking me if I included the header file correctly
This is the header file’s path
Aaah OK just read you use Apple. now I understand what I'm seeing
I though there was some misery command line tool in rider to list dependencies or something like that. Just realized you are simply listing files in a directory Unix style
Why does GetAIPerceptionComponent() return null in StateTreeCondition, but not null in BPTick?
The result is the same even if I use GetComponentByClass().
Is the AI Controller valid? Maybe it's that
I wrote a function in the library that gets the component instead.
Thinking about a bad idea. I wanted to use an classification model to decide rather a player run up/across a wall.
I see there's talk about StateTrees and I've been reading articles that were complaining about them(maybe old), so I'm curious what are people's thoughts on them... are they stable and production ready?
Yes. Room for improvement but there are games out there using them
Great! Can you name any?
never mind I found some
Hey, I was wondering why the Sequence doesn't abort the task when the value change. (Aborts self is activated and the parameter is an object that is required to be set)
Here a small image:
It keep running in this loop and doesn't exit even if the value is at None (fail)
If someone did encounter this, it would be really helpful, thank you ❤️
Problem solve!
(for people who are curious) It is the sequencer not reading the new state of the Blackboard and being stuck in a task. Launching a finish task in the task being stuck solve the issue!
Hi guys! I've run into an issue with navigation and was wondering if anyone has faced something similar or knows how to fix it.I'm the creator of the Layered Fog of War plugin, and I'm trying to make pathfinding take the fog state into account. Nothing too complicated in theory! Here's what I've done so far:
- Overridden
ARecastNavMeshandRecreateDefaultFilterto replace the default query classes with mine,FFOWNavigationQueryFilterandUFOW_RecastQueryFilter - Overridden of the
FNavigationQueryFilter - Overridden of
FRecastQueryFilter, andgetVirtualCostto invalidate polygons based on the fog state. - Overridden of
UNavFilter_AIControllerDefault, add variable to filter the fog state
I've then changed the RecastNavMesh used in the ProjectSettings by mine and then tried the setup.
The result is that it partially works
- without the
CrowdManagerpath is found and the agent get along it - with the
CrowdManagerthe agent initially follows the correct path but then reroutes itself and moves through the fog, which should be non-navigable.
I've tried to debug it but the Visual logger never shows a repath, and the initial path correctly avoids the fog. I also checked the code, and the filter used by the crowd manager seems to be the FNavigationQueryFilter and not my override FFOWNavigationQueryFilter
Hi guys, I try to use statetreeaicomponent, but the state tree exit with information like the selected lines
How can I set the ReferenceActor of a statetreeaicomponent?
Thank you very much!!
What happens when calling StopLogic on a State Tree?
Because the tree is still effecting the Character afterwards somehow.
It seem that the stateTree is not running at all after calling stopLogic
so it actually does not affect anything
Yea I don't know, I'm possessing a character and stopping the state tree logic, but it somehow messes with the character movement or something I'm not really sure.
The character stutters and can't really control it.
As soon as the Walk to node is activated, the stuttering/rubberbanding starts.
Looking at the debug view, I even see the State tree stopping, the only thing I wonder, why there are 9 simultaneous executeion all of a sudden, while there is only one state tree running.
Didn't follow the convo but it sounds like you might be entering the moveto task over and over again if it stutters
Eg. the reason it stutters is because it starts trying to path to it, path to it, path to it...
Try moving your "ST Task Set Max Walking Speed" to a new child state under Constant Wandering, above EQS state
But I called StopLogic on the StateTree, so how would that even be possible?
🤔 yeah in that case I suppose not
I would check in visual logger what is going on with the movement
it usually contains more info on movement and pathfinding
Also didn#t help
where do i find it?
Tools->Debug->Visual logger or something along those lines
the weird thing, if I'm running it locally it works fine, but as client it stutters.
thx 🙂
What should i look for there?
I mean it maybe has something to do with the max walk speed task, if I skip that, it works, but not sure how this can have any effect.
How to make the global task of the state tree run only in the substate? It's like the service for behavior tree.
I found that I could solve this problem with a task that runs repeatedly.
can anyone tell me about what eqs produce in outputs ?like only positions of valid items?
It produces a collection of items that are a sub-set of the ones created by the generator that passed all the tests in the case of filtering only. In the case of scoring only, all the items of the generator will be returned with scores. Using scores then you can grab the best 25% etc.
Scoring and filtering can be combined
if i run the eqs in behaviour tree then what will it return ??
given some location, is it possible to check in cpp if it is inside of some specific nav area modifier volume?
If you already have the pointer to the volume, there's a function within the volume class to chekc if a point is inside.
If you don't have pointers to the volumes, you could do what I do:
- create your own extension of the nav system
- override On Navigation Bounds Added and On Navigation Bounds Removed and add/remove volumes from your collection.
- I have said collection within a subsystem class that also has other functionality related to nav volumes
If you do that, make sure your World settings Navigation setup points to your Nav System Children and re-generate navigation if you use static or Dynamic with Modifiers
eh, seems like it's the same as the first option but volume registration process is reversed.
anyway, thanks. I was just hoping that there's some magic UNavigationSomething::IsPointInsideNavArea(TSubclassOf<UNavArea>())
so this is where all the nerds reside eh
this channel reminds me of the deep sea spongebob eposide
where there are diffirent dark creatures exist
wouldn't the cpp section be more fitting for this description?
nah. they are normal c++ devs there. the real deal is here
ask cup guy
fair enough, I haven't been around here for too long and haven't found the ai stuff to be too difficult so far
coz u still not diven deep to the deeper and darker areas of AI
u still in the surface sir
where life is happy and colorful
Thank you for your kind words of comfort, I am looking forward to it.... lol
I am glad to hear
I've just recently discovered state trees which I plan to use for 50(?) ai characters as I've heard that state trees are more performant and easier to understand than behavior trees
but involve more work
i dont use either
i use bp or mass
BT ig are garbage
state trees seems promising but i cant say yet
BTs are already pretty performant in UE. At 50 AI, neither approach is going to be your bottleneck anyway. It's going to be the CMC. As for ST being easier to understand, I disagree on that 100%. But it is entirely opinion based.
Does anyone know how to restart a State Tree properly? I get to the end of my tasks and I made a task that uses the AIController reference to Restart Logic from the Task itself. It seems to start another state but then immediately stops and the tree no longer runs.
u are the guy in the c++ channel. i remember u helping me profesonally.
why epic does not fix CMC? it is so heavy
on mobile 150 actors with CMC so heavy
↑ I would like to know as well, if CMC is going to be the bottleneck, what can/should I do about it?
They're making a CMC replacement AFAIK called Mover. Not sure if that will handle any of the issues you are facing or not though
looks like it was introduced in 5.4
Seems I was able to properly handle this by simply restarting on the AIController itself in a function instead of letting a task make the calls.
From what I hear - Mover performs worse.
Can't say in a vacuum other than super generic stuff. Have to measure and apply your fixes.
Yea Mover is quite new and I believe experimental, but hopefully over time it will become the standard and surpass CMC in performance. I really like the physics stuff that seems to work on it.
mover perf vs cmc? please tell which is faster
lmao then why it exist
Because CMC is old as hell and they want to introduce more modularity most likely.
Time will tell how it turns out.
CMC is a necessary beast.
ahh yeah typical epic, introduce new features
make it heavy and slow, after few years before it matures and become stable
rerlease new unstable repalcement
then repeat cycle
so angering
epic ruins gaming repuation, now when people hear a game is made with ue5, they panic. an unrecoverable damage to its repuation sadly
i removed epic ue5 logo from my game so they wont know y game made with a stuttery mess of engine
That's just fear mongering.
yes, but people dont know
they see bad games made with ue5 and their brains adapt to the feeling that ue5 games are bad by nature
u cant change their miind, they are not tech savy or willing to spend time
Well, this is the #gameplay-ai channel. If you want to be educated about this, you can go to #programmer-hangout
my friend when know my game with ue5 said wont buy
i was so sad
why duroxxiagr this is happenig why!!!
its alrigth, it is something we can not solve, our fate as a ue5 devs has been sealed. no need to discuss an irrevisrable thing. unforuntally.
This doomerism talk is not necessary.
Super generic stuff being something like disabling jumping, gravity, slope handling? (if I don't need it)
Troll found a new feeding ground is all
If you plan to release, you can't do that. I think you need to pay Epic to remove the logo and that's expensive for what I heard. Either that or face legal consequences
In case anyone wants info about mover, some comparisons vs CMC here
https://youtu.be/P4IKS5k47Wg
The recently released Mover plugin is an experimental tool supporting movement of actors with rollback networking. In this session, we will discuss its high-level concepts, compare it with CharacterMovementComponent, take a look at what's running under the hood, and see what's planned for future development. Please note the README documentation...
ok, to answer my own question. it is possible by projecting location on navmesh and then getting area class from recast navmesh, but I'm not sure if it is good performance-wise because of nav mesh projection step, so maybe it'd just be better to go Brunos approach with storing volumes in some subsystem
Also that will only work assuming you have a nav modifier volume that changes the area class. If you need to know if the point is within a nav mesh bounds volume, that doesn't work
I was referign to the later
oh, then we misunderstood each other, because I was specifically interested in detecting whether some location is affected by some nav area
Aaaah OK then yeah, you are doing exactly what you need.
u are wrong.
no I'm not. I have been through that. You are forced by the EULA to acknowledge, which is usually by showing the logo. I know some games that reached an agreement with Epic to not show the logo in their splash screens but that costed them money + adding a bunch of stuff in the start section of their credits (I believe games made by Sony with Unreal do something like this, like Astro Bot and Sackboy ps5). You also can't change their logo unless you get authorization (Rime from Tequila Games has a custom one for example). There are other ways to acknowledge them aside the initial splash screen logo, but they need to be approved.
Of course you can ignore all that, but you might face problems if Epic realized it and wants to take action (there are legal precedents)
Some info here (btw, I'm not the Bruno in that thread)
https://forums.unrealengine.com/t/is-it-a-requirement-for-all-unreal-engine-games-to-display-the-logo/126426/6
There is a Trademark Usage Agreement that you need to sign (it is a pdf which you will fill the missing data and send back) and you will be pointed out where to find the logos, pictures and rules for colors etc. Just send an e-mail to lauren.willoughby@epicgames.com and you will get the info!
sorry everyone from poluting the AI channel with unrelated topics
does not matter, they wont know my game was made by ue5
by the time my game gets big, i hope the repuation of this engine to get restored back then i will look into putting the splash sceen back into my game
thanks for the information
so, I need to make characters move in a formation. I plan to use a custom subsystem to store information about the formation structure (what units are in it, who is the leader, etc.). Then, in the behavior tree, when moving, the leader of the formation will, using a custom service, periodically generate coordinates of the formation relative to the leader and, using the subsystem, distribute these coordinates between the characters. Accordingly, in this way, everyone except the leader will periodically adjust their location so as not to break the formation. How correct do you think this solution is and can you recommend anything else?
Sounds reasonable
So I've tracked down an issue with my State Tree building up lag over time due to using Event Tick on one of my global state tree tasks. The task is used to update some global variables as well as check some conditions which the AI needs to know on tick basically. Is there a better way to do this or can I at least slow down the tick rate somewhere?
Hmm I found where I can turn down the tick rate of the entire State Tree. I guess I'll try to build in something for the global task itself perhaps.
I find interesting that your AI needs to know anything on a tick basis. What is that it needs to know?
I have a pretty complex fighting system where during any specific state tree state it may need to block based on what the focus target is doing.
That's just one example
I do the same, but it's an event driven thing: upon being attacked, a g.tag is assigned to the attacked AI. If the tag is present, we do X thing. When the attack finishes, tag is gone.
Right, but there is no state to say "i've been attacked now block" it's more of is this attacker doing anything now? How about now?
We use to have checks on tick like you for many things, but it was not feasible performance wise in the long term, so we turned everything event driven
And it's also distance based, so is this attack close enough to be blocked? Ok then use block
We handle all this through GAS in a quite complicated way, since we have block, parry, dodge... You name it
Sounds very similar to our games
Souls likes
I am also using gas to trigger things as well, I'm just not sure how to tell the AI that the attacker who they are locked on to is close enough and doing A, B, C attack without just checking from a global task
Mine's just a multiplayer fighter
Yeah that one might need way more accuracy frame wise
Your approach is probably better for your game
I'm thinking eventually it will just be a tick rate tweak and also make the task a C++ only task if it's running every tick
Physics using overlaps could work
Very annoying right now though in the prototyping phase
Yeah...
The range is rather ridiculous though, like 4000 units to check sometimes
Or 2000 usually
You could have a specific component with its own tick rate for this things
Yea I might have to just make it happen in its own component but I'm not entirely sure that will change much. The problem might just be trying to do so much on tick while also running AI logic
It's weird though when the AI dies and respawns, the framerate subsides
I even tried calling a reset after they kill me and it doesn't do the same as the AI dying
Hard to track down, but it does appear when I disable the tick task that it doesn't drop framerate over time
And it doesn't seem to have a limit either. Appears to be like I will eventually have 2 FPS if I leave it long enough
hey guys i need some insight on how you would approach this maybe my head is fried for now haha but i got 3 giant AIs in which it will only get vulnerable once all the protector minions for that giant are dead. i got the titan and minions behavior done, any suggestions on how should i link both of them up to ensure that only giant "A" will get vulnerable once the minions for this giant are dead? I will have a total of 3 giants in my map
Anyone got this problem while playing built version? I create a custom service using instance node memory, I also implement get memory size correctly, it work perfect on editor but have trouble on build.
Can you show us your implementation of the function? Have you also implemented Initialize and Clean?
Many ways, none are more correct than others. Does your giant know about the minions?
I figured it out, it took a whole bunch of time to debug this. Apparently, even though the memory struct is not public, if you have 2 private structs with the same names, the sizeof(StructName) will went wrong.
I just renamed the struct with my own project prefix so it looks different.
at the moment not yet but it should
Once you have that, you can just make the giant register to a delegate that broadcast on death from each minion. Once all of them trigger, you can di your logic
any suggestions on how should i make my giant know about my minions tho?
there are many ways.
It could be your giant the one spawning the minions and the registering would happen at that moment.
It could be the minions spawn on their own and they have a property/data/component/g.tag that marks them as "protectors of boss"and they look for a boss in the map and register themselves to its TArray<Minion> collection.
It could be you have spawners for those minions on the level and you giant spawner is linked to them
It could be that the giant spawns the last and, upon spawning, it searches for minions to register to their death events (with an EQS for example)
many ways. Up to you which one is best for your system. Probably one I haven't listed
is State tree breakpoint system bugged? I place break points but they never get hit.
Like the AI never stops as if I have placed zero breakpoints
I don't remember for sure but at least with BT's, the debugger won't always work unless you select the actor / bt owner you want to debug with. It has a selector for it in the top menu bar, I'd assume the ST editor has that too, so I'd check that first.
If that doesn't help/exist, try enabling the ST debugger from the menu in the ST editor, perhaps that's required to be on for the breakpoints to hit
ooo okay thanks! gave me some ideas on how to do it
AIPerception sees me through the wall even though I have collision block
Weird but ya after selecting it started working
Thanks
do the wall have collision?
sure
maybe they are not using the right physics profile?
@forest tundra ya what this person said
as far as I understand, the standard "DetourCrowdAIController" prompts the agent to go around the obstacle. I need more of a behavior like it works in StarCraft 2 - the unit should push away the obstacle. Can you advise something about this?
I think the simplest way to do that would probably be to allow your agent to overlap, and apply a pushing force to things you're overlapping with
yes, but if agents push each other it won't work
I don't see why not. They would probably cancel it out
not around. That's a missconception many people have. It's more a "lest push you the minimum possible to avoid you getting stuck against other fella"
and then you can parametrize that a bit to have a bigger push/detection radius and some other stuff
Well, it works in a very strange way, I couldn't set it up properly. Maybe you can recommend some information on how to set it up?
that's the best I got. Haven't used in the past 2 projects so.. I'm a bit outdated
@chilly nebula sorry to tag you, but this is another black hole in Unreal's AI: almost no documentation, almost no examples and lots of mysticism around
Why when I use RunBehaviorTree multiple times on the same AI, it creates multiple instances of BT Task ?
I don't think so
basically you just specify which BT to use
When i run twice the same BT, it does create multiple instances of tasks
Hi! I'm starting to work on AI (no prior experience with it tbh), and I was defaulting to using Behavior Trees. But then I just discovered about this new State Tree thing. I've searched a bit, but the pros/cons of each are still a bit unclear to me.
My logic is generally pretty simple and mostly boils down to a priority list. BTs seem to handle this extremely well right off the bat. I might just be misunderstanding how they work, but this kind of logic seems much harder to handle using ST?
I'm mostly concerned about reusability, as I'm expecting dozens of different enemy types, which will require custom AI. They will be mostly similar, but require unique logic as each will use different skills and such. I could work on a monolithic generic AI that can handle every enemy I guess, but I'd really like to be able to add unique features and do custom tweaks here and there, so I'm not hot on the idea. I'd like to iterate fast though, so working from scratch every time would also suck.
I'd really appreciate any suggestions, thank you!
Is it running through the extract same path in the parent bt? What I mean: do you have a single Run BT node in the parent bt running that child bt? Or do you have two nodes that can run the BT?
This question is tricky.
My advice seeing you don't have experience? Stick to what feels better and it's easier to understand and use for you and your game.
There's no better or worse outside your specific context and reality
The reusability problem exists in both and both are solved by your approach. The more data driven the better. Don't have Attack for enemy A and atraco for enemy B. Have a node Attack that call the attack function on your AI, being it's implementation different on each Ai. Same st/bt, different usages
If you use that concept with subtrees (bt:s or st's) and you read what to run from a data asset, you will have even more flexibility
Thanks a lot for your input!!
sorry for late reply here, catching up 🙂 take a look at what we did for tasks in 5.6 before building anything on your own. Massive amount of work to optize tick, reduce the need to tick and allow custom rate and scheduling.
Awesome! Thanks for replying. I figured out part of the issue was actually just some niagara systems sticking around for too long. I look forward to using the optimized version in 5.6!
just learned how important "Categories" are, thought they were just for convenience
In state trees they get a whole new dimension of meaning
I can't seem to be able to pass a character reference from a global task that uses ai perception to another task... the global task works as I can retrieve the character after setting it
but in the chase task, it's blank
Wouldn't it be useful to have a settable Tag in AIPerceptionStimuliSource when registering sources for senses? Stimulus has a prepared Sensed Stimulus Tag member for this, but unfortunately, this seems to be only usable in conjunction with Report Noise. This looks kind of inconsistent to me.
I sort of got it to work by storing the actor reference in the character bp but that feels wrong
returning to the movement in the formation. Using the ECS turned out to be ineffective. I am now doing this through the subsystem in the Tick Event, the photo shows two methods that are called.
It works better already, but I suspect that this is also not a very effective solution. How adequate do you think this solution is and how can it be improved?
Ideally, of course, you would redefine the navigation logic itself to adjust the movement vector at runtime, but I'm not sure how difficult it would be to do this since this is quite low-level logic.
if you use default MoveTo, do you take into account that your formation members destination points should consider where the leader is going to be in X seconds instead of just where they should be right now?
since now every frame is adjusted, I think this is not significant
What's the typical way to save/load behaviour tree/state tree state? 🤔
Someone was here at one point claiming you can just straight up serialize/deserialize a BT component, but I never got that working. Haven't tried with StateTrees.
I guess the question is if that's even intended, or if the answer is "dont do that, just restore that data in the blackboard and hope it starts back up in the same state"
It's kinda hard to say tbh. It seems like any non-trivial AI would not be able to go into the previous state purely from BB or other readable state, or to do so, it would require an incredible amount of extra decorators to ensure it does so
How are you setting the CharRef in the global task? its possible your Chase task is running before your global task has had a chance to if its in the first state that is run.
Im expecting this to be fixed in 5.6 though.
A few possible fixes for you:
- Use an evaluator instead of a global task
- Use a property binding function to get your character reference.
Ah good, I was thinking about pinging Siggi about that question on saving/loading BT and ST state :D
Siggi, would you happen to have any insights on that question from Moritz?
State Tree only keeps parameters in memory that are on the active state path, so global parameters and parameters/output params on all active states including the root.
I'm actually not sure what the best approach would be here, but I'll ask around... its a good question!
Nice, thanks :)
In one of my projects the solution was to just... not allow saving while NPC's were present lol... I do have another one where it just resets the tree and the AI figures it out from there, but in that one the logic was a lot simpler.
I see that FStateTreeReference can be serialized, and we now have a method on the state tree component to set the ST reference directly. So that might be one approach.. nope! This is only the asset ref + values for the exposed parameters.
I'm checking if I can get you a better answer
One thing I like about FlowGraph is that it's been designed with this in mind, so it slots in quite well into situations where you want to save the graph execution state. Each node can have its own save/load logic quite easily. I could see that being a slight issue with BT and ST since I don't think the nodes have functions that you could override to deal with loading their state or such
I do save/load bt's on demand. My solution is to back-up the Instanced tree memory and restore it when needed. That saves/loads the data from the BT nodes but we can only do that with custom nodes. Many engine nodes clear the memory when they stop being relevant and then you get trash in the memory of the tree that will crash the gsme upon restoring it
I do this because we run trees independently and we can come back to them. We need to restore the previous state of the tree in combat situations, specially for utility-related nodes
Interesting, I'll have to keep that in mind :)
I think my BT design in cases where it's been particularly problematic isn't the best, but more pressing issues than redoing the whole thing :D
Ok, there is no easy way to wholesale serialize a ST, sorry 🙂 I recommend an approach similar as people have replied above, to set your AI up in a way that it can be restarted and will be able to pick things up again.
You can always manually serialize anything you do want to store, like a target being chased, save it and push back into a re-initialized tree.
If you really want to explore serialization, you can get part of the way there by looking at what is in FStateTreeInstanceStorage.. but things like state of tasks being executed or transitions in motions are tricky.
Yeah thought that would be the case, good to know thanks
When I click on the ground to move the character, I call BrainComponent->StopLogic and CleanupBrainComponent and RunBehaviorTree, but if I click x times, it still instances x times each BT's tasks.
Stop logic deletes all the Tree instances the brain (Behaviort Tree component in this case) has. Why are you calling that before moving?
Because when I trigger another behavior, the previous behavior has to be stopped (je suis FR)
but you don't need to do that stop logic. You simply call RunBehaviorTree with the same AI controller and the new bt will run stoping the previous one and keeping its instance
AI's in unreal can only run one BT at a time
Wait... calling run will call Stop on the tree, which I believe is also cleans the instances too. I would need to check
If you want to keep instances around, you need to use sub-trees
Only one BT is run at the time, but when i call back an already used behavior, I can see I have multiple instances of its tasks
I want to delete thoses instances, it is wasting memory
Well the best way would be starting by making your nodes Not Instanced (only possible in c++)
The second thing is that, when calling stop, the tree component will clear the BT instances array and, with them, all their memories and the Known Instances. You shouldn't have any node instances alive at all
without checking the code is difficult to say but, seeing you are running trees independently, you should make your nodes not instanced and rely on their memory to store values while they run
I clicked several times on the ground to move the character, and have multiples instances of BT's tasks
I have a BT for each behavior
Do you have access to c++ or do you use it? I'm not 100% sure if that list is representative of the currently alive instances of the task
I am working with c++ and BP
the instances represents the number of times I clicked on the ground (except the first BTT_MoveToLocation_C_0)
ok, then you can set a breakpoint in your task tick and see if it stops several times and check if the pointer is the same (only one instance alive) or different ones (one per instance alive)
yeah but that doesn't mean all those instances are actually alive and in memory
It might be the case, but I'm not sure
thank you for your help i ll come back later
Is there some way to get BT's "abort lower priority" logic in a State Tree? Or do I have to setup transitions everywhere?
As in "if low on health, stop what you're doing and heal yourself". Is placing transitions everywhere the only way to handle this?
Any recommendations for learning State Trees, ideally something that's either up to date from beginning to end with 5.5's improvements or at least has followups that go into changes/improvements?
Nothing like that, no. One of the things I gave feedback on last week. But what you can do is set up transitions on events from the root state and have it transition to the state you care about. It is sort of like what you want.
It at least saves you from having to manually place a transition on so many things.
Best you can do is the docs really. Most YTers don't know what they're doing either. So that is a pit of despair.
there's some stuff in the pins of the chat. Epic also has some documentation here and there. Some videos posted here (That might or not be in the pins)
The ST overview doc and then the your first 60 minutes with ST docs are pretty much the best places to start.
Then you just experiment from there.
👍
And 5.6 is going to bring even more changes
I was mostly hoping there was some amazing breakdown out there to help me minimize the 'wonder why something doesn't work, poke it for hours, finally come here and someone tells me actually that's just kinda screwed up at the moment' cycle.
I saw this when I was looking into pros and cons of State Trees and it made me a little gunshy, especially since the update note near the top doesn't really elaborate on what's improved or solved compared to when it was written.
https://jeanpaulsoftware.com/2024/08/13/state-tree-hell/
You can probably search this chat for mine, Bruno's, zomg's, and others feedback to Siggi on issues with the ST in its current form. It was only a week or two ago.
Really the big issues are:
- Doing async stuff is frustrating. IE - multiple tasks on one state.
- Data flow - how to pass data around the ST overall. As well as from outside sources, this includes reactionary things. And also if task B depends on data from task A but task A is an async action (ties in with point 1)
And I know Bruno brought up some stuff with the debugger for it as well. Just don't recall.
However, Siggi has told us that a lot the stuff we brought up was already on their radar and there are some changes coming in 5.6
So, we'll see.
Neat, thanks a lot!! I'm glad I'm not the only one missing that feature haha. Gonna experiment a bit with what you suggested, but ultimately I think I'll be going back to BT (which I'm sad about cause ST seems super neat otherwise)
As a heads up - they do plan on deprecating BT in the future.
Most likely sometime around UE6 or during UE6's lifetime.
Wow, straight up deprecating it? 😮
Yeah. Hurt my heart as I really like the BT, but it is what it is.
ST is the future.
Of course that info may not matter for you. As your game may get released long before it even happens.
Yeah, thats a shame! It probably wont affect me directly, but its good to know
Wasn't it just stop giving support/new features? I can say our designers don't like st's interface and how difficult is to track logic on a simple glance vs bt's and I'm pretty sure we will have to strip bt's from their dead cold hands
Nope. Mieszko said it is being deprecated around UE6
Seems unreasonable to deprecated something that works and is super well documented and standard in the industry
will keep existing until last dying breath of BT in Unreal (so roughly until UE6).
I did a PR to get rid of the blackboard wait task because of the changes they made where all the tasks can accept a BB key now.
No no, there's no depreciation there! Just dying! LALALALA I HEAR NOTHING....
I agree. But I imagine it is also because BT doesn't get much attention from them anyway. And you can model a ST like a BT as well.
Plus, as you know, I do prefer the BT over the ST 😅
I tested with the breakpoint in the task tick, and it appears only the last created instance is ticking
I found an interesting effect: if having small values like 12 degrees for Peripheral Vision Half Angle on the sight config, perception fails, if the stimuli source (exactly in front of the sensing actor) is too near. Doing simple test shows, that at some increased distance, it gets detected.
In terms of helping to automate Blueprint creation, are there any GenAI tlools that are
- inexpensive
- reliable
and - respect data privacy
Unlikely 😉
The ones that exist to generate text code are still quite unreliable. Godspeed if you find one to generate BPs.
Nice
Where is a good practice location to store the data for who is in my party? (Single player rpg) PlayerController or GameMode?
SinglePlayer? Doesn't really matter. Pick whichever you prefer.
Is playercontroller reliably persistent?
Doesn't persist through map changes. Otherwise, yes.
Hello. How can I set a blackboard value as a struct? it gives me the option to use a struct in the blackboard but there is no Set Value As Struct function?
Game mode does though, so ill use game mode just in case my idea for level management changes.
True?
No. Not true.
wouldn't that typically go in the save game? thats probably where I'd try and put it
i am not smart though
GameInstance is more common to handle things that need to go from map to map.
Or you can use seamless travel
But so far, none of this is #gameplay-ai related
Ok ty
Never tried to use a struct as a BB value to be honest. I'd imagine it is poorly supported.
First time I'm even hearing someone try.
So the question is then - why are you trying to use a struct?
Its the way I'm storing stuff my NPCs perceive, so I can have a sort of gradual detection
It'd be copied to the value and not be a reference though
So it's more of a snapshot in time
yeah, the code only tells the blackboard once something is fully detected so it can go and do investigation tasks
You can retrieve the struct through the controller or pawn as well. As that gets passed to each task.
Yeah, that just requires a simple vector or target actor
this might be a design flaw, yes. I will try retrieving the struct like you said, thank you.
scam
<@&213101288538374145> 👆
I got it to work somehow with an evaluator, not sure if that was the fix or I just needed to mess around with it to familiarize myself with it some more...
I hope they come out with an update soon as I often find myself having to reload the editor to remove the variable remnants after some changes
I think I use it but it's definitely form c++. Would need to chekc
So, for something like an attack, I've stumbled my way to having a task send a gameplay event to the pawn to trigger whichever attack gameplay ability, with a reference to the task stored in the payload which I use to finish task as success or failure within the gameplay ability.
Is this a crazy person approach, and if so, what would be a better way to go about things? I guess I could tell the task to wait for a gameplay tag on the enemy and finish appropriately when it sees that instead of passing the reference, if that's less weird.
Hey everyone! I’m not using BT for my AI, and I have the AI moving to the player. But I’m using 2d assets so I want the AI to prioritize the y axis and make sure hes lined up close there, and less close on the x- is there a way to input custom acceptance radii for each float?
Sounds reasonable
Hello everyone 🙂 I'm looking for a course/tutorial or similar that guide me to implement 3d pathfinding from scratch. Do you know any resource that could help me?
Thank you in advance
I'm not understanding filtering at all. I have a test here that returns 0.f or 1.f based on some conditions. If I test the scores, this is returning correctly at least if I show the scores and their related data set.
But when I set up a filter with a minimum of 0.5 I would expect to only get results for the 1.f entries. But I still have the 0.f entries in my query.
What am I misunderstanding with this?
Nevermind. This was my derp. 😄 Wasn't using the filter values.
I've done nothing beyond set down a navmesh and plop in "aimoveto" but my AI seems to want to hug walls and get stuck as a result.
What can i do to get wiser ai?
What is the general approach to doing a continuous EQS and MoveTo with StateTrees? I've tried a few approaches -- Running the env query as a single task in a state, then running the moveto task in a sibling state, but this results in the AI moving to the location and then running a new query. Ideally for my case, the tasks would run parallel for the same state, so I've tried some hacky workarounds, but none of them seem to work smoothly or reliably
What is the intended effect of using Enter Conditions in state trees? If I put a couple enter conditions on a leaf state that don't pass, then put a Next State transition on that leaf for completed, failed, and even succeeded, it doesn't seem to continue on down the chain of sibling nodes like I thought it should..
I was under the impression that if it fails the enter conditions, it would simply continue on the chain of sibling nodes if the parent was Try Select Children in Order
Sounds like the nav agent config used doesn't match your AI's character capsule radius.
You can try run the eqs in a global task
The transitions are related to the state result, which is usual defined by the result of a task. If the enter condition doesn't allow a state to run, there's no result because its task will no run, so no transition. Sibling nodes will not run (or evaluate) if the parent doesn't run
The se way that a running parent will evaluate all its siblings at the same level in parallel
Interesting. So how should I be using the enter conditions if not to stop a sibling node from being executed while the others are? Or more specifically how can I achieve this result? The only method I have found that I'm currently implementing is to completely nix the enter conditions and just run checks in a custom task.
ConditionPass - StateA runs
ConPass - StateA.1 runs
ConPass - StateA.1.1 runs task1
ConFail - StateA.1.2 doesnt run
ConPass - StateA.2 run task 2
So it's to fail a parent node then?
And all of its children
Or at least past a specific node that failed
If a parent state can't enter, its children will not run
A sibiling (if any) will be choosen (assuming that's the setup on the evaluated state)
So basically once it hits a fail node, the rest of the siblings are caput if I understand correctly
But the ones before it still run
The children, not the sibilings
Hmm well what I'm experiencing is that the siblings after a failed sibling no longer run at all
A practical guide to understanding and working with StateTree as it relates to AI. It covers key concepts, terminology, and execution flow for StateTree. This is accomplished while building a basic wildlife AI agent using the new StateTreeAIComponent. https://dev.epicgames.com/community/learning/tutorials/lwnR/unreal-engine-your-first-60-minute...
I was hoping the enter condition would just mean ok don't run that sibling node, go to the next
That's what it should be
Hmm ok. Well it's not super straight forward then I guess. Yea I will need to resume this with you Monday or next week if you have time and don't mind, had to step out and won't be at my desktop to show pictures. I can describe though, I had 3 enter conditions ANDed together and anytime one failed, the sibling node wouldn't run and it kicked back to root for some reason even though the enter condition node had transitions for failed, succeeded, completed to just go to the next state. I also tried transition on tick but nothing was working.
Are you using the debugger to know what's going on? I would start there
I have been, but for this issue specifically I did not breakpoint it. I'll try again next week and let you know what I find. Thanks for the help.
Ah, the capsule is hella small for some reason 🤔 I didn't leave myself any notes
Has anyone had issues in c++ state tree tasks with instance data not resetting. Possibly something to do with a state transitioning to itself
Unfortunately, that doesn't update the MoveTo task correctly, because I'm trying to get the FVector location result from the query. From the source code, it looks like the StateTree MoveTo task will only track moving goals when using actors
The instance data doesn't reset unless the tree stops. It's kept for its instance life cycle no?
Ah you want re-pathing to a location... Yeah that's not supported by unreal, repathing within an AIMoveTo async task only happens for actors (the path event on goal actor moved triggers it) . The work around is to have a very very simple actor (no components but the scene component, no ticking, no collision) that it's handled by the AI. When your eqs produces a location, se the actor location to it. Your movement task will move towards that actor. It's a more or less common approach in unreal.
I was afraid that would be the case -- I didn't know that it was a common approach though!
"common"
The other thing is that, running eqs on tick generally sounds like a bad idea. What's the use case?
I thought it was for task life cycle, I guess not
it kicked back to root for some reason
There's a specific behavior in the StateTree system: if the EnterConditions returns false for all children states of a given parent state, the system is designed to force a transition back to the root state.
If you are seeing the message "Could not trigger completion transition, jump back to root state" in the StateTree debugger, this might be the situation you are encountering.
For example, in the StateTree shown in this image:
- All state's
Selection Behavioris the default:Try Select Children In Order. - The
Fail_Cond_0state has EnterConditions where its Test always returns false. - The
Fail_Cond_1state also has EnterConditions where its Test always returns false.
When this StateTree runs, after Wait_0 is completed, it will transition to Wait_0 again, and this will continue forever.
All but Root and Wait_0 (such as the Wait_1 state) will never be active.
I'm not sure if this exactly matches your situation. Sorry if this isn't relevant to your problem.
( By the way, in the CitySample's StateTree, it does not jump to the root even though all children's EnterConditions fail, so there seems to be some setting for this issue, but I have not yet figured out what it is. )
Additionally, there are several other pitfalls associated with EnterConditions.
For example, if a child state's EnterConditions depend on the StateParameter or TaskOutput of a parent state that is not currently active, that EnterCondition check will always fail, regardless of the actual value of the TestCondition function would return. (Strictly speaking, the TestCondition function is not executed. )
In this case, you can see the message "Evaluation forced to false: source data cannot be accessed (e.g. enter conditions trying to access inactive parent state)" in the StateTree debugger.
(https://github.com/EpicGames/UnrealEngine/blob/2d53fcab0066b1f16dd956b227720841cad0f6f7/Engine/Plugins/Runtime/StateTree/Source/StateTreeModule/Private/StateTreeExecutionContext.cpp#L2741 )
Because EnterConditions can have these kinds of pitfalls, I am considering using Tasks to perform the check logic instead of EnterConditions.
For instance, the image shows an example where:
- If the CheckCooldown Task succeeds, the StateTree transitions to the Log_String state.
- If it fails, it transitions to the Wait_OnCheckFail Task.
I'm trying to use EQs to position enemies in a top down fighting game. They position themselves around the target at certain distances and locations in order to execute melee attacks. The queries aren't huge, maybe only testing 8 points each
Ideally, I wasn't going to run the EQs on every single game tick, but adjust them based on performance
Wow what a thorough investigation and information, hugely helpful and I will be checking all of this next week when I look at it again. Thank you so much! It probably is one of the conditions you mentioned although the other sibling states are passing properly so maybe it’s the latter case where it uses information from a non active state. Either way, I too decided on using checks in a task instead and it works well so it will just be an investigation for me of why enter conditions aren’t working the way I thought they would.
Any ideas on what could be making that BT Search and BT Execution Time act like that? I'm not positive what those are, but need to keep that .5 ms spike from happening in our AI^^;
I have seen that with Run Dynamic BT
But could be something else. Where was the capture taken from?
We do have one instance of "Run Dynamic" in that BT, but it shouldn't have been getting hit I don't think... hmmm. When you say "where" are you asking about insight, or the circumstances or?
If it's a Test Build or Development or what
That was in the editor
Yeah never measure perf in editor. Is nowhere near reality
That could be a debug print, a debug draw, a log print, an ensure somewhere....
Measure in a test build better
gotcha, fair enough, may have freaked out too soon on that, but thanks^^
Understandable XD
If you compile your own editor etc (form the epic source code) you can always temporarily add cpu text stats in the engine functions to figure out what happens and remove them later
https://streamable.com/bu9jba
Hi guys, I have a problem, i was working on ai n i created patrol. but the animation bp stoped working, so now my enemy just moves in A pose, how can i fix this?
You'll want to watch your AnimBP run and figure out where it's getting locked out and fix the conditions there. Otherwise will need more info to be able to help^^;
Does anyone know any good resources that tell me how to make a car AI, Not one that follows a spline I want it to randomly drive around all over.
That would be no different than non-car ai
really just the gameplay/rules that you would have to implement, like speed limits, stops, etc.
hey my root is never being triggerred any help first time doioing this?
does anyone know?
ah in "my tree is never running" or what do you mean?
Why didn't it enter the "middle Range" State?
There are many reasons why a state tree may not work, so it is a good idea to start by creating a minimal example.
If I were you, I would create a StateTree asset with just one State which has only a DelayTask, as shown below, and check the display in the StateTree Debugger.
if it works, StateTree Debugger will show Root.Wait0 like this.
If this minimal example does not work, the cause is probably something other than the StateTree asset.
For example, you may not have assigned a StateTree asset to the property of the StateTreeAIComponent of the AIController.
If this minimal example works, then there is a problem somewhere in your ST_Wildlifeaione2 StateTree asset.
For example, the AIController Class and Context Actor Class in the area surrounded by the pink frame in the image may differ from the classes actually used.
For more detailed information, I think this URL is very helpful.
https://zomgmoz.tv/unreal/State-Tree/Troubleshooting-State-Trees
hahah this is so stupid i been using other debug tools for it and found out they dont seem to work?
break on enter?
just spent5 2 hours trynna get this to work thinkign it was never entering the root lo
could someone please help?
I'm making a basic enemy that just walks up to you and attacks you for now. I want to just get the basics out the way first. but I'm also using the gameplay ability system as well and everything works. The enemy comes up to the player and attacks even though my anim montage doesn't seem to be working, but I think that can be something I can fix later. issues I'm having when the enemy attacks: the player does take damage, but my bTT_Attack never exits, and even with a breakpoint, it doesn't fire. I just need someone to tell me what I might have missed. I will post two screenshots, one of the actual ability and the BTTask.
GA_Attack_Punch: https://blueprintue.com/blueprint/i5sgyyq4/
BT_Task_Attack: https://blueprintue.com/blueprint/4h2kuhn3/
Actually, never mind, I am so dumb I ended the ability way before the montage finished, so my event never fired, lol
sorry
hi! I'm using a MoveTo node in the Behavior Tree to move to the location where the AI starts but it doesn't seem to be fully moving to that location, it stops at a different previous one. anyone knows why it might be happening?
It's probably the radius of the capsule being considered for the location overlap
then how can I fix it? I just have to substract the radius of the capsule to the location or is there a better way to not have to calculate it for every location?
Perhaps turning off Reach Test Includes Agent Radius in MoveTo would help.
https://dev.epicgames.com/documentation/en-us/unreal-engine/unreal-engine-behavior-tree-node-reference-tasks
If you use big Acceptable Radius, making it small also may be help.
I can't test it right away so I apologize if I'm wrong.
oh yeah, it was the reach test. thanks a lot <333
Anyone here that uses custom Nav Areas can help me out figuring if something is a bug I have or something the engine does by default please?
The test is simple: if you drop a nav modifier volume on the level and you set it to use your custom Nav Area, upon generating the nav, how do the flags por the polys withing the nav area look like?
Assume your nav area generates flags in hex 0x200
I was expecting the polys to look 0x01/0x200 -> that is Poly Flag is default, nav area is your custom area
But to me the poly are is showing up as 0x200, which messes up with our logic because we have custom poly flags.
I just noticed this so no idea since when is this happening
This is what happens to me with my custom nav area
Is there a way to "spoil" pathfinding to make it return x-th best path from point a to b? I have a piece of logic where NPCs predict a prefire location (a point to focus on when waiting or moving to enemy instead of focusing on enemy directly) by getting a path from enemy to themselves and the prefire location is the 1st point of the path where nothing blocks visibility for NPCs. However, when a level geometry is complex, most of the NPCs look at the same path, since it is the shortest one, leaving another potential path unwatched. So the only idea i have right now is to instead of making a path from expected enemy location to an NPC, run an EQS to find a point in proximity of the NPC (with some tests) and use a path from enemy to this point from EQS to get a prefire location, but this sounds like a hack to me 🤔
uh, should it maybe be AreaFlags |= fireFlag instead? I mean if you expect 0x201 and get just 0x200 maybe it's because you're overwriting bitfield instead of appending bits to it?
I'm expecting 0x01/0x200. Not sure where in the engine source is the polygon flag being override with the area flag
To be clear: are you trying to make AI's use different paths to get to the same location?
what do you mean by 0x01/0x200? do you mean that you want it to return true for both AreaFlags & 0x01 and AreaFlags & 0x200? if so, you need to concat the area flags in your constructor
AreaFlags |= 0x200; // not AreaFlags = 0x200;
as it is set to 1 in UNavArea constructor
no, i don't need them to get to a location, I need them to find different paths to the same point when in general they would always get the same, A*-shortest path
and then I iterate through path points to find a point that would be a good "look at" location when there's no direct LoS to an enemy
nav flags for a polygons are in contained in 16 bits (uint16). One part is for poly flags, the other is for Area flags.
If you look at the image (or if you enable Show Poly Labels in your recast object while showing the nav in editor) you will see both set shown in hex format.
[0x00 (poly flags) : 0x00 (area flags)]
For default nav area, the flag is always 0x01, meaning you have nad data in that poly.
So the expected (or at least what I expect) is to see [0x01 (there's default nav data) : 0x200 (the poly belongs to a Fire Area)]
In other places, because we do poly manipulation data, we have it right but, as default, the area flag is used everywhere
maybe you can get the first path and, once you get it, mark the area more expensive. Then the next path will use other locations that are cheaper.
Not sure how you can marke the costs without using nav areas, but I'm sure there's a way to temporarely mark polys in the level
you could simply temporarily change the are flag of the affected polys to Obstacle (I think they have a super high cost)
Sadly thats not really how a* works, there's no nth worse paths it finds. What you're looking for is shared squad behaviour, as bruno said probably something like marking up the path corridors if somebody in the squad is already moving along that path
I'm always asking myself whether to start using State Trees vs. BTs, many discussions just lead to some it depends. Now when starting a new project (which may take lot of time to finish), this makes me think again if it would be an option to go for State Trees, also the fact, that there's so much discussion on them - so in long term, looks like it is worth giving them a try? Do you have any reference, where that deprecation has been announced?
I linked Mieszko saying it
alas, can't tell anything helpful on the matter. also i'm not sure if it means anything but in dtPoly flags are ushort and there are some bit mask operations where it seems only 6 bits are dedicated to areas so maybe this could give you an idea to look further
yeah I need to look into that because one thing is what unreal does and another what DetourRecast uses. will se what I find tomorrow. Thanks for pointing that out
Oh, sorry, just did miss that link... been kind of blind...
thanks, yeah, I was just hoping that there's already a solution for "give me next-best path", but Bruno's solution sounds legit, even though it'll take me some time to implement
When you obtain a path, you get what is called the Nav corridor. That is the object holding all the polys and nav edges used by your path. You can use that to flag the polys before the next path calculation
You will probably still run into issues with this, since now youre marking up all of the poly in the path so other NPCs might start doing very weird paths in order to avoid all of those polys... Depends on how sophisticated you need it really this can be a quite difficult problem to solve
Finding a better way to spread out the found cover points may be easier and still solve the problem, but depends on the game
yeah I thought about it, that's why i mentioned that it'd take me time to implement. There's also a question when to release the "heavy" flag from polygons and what if there's only a small piece of a polygon in the nav corridor but i'm about to mark it completely. but still something to start with
Someone played with the GDC Boy and Kite demo on last versions aka from 4.27 to 5.5 and knows why the navmesh seems to don't work even if the invokers are there isn't generating or something strange going on
Dumb question: if you're making a door that can open and close and needs to affect navigation via smartlink, should the door actor itself just be a subclass of ANavLinkProxy? Or is it better to have a door actor, and then separately place a nav proxy? The latter feels like more effort to maintain so I'm leaning toward just having the door be a sublcass of ANavLinkProxy but I'm wondering if there's some other downside to that.
Okay answering my own question: don't do that because the proxy actor sets itself hidden and turns of its collision so it obviously isn't meant to be used that way, heh.
iirc there was a navlinkproxy component that you can put on the actor. I remember seeing something like that but can't remember making it work 🤔
Yeah there is but it's not a smart link so it doesn't have the convenient API for enabling/disabling or reacting to an AI reaching one of the link points (e.g. to open the door for them).
Seems the right solution is just to have my own native class that can add smart link components and use that as the parent for my door blueprint.
I suppose a ChildActor component on my door with a nav link proxy actor would also work but I fear those stupid things (ChildActor components).
Well...actually it seems like nav proxies don't work as child actors in 5.5? If I place them in the world directly they work fine, but any I create via ChildActorComponent don't work. One more reason to hate that stupid component I guess.
Seems someone else encountered this as well and maybe it broke in 5.4: https://forums.unrealengine.com/t/navlinkproxy-child-actor-smart-link-in-5-4/1946864
I would like to ask for advice on how to properly implement NPCs passing through doors in a game. The NPC starts at point A and needs to reach point B, but there is a door in the way. The NPC should walk up to the door, open it, and then proceed to point B. I approached this by creating a door actor with embedded logic for animations, character...
We use the component for doors, but without checking I can't remember what are we inheriting from for it.
But same use case: doors, bridges etc
mine work, but I need to disable them and enable them on begin play
Maybe ANavLinkProxy? I ended up just doing that and unchecking HiddenInGame and setting actor collision enabled to true in the construction script.
That seems to work totally fine.
Ahhh yeah I should have tried that, I ended up deciding that just directly parenting to ANavLinkProxy was easier for my case.
I checked what I did for this. I created a custom component inheriting from UNavLinkCustomComponent, which is a smart link. That way you can have a component with the smartlink stuff and your own logic to it
can a montage with root motion throw NPC off the navmesh? 🤔
Does anyone know if there's documentation somewhere on how the pathfollowing works? It seems to have a bunch of cool functionality to detect blocking paths, being off of nav corridors and does proper turning with velocity intact, but I can't find any documentation so its all just trial and error..
As with many things in unreal: the code is your documentation.
Sad reality but...
a good point to start is the UAITask_MoveTo since it has a path observer and some other stuff.
hmm is the path following able to handle obstacles when it diverges from the calculated path?
If the obstacle affects the navmesh (=navmesh is regenerated or such) it should be able to go around it, but if the obstacle doesn't affect the navmesh, I don't think the default system knows how to deal with it
I do recall it can detect if it bumps into something or if it's unable to proceed on the required path due to something being in the way, which you could use to implement your own logic to repath
Yeah, you could react to the path event Blocked and do something about it
It's more about it predicting the path, if it's bumping into things while path following doesn't seem super intelligent
Yeah I do mean navmesh affecting things, how does it avoid those? Can't seem to find relevant code in the path following other than it modifying the acceleration to move from one segment to the next
Hello ! Does 5.5 have a search bar in the StateTree (in the States) ? 👀
There's an event for when the nav changes so it repaths (in the AI move to task)
Any idea why is this behavior so jittery at the start? I am using behavior tree with looped move to to random location (Sorry for phone capture)
Is there any way to expose a pure function to a state tree's property bindings?
So I have a decorator that has bTickIntervals and bNotifyTick, bNotifyActivation set to true. In OnNodeActivation I call SetNextTickTime to my specific delay time, but for some reason the decorators ::TickNode never gets called (breakpoints never hit). What could I be doing wrong here?
By creating a class that inherits from FStateTreePropertyFunctionCommonBase,it will appear as a function in property bindings.
For example, here's the code for an FStateTreePropertyFunctionCommonBase derived type to use UAbilitySystemComponent::GetOwnedGameplayTags:
#pragma once
#include "CoreMinimal.h"
#include "StateTreePropertyFunctionBase.h"
#include "RPGSTPF_GetASCOwnedTags.generated.h"
USTRUCT()
struct RPGUD_API FRPGSTPF_GetASCOwnedTags_InstanceData
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, Category = Input)
AActor* ASCOwner = nullptr;
UPROPERTY(EditAnywhere, Category = Output)
FGameplayTagContainer Output = FGameplayTagContainer();
};
USTRUCT()
struct RPGUD_API FRPGSTPF_GetASCOwnedTags : public FStateTreePropertyFunctionCommonBase
{
GENERATED_BODY()
using FInstanceDataType = FRPGSTPF_GetASCOwnedTags_InstanceData;
virtual const UStruct* GetInstanceDataType() const override
{
return FInstanceDataType::StaticStruct();
}
virtual void Execute(FStateTreeExecutionContext& Context) const override;
};
void FRPGSTPF_GetASCOwnedTags::Execute(FStateTreeExecutionContext& Context) const
{
TRACE_CPUPROFILER_EVENT_SCOPE_STR(__FUNCTION__);
Super::Execute(Context);
// OMK2_ASSERT is my assert macro. it is something like ensure() , check() ...
FInstanceDataType& InstanceData = Context.GetInstanceData(*this);
OMK2_ASSERT(IsValid(InstanceData.ASCOwner));
const UAbilitySystemComponent* ASC = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(InstanceData.ASCOwner);
OMK2_ASSERT(IsValid(ASC));
ASC->GetOwnedGameplayTags(InstanceData.Output);
}
This can be used, for example, to bind to FGameplayTagMatchConditionInstanceData::TagContainer.
That's very helpful, thank you!
Just what I was looking for
in theory all you need is bNotifyTick. Is your decorator stopping at any other breakpoint?
It does in all other places
Could it be it ceases to be relevant in the same frame?
shouldn't be. it has abort mode set to none and those decorators are placed almost at the top of the tree (so not affected by run behavior dynamic nuances)
Double check just in case.
You can set a breakpoint in BecomeRelevant and another in CeaseRelevant.
Add this to the watch list in Visual Studio (works on Rider too changing the syntax a bit) {,,UnrealEditor-Core}::GFrameNumber
And see if they happen in the same frame or on consecutive frames
for rider you have to use @ ALREADY PREPROCESSED @{,,UnrealEditor-Core}::GFrameNumber
ok, i think i fugured it out. it seems decorator won't tick unless their FlowAbortMode is something except None. I have poor understanding of BT's search data, but I guess this might be the place where it is decided whether decorators are going to tick or not
riiiiight yep. I suffered this recently and completely forgot. Sorry for the misslead
I am trying to get a door to work with my navmesh using a NavLinkProxy, but as soon as I turn on "Smart Link Is Relevant" the link stops working?
I have a navmesh that my AI walks around fine. I added a navModifierVolume to break the navmesh in a doorway. I then added a NavLinkProxy to connect back up the gap and the AI used it fine.
Now I want to be able to turn that link on and off depending on if the door is open or closed. If I click on "CopyEndPointsFromSimpleLink" and turn on "SmartLinkIsRelevant" the AI stop using the link and wont go through the door? How can I set up a NavLinkProxy so I can turn it on and off?
I'm using Unreal version 5.5.4
iirc smart link requires you to manually implement the behavior the AI should exhibit to cross the link
so it will walk up to the link and activate it... and whatever comes next is up to you.
That makes a lot more sense, thanks.
One way is to modify the tunnel nav polygons area cost on entry. That can only be done in c++ AFAIK. Another way would be to simply change the area flag of the corridor polys to some custom area and use a nav filter when obtaining a path that would exclude that area flag. Then restore the area flag when done.
If you can't do all that, you can always not have nav in the corridors and handle them with smart nav links and don't allow AI's to use a nav link if it's already in use
How is everyone here sending their AI Controller data? (references to other actors, game mode data, etc)
Send where from where?
custom Game Mode c++
So your custom game mode needs to know about your AI's controller and other actors? Can you give us some specific example?
That is kind of odd.
Assuming that AYourCustomGameMode really does need to know about AYourAIController, an implementation might look something like this.
I haven't actually run it and I'm not sure if it's correct, so I apologize if I'm wrong.
Depending on your specific use case, the type of your public variable could be something like TMulticastDelegate instead of TArray<AYourAIController*>.
Has anyone had issues with the FindSlotEntranceLocation state tree task? It seems to keep failing for me and I don't know why
My AI Controllers need data that is stored in custom GameMode. In this case, it's who is on what 'team'. Arrays of APawns.
I'm settling on the solution of using event dispatchers: anytime the TeamRoster variable updates in the GameMode, send that variable to each ai controller. Each AI controller would then update their personally decalred variable of that same type.
Because I feel like having all of my AI Controllers call the Game Mode for data would be more cpu intensive than using event dispatchers to update variables in each AI controller.
Most likely this makes almost no difference in terms of performance, but using events seems reasonable for this especially if it's something that can change mid-lifecycle
Time for a little 5.6 State Tree tease! Hmmm.. I wonder what this could be? 🙂
Ufff man
Just release that in a hot fix please
You are teasing us
Suggestion: consider the possibility of adding a "custom" option where a function is called so we can have other results. People probably want things like "if A and C or if B and D" or "all but, if H finishes first, transition". Customization for the win
There is something like that 😉 This tease only showed a part of the new solution
5.6 is so full of State Tree goodies, our team has done an amazing job honestly. Looking forward to see what you all think!
Man... I'm writing a proposal for a talk at Unreal fest and, by the time I get there it will be "look... We did stuff thus way... But Siggi changed everything and our shit means nothjgn now. Let me show you how things can be done in 2023...."
XD
I cant take credit, Im only a small part of all of this 🙂 Im lucky to have some really kickass people on my team.
If you're not going to the UE fest in Orlando - at least you'll get to play with this new stuff. I'll be in Orlando though. Not playing with the goodies 😭
@chilly nebula And make sure docs come with this stuff. I know its a lot to ask but, it goes a long way!
hey,so i want to fail the sequence after 10 seconds here is the logic i made and it does not fail
Hi folks! Still kinda fresh to Behaviour Trees etc. Blackboard states "OnAlert" is set, yet active returns to root instead of going to the Alert behaviour. What am I missing here?
Is that a custom node?
What's after the selector on the left?
Not yet connected fully, it's being adapted from another BT. The Attack isn't plugged up yet, as you can see, since I'll be building a new task for this particular Pawn. Still, I'd usually see the flow flash at least to the "Can See" Node...?
I had weird flow bugs in the past when having empty composite nodes plugged. You can always set breakpoints in the first task of each composite's first leave (the first task) and see if they stop
Thanks! I'll give it a try!
Does anyone know how to make the Navigation Mesh visualization we get in the Gameplay Debugger appear at the right Z height on top of the WorldPartition landscape? There is a large offset as is clearly visible around the visibility mask.
Not directly AI but there was no other category that fit.
(Using Navigation Invoker)
So, you might be right its a flow bug... I get the red bars on the side of the decorators (which I haven't seen before) , so I guess its reaching hthat point. Its swapping between the EnemyVisible decorators - but seemingly inverse of when Stimulus is sensed, so that may be a fault in the AI BP...
That's defined in the project setting I think
Wdym?
Time limit is not custom
Wait is not custom
The rest of all are custom
in recast actor details there's a debug display section that has debug rendering z-offset along with a lot of other parameters, perhaps you have it set to some big value for some reason. also you might want to check your recast actor actual navmesh generation parameter cell height, maybe it's bigger than it should be too
I meant this. Was wondering if the time limit was a custom node and the abort condition was not properly implemented or soemthing.
Re-watching the video: it is indeed aborting
- runs the 1s wait
- then runs the 11s wait at 0:15s
- at 0:25s the abort-self happens (it's set to trigger after 10s) and the tree re-evaluates into the 1s wait again
It effectively cuts out 1s before your 11s wait finishes
but i want to fail the whole sequence after an amount of time
i want it to completely fail after 10 seconds and never make this sequence again
Umm then you would need somehow add a cooldown decorator that starts when the sequence finishes.
The way we handle cases like this is by adding gameplay effects with lifetime that add a g.tag to the owner for that time. The g.e is added on cease relevant and a decorator checks if the tag is present to avoid execution. But that's all using gas and custom made nodes
i tried the cooldown decorator and it seems to work,but it blocks the execution only for a while i think also for 10 seconds
and then restarts
The problem with cooldown is that I think it starts counting on enter, not on exit. But I might be wrong
If I'm wrong, you can use both:
- the decorator you use to ensure the logic runs for 10s
- the cooldown to avoid re-entering for 10s later
order of decorators does matter?
No, it doesn't. They are AND conditions
What matter is when/how do they "decorate" your bt
And when/how they evaluate internally
Specially for abort stuff
i put both of em and its still the same
Yeah that's because cooldown starts when evaluated, not on exit
Try set cooldown to 20 and time limit to 10
The problem you will have though is that, if a task fails in let's say the 1st second, you will not reevaluate for the next 19s
So your "run 10, wait 10" will not work
It will be "run 1, wait 19"
it waits 20 seconds and then restarts
Yeah
But that's what you want right?
- sequence starts running, the 20s starts counting
- sequence runs for 10s (10s left in the cooldown) and aborts
- sequence tries to reevaluate and fails because cooldown is still active
- after 10s of revaluation attempts, the cooldown finishes and the sequence runs again
So you technically run your sequence for 10s and blocked it for another 10s
That is assuming the cooldown starts on enter the sequence (become relevant) which I'm unsure now (I'm taking your word for it)
Aaah wait
Sorry
i want it to be blocked entirely ,i want the invincible state to run 10 seconds and then shut down this state permanently,i dont want it to restart in any condition
"and never make this sequence run again"
Just re-read your message form before
Ummm
You could create a do-once decorator, we have one
Basically the decorator has a bool set to true by default that is set to false on cease relevant
When the decorator evaluates, return the bool
It will fail always after the child execution finishes (the sequence in your case)
You will need to make it Instanced (every BP decorator implementation is instanced) or not Instanced and store the bool in its node memory (c++ only)
i dont get it,can you describe step by step please?
Make your own decorator, override On Cease Relevant, change the bool value property from true to false there. Override the evaluation function of the decorator (I can't remember the exact name) and return the bool there
hi guys. why abp can stop working when enemy is patrolling?
A million reasons. If you set a breakpoint in its update, does it stop?
Hi guys
How can I make AI characters detect each other as obstacles in blueprint? Right now, they do recognize the AI in front of them as an obstacle, but they don’t try to avoid or get around it.
Crowd manager
There isn't much documentation about it but some. They will push each other out of the way so they don't get stuck
If you want true path avoidance, it will require more work
I've been trying out state trees and have been really enjoying them. However something I haven't been able to figure out is how is there a way to dynamically inject StateTree subtrees the way we can inject subtrees into a behavior tree?
I haven't really figured out a way to do this yet. It's possible there's a way to achieve this I just don't understand. The state type documentation is kinda sparse
You setup linked subtrees, and then set an override at runtime. Look at LinkedStateTreeOverrides on the ST component.
Basically like setting up named "slots" that you then set a link for at runtime.
what's the func that sets the link?
Is this how I want to set this up? Is there a function that lets me change the default assets that I setup in these slots?
I'm trying to replicate a pattern I use in behavior tree where I have an item slot that can define an agent behavior that can come from other places.
hi! anyone knows how can I make the AI to avoid other NPCs? like, they stands waiting but I want them to find another path. I'm using the move to node from the behavior tree
I think the answer to this question is still on the screen lol
what?
if you scroll up, Bruno answered 61level's question of basically the same thing
oh thanks, I didn't see it
Hi guys, is there anyone looking for AI engineer/developer?
you might try the job board
hey,so if i play only the Necromancer Invincible task,it works fine,the necromancer sprite goes from a to b point ,but when i connect all tasks,he does not play this animation,i tried adding a wait node after it,i tried adding set timer by event inside it,and none of this worked,can yall suppose why?
I did come across some BT implementation and doubt, that this is the way BTs are meant to be used. Basically, that one uses the Service to do rotations and movements. Apart from repeating many things within the Tick of the Service running at high frequency to make the interpolation for the rotation, my question is, if this isn't kind of a misuse. Shouln't Tasks do the work and Services more or less just check and set variables and conditions? This one looks nice at a first glance and works, but looks like doing it vice versa. One might say "if it works it is ok", but I'm just thinking about doing it the right way things are meant to be done. Any thoughts on this?
Did anyone know the workflow of moving all BT's to State Trees ?
There isn't one. You need to convert your decorators to conditions, your bt tasks to St tasks and, flow wise, things will change
Services are there to "do things periodically while the children are running". Whether is checking and setting variables or handling the rotation is up to you
We have services that override the focus so the character looks to X location/actor while a child task moves it
To give you an example
We have other services that apply a tag and remove it on exit
Does anyone know of a good talk/web/book that explains in detail breaking friction, dumping etc for AI characters in Unreal?
Seeking Alternative to ProjectPointToNavigation() in UE 5.0
I'm working in Unreal Engine 5.0 and looking for a way to find the nearest navigable point from a given world location.
Currently, I'm using ProjectPointToNavigation(), but it requires an Extent parameter—which I’d prefer to avoid.
using a large extent often results in inaccurate behavior, where the AI navigates to an unintended location instead of moving toward the desired target.
Does anyone have suggestions?
Nope. It has just been trial and error for me. Based on my understanding of that stuff while tweaking stuff for the player.
The extent is there to define how "near" it checks for the navmesh. If the world location is on the navmesh already it will take the exact same point on the navmesh
You can generate additional points around the point you want to project, and also project them or check if they are reachable. This way you can end up with a better position
For example in my game there's some cases where the AI needs to pick up an item on a table. If the item location is projected, it can do it, but sometimes it would walk to the opposite side of the table than what would be sensible. I projected some additional points around the item's location, and picked the one closest to the AI which made it walk to the appropriate side correctly
Using UE 5.5 trying to use subtree within behavior tree
I'm working on a simple problem where I want to have a behavior tree use a Run Behavior node to run another behavior tree.
It'll look like ParentTree with ParentBlackboard calls run behavior to run ChildTree with ChildBlackboard
ChildBlackboard has ParentBlackboard as its parent
The node says that the subtrees blackboard not compatible.
I've looked into the source for BTTask_RunBehavior.cpp and it has a line bIsBBCompatible = BlackboardData == OtherBlackboardData || BlackboardData->IsChildOf(*OtherBlackboardData);
ParentBlackboard has to have ChildBlackboard as its parent in order to run the subtree.
Is that the only way to do this?
Umm unless I'm not reading it right your setup is
ParentTree using Parent Blackboard runs ChildTree using ChildBlackboard (which inherits from Parent Blackboard).
If that's right, that should definitely work.
You are reading it correctly, but for some reason in the engine code it requires the ChildBlackboard to be the parent. It seems like a bug
Umm Just took a peak at the code in github and, at a first glance, in did looks like a bug. But I will have to debug it on our project. Not sure how, but that definitely works for us
I'm looking for a good tutorial for enemy ai using state trees. Any recommendations? ...please don't make me read through all the docs
The pins of the channel have some useful links
There is also this one:
https://dev.epicgames.com/community/learning/tutorials/lwnR/unreal-engine-your-first-60-minutes-with-statetree
- if you get latest 5.6 from Github and compile yourself, some of the new starter game templates are using State Tree 🙂
Hey all,
For future UE releases, we at Epic want to make it easier for new users to get started with State Tree, and provide a more fleshed out library of tasks and conditions that are ready to use.
It would be great to hear your top wishes for tasks and conditions that could be provided "out of the box" to build your AI behaviors and other stateful systems with.
What are the common tasks that everyone builds when making behaviors with State Tree? Is there a system you wish we would support integration for directly, like for example GAS abilities?
- cooldown condition
- apply/remove gameplay tag to an actor passed by param or from context task
- condition to check gameplay tag query on actor, being the actor passed through a parameter or from the context
- wait for gameplay event task (We handle this with a global task)
Hi! The first that come in mind is :
- "MoveTo" task with plenty parameters to control the move to request
- GAS conditions (check tag, effect presence or stack count, ...)
- Task to trigger ability
- AI Perception or tasks if it still a relevant system (Enable/Disable sense for instance)
Also additionally :
- Tasks that run EQS and wait for its results
- More Debug tasks (either debugTrace or vlog driven)
Yes Ive had the same issue. My conclusion was that having a child blackboard in a subtree is simply not intended, since the uppermost blackboard needs to include all the data that is used over all subtrees. Not sure if thats true, but its the only theory that made sense to me
MoveTo and EQS tasks are already in the GameplayStateTree plugin, but we are soon improving them with better async patterns!
Is there already something in unreal to combine a smart object with a navlink? 🤔
For what purpose?
running custom behaviours that are a bit more complicated while using a navlink
navlinks are used to move between two navmeshes, is this to add conditions or something else?
I think an example would be a locked door that could be opened with a button press or something. The navlink would be through the door, but the logic of moving from one side to the other would include pressing a button
Youd still want to be able to succeed a pathfinding query that gets you from one side to the next
Or something like crawling through a small space, you might want some complicated logic for how many people can occupy the space at one time, be able to crawl back and forth etc
The door example sounds like a navlink with a condition, shouldnt be too hard to add. And then you could have a smart object/action that changes that condition.
Well in this example the action would need to be part of the pathfinding, for example an npc wants to go investigate a noise behind that door, if its locked due to the button not being pressed, the pathfinding query will fail, unless its somehow included in there
ah got it, but would the pathfinding query need to take into account if the character CAN unlock the door? thats where things often get tricky 🙂
Yes I guess it would, if the navlink were tied to a smart object for example, you could query the preconditions on that and if its claimable, then succeed or fail the query based on that 🤔 And when you do the path following, you could use the smart object as part of the navlink traversal, assuming that will execute all the logic to move you to the other side of the door and press the button
but its a good idea overall 🙂 should be doable, there is already code there that moves the character along an arc when traversing the link.. should be able to expand on that to use a SO that is linked, you would just need to resume the path when exiting the SO
Ah i'm still in 5.4 not sure i have them right now
Edit: ok we have MoveTo but i guess EQS task come with 5.5 Thanks for the info!
It would be nice if the built in MoveTo would automatically repath if goal actor input changes to a different actor. Right now, I'm firing an event to do that manually.
I struggled a bit with my attack selector system because utility weights are not property access binding but just a const/literal value. Games with top-down game director systems/services often manipulate weights based on world state so I think that could be a dynamic property as well like the ones we expose to ST through tasks and conditions? 🤔
Please fix AIController's SetFocus function to allow (x,y,z) Vector input as well as Actor input. Currently, if provided with a vector input, AiController ignores z.
but you don't need Z do you? you can't rotate the Character's capsule around it's X and Y axis to look up/down. The focus direction will be projected onto a plane defined by the capsule's Z axis as a normal because a capsule can only rotate around it's Z axis.
No? or am I missing something?
Decided to cleanup Gameplay Tags in my project, and noticed that Smart Object Plugin and State Tree are defining some test native gameplay tags (Test.SmartObject.Tag1 in SmartObjectsTest.cpp:27).
Is there any way to remove them from a project without needing to recompile engine?
We are considering expanding on the utility selectors in the future, perhaps support multi-target evaluation.
I don't think so since there's no way to get rid of C++-defined tags... but this seems like a pretty minor issue :)
Set focus (utilized as a Look At function) works for actor references with Z locations. Why not vectors?
But how dies the capsule look up? Doesn't it project the actor location?
I don't think the look at rotates the capsule around X/Y
Hey folks, I'm on 5.5.4 trying to use Linked State Tree Assets but I keep crashing when they have a Parameter. Has anyone experienced this before or accomplished having Linked State Tree Assets with Parameters?
only 2 QoL related wishes
It's not a serious issue, but it's cluttering the tag picker. And there are more from other plugins. I wonder if there is at least a way to hide native gameplay tags?
You can make your picker in your tag container property to only show tags under certain parent. There are property metatags for it if that helps
Hello guys I from Mongolia I have made system to spawn parcel for transport in my game and unfortunately when I spawn too many parcels it says "assertion failed" and i crash
why
I just switched all of my AI logic from BP to C++. Are there any C++ exclusive AI functionalities that I may not be aware of, or that you find useful?
When the editor (or a build) crashes, there's a crash log generated that will say the reason
If you use bttasks/decorators/services that you made for custom stuff, you can make all of them non-instanced and, instead of saving data in Uproperties, use the memory node passed to them.
I'm using BT only right now, so I'll have to try this. Is this a functional difference, or optimization?
Its mostly optimisation, but changes the way dynamic data is stored. By making it non-instanced you are creating only a single instance of that node over all instances of the same tree, all the data that is not in the instanced data is thus shared between all instances
What Moritz said.
Noticeable optimization on memory and cpu
Hi, I'm using simple c++ to generate navmesh at runtime. I move the navmesh bounding volume and call Build() on the navmesh system.
This works. However when I load a different level with a navmesh and return to the one with navmesh generation the code stops working completly.
I get no errors, the built navmesh is empty, and logs say it took 0.0 seconds to build. I'm using 5.2, any idea what might be the cause? Thanks!
Never seen anyone doing this. The thing is that, by doing that, I think you might be re-creating the recast nave mesh object into whatever level the first nav bounds volume is. You would need to call build again when coming back.
You could add a small volume at 000 in the persistent level to ensure the recast object is always added to the persistent. But since you call build on the second level while the 1st level is gone... You will delete all the nav from level 1 because there's no level to build nav upon
I'm don't know why are you doing that nav mesh bounds move and then call build but sounds wrong
That kind of scenario is usually handled by dynamic nav mesh using invokers
What's the use case?
Hello guys working on ai state trees im havign issue with delays, i want to have my montages play for like 20 seconds etc etc any help?, Also the 50 sec delay is no tworking
You probably want the latent version and to call Finish Task after the Montage is complete. Try something like this and remove the delays.
If you're interested in the montage looping for 20 seconds, I would probably control that within state tree itself. Like having a child state that calls the Animation Montage and completes, spitting out whatever delta seconds have occurred. Then track the value somewhere (like a property maybe?) in the State Tree and transition out of the State once it's past 20 seconds.
Omg that sounds awesome.
Like Bruno, Im also interested in what your use case is. Navigation system also supports a fully runtime generated mode for procgen worlds called Invokers or "navigation on demand". We use this for example in Lego Fortnite.
https://dev.epicgames.com/documentation/en-us/unreal-engine/using-navigation-invokers-in-unreal-engine
Are blackboard key ids the same for all blackboard components on all controllers? I have the following situation. I have 2 NPCs N1 and N2 and a BTTask that has a FBlackboardKeySelector (say BBKey) and inside that task I make N1 to observe N2s BBKey. But for doing this I get N2s blackboard and register observer against a BBKey that is used for N1. I haven't debugged it yet but I'm wondering if BBKey KeyIDs exist per-BlackboardComponent or per blackboard asset 🤔
ok, to answer my own question, it seems that the BBKey ids are blackboard-asset based so it's legal to do what I'm trying to
Are age expired senses suppose to hang around in the LastSensedStimuli array?
How?
My AI keeps chasing me and then stopping randomly, thoughts?
I'm using sight perception from AI Perception component
I believe they are finishing the move to
just randomly stops chasing me like this, i think the navmesh is bugging for some reason
Seems to replicate when the AI reaches me, and then DOESNT lose line of sight with me... if it gets lost (or the line gets intersected) then it starts up again.)
@remote fractal
Sounds like a bug in your logic. Like you are forgetting to reset something upon reaching.
It could be it's stuck too. If you use visual logger you should be able to check why did the move to stopped
Yeah that's an array with one entry per sense used. It holds the data of what was sensed by each sense last. It's up to you to check if you want to use the expired aspect of it or not
As in "I heard this guy, but that was 55s ago"
If my max-load use case is a single player game with 36 humans simultaneously navigating in the same level and navmesh, and I want all of these ai humans to possessable by the player at any moment,
- Do I need to use the Character class for all 36 humans?
- Does basic of the shelf AI navigation require CMC? Or can I work some c++ magic to prevent all 36 humans from needing a CMC? Maybe slightly beefed up pawn classes? (I do not want to use Mover)
off the shelf I think it requires a component that inherits from INavMovementInterface to do path following, the Pawn Movement Component should be sufficient or any custom thing
A pawn is the base prerequisite for anything that can be controlled, so i think that's the most "basic" you can go
Well strictly speaking it's just something that can be possessed by a controller of some variety, you can certainly use other mechanisms for it also if you're so inclined :)
(obviously a lot of code in UE assumes the controller + pawn architecture but in any case)
Although I don't think a "plain" pawn adds much on top of actor so maybe it doesn't matter that much
It doesn't.
There would be some major NIH syndrome if you were circumventing the controller + pawn setup while using the actor system overall.
Yeah you're right, I think there's some really niche usecases where it might make sense though :)
Yeah, those are outside of the actor system though.
Like using your own game simulation. Or #mass
question regarding state tree (maybe behavior tree logic would solve this to?). i have some call of duty zombies style zombie ai and i have them setup to find the closest player, move to them, then attack. the issue i cannot figure out logic wise inside of state tree is to "refresh" the closest player. for example, 2 players, 1 zombie, zombie selects player1 as they are the closest and starts moving to them. in the process player2 runs closer to the zombie, i would like the zombie to change move to targets to player2. heres my current setup
Hi everyone, I have this issue with designing modular BT for ranged enemy. Is there a way to achieve SimpleParallel-like behavior only with multiple behavior trees? Lets say that I need to implement classic "move and shoot" behavior but SimpleParallel wont cut it for me since both movement and shooting consist of multiple nodes and I would also like to be able to swap implementations of these two features dynamically. So basically can I somehow run two RunBehavior nodes simultaneously?
There is a run behaviour tree task, tho I can’t rmbr if I tried using it in a simple parallel. Try it.
for the current setup you could add 2 child states to FindAndMoveToPlayer:
- Check (compare if STTFindClosestPlayer is still the same as the one found in parent state), you can make a simple task for it or go deeper with child states, check conditions on one to compare found players and trigger appropriate transitions on those child states
- on success (the same)
- transition to Delay
- on fail (different)
- transition to Root
- on success (the same)
- Delay (1s?)
- on completed
- transition to Check
- on completed
Typically - I'd probably do something like this in a service on the BT side, so that means to just have another task that you put on your state. Considering it is CoD zombie style, can probably put it on your root task. Then transition to your move to state if the target changes.
Yeah, that was my initial idea. Sadly RunBehavior node won't run as main task of SimpleParallel. You can place it there but execution wont jump inside the sub-tree (also confirmed by multiple forum posts).
@lofty ember thank you, currently im trying using events. making a global task that searches periodically for the closest player, if a different one is found then send a state tree event which causes the transition to revert to the root to rerun the move to task. trying to see if this works before trying the other options
Hey, the behavior tree doesn’t work properly on the npcs i spawn. i think it’s because the navigation isn’t built correctly. when i add delay nodes, it works, but that kind of delayed result isn’t what i want. is there a way to build the navigation in advance? or is there another solution for this?
What's your navigation setup?
and i'm also using it in the navigation invoker
I'm trying to build a custom EQS point generator using blueprints and I'm running into crashes. Some research already suggests this is an unfixed bug without a workaround? In any case I need to generate custom points for my project. I'm not very good with C++, but I can learn what I need to get this done, but I'm asking here to verify among the community knowledge: Do custom EQS Point Generators work in C++? I wouldn't want to struggle through learning only to run up against the same bug again.
it is definitely a bug in my logic although I am uncertain as to how I fix it.
i followed the official documentation quickstart guide and it appears that the event for having the crabs lose sight (it was set on a timer so i could reset the timer meaning it would be like 4 seconds of having to lose LOS before they'd stop chasing you)
now i just need to figure out how to reimplement that without it breaking it lmao
Ok so your are using dynamic with nav invokers. You could pause the AI until the nav is done for example.
If you want to "bake" the nav you need to use static or Dynamic with Modifiers. There are videos online explaining the different between the 3 stc
They work both in c++ and BP as far as I know. What crash do you get?
got it, thank you.
My generator doesn't generator any points. My understanding is because I need to set the generated item type to points in the class default. If I do that and then move my EQS testing pawn it crashes. "Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0xffffffffffffffff"
Upon rebooting moving the testing pawn doesn't crash but it also doesn't generate points. If I go back into the Generator BP and unset then set the Generated Item Type and move the pawn again then it crashes again.
If you look in the crash log you will see what's us crashing probably
[2025.04.17-19.02.18:629][553]LogWindows: Error: === Critical error: ===
[2025.04.17-19.02.18:629][553]LogWindows: Error:
[2025.04.17-19.02.18:629][553]LogWindows: Error: Fatal error!
[2025.04.17-19.02.18:629][553]LogWindows: Error:
[2025.04.17-19.02.18:629][553]LogWindows: Error: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0xffffffffffffffff```
That?
Ummm is that all?
Rent there more lines below in the calls tack explaining the chain of execution?
Below the last line
Ah ok, you need to download the debug symbols for the editor, otherwise it's a useless callstack. But it might be faster if you post here the code of your generator (or BP)
Maybe I should do that. Here's the generator though:
I'm actually trying to generate a 3d grid of points around the actor but I reduced it to this to debug. The crash happens with it just doing this.
And how are you running the eqs? Could it be your array has nullptr entries? Place an Is Valid before the get actor location
Just in case
I installed the debug symbols.
Oh also I just added that validate and that crash is from after.
Is attack target from your context valid?
The crash is in EnvironmentQueryInstance.cpp line 322
I'm not at home but maybe someone can check that line in the source (or you can sign up for epic github) and see what fails
Well the context that I'm using works when I use it in a non-custom EQS query, and I did add a validate to the generator BP.
I joined epic UE github. Line 322 begins this If statement:
{
SCOPE_CYCLE_COUNTER(STAT_AI_EQS_GeneratorTime);
DEC_DWORD_STAT_BY(STAT_AI_EQS_NumItems, Items.Num());
RawData.Reset();
Items.Reset();
ItemType = OptionItem.ItemType;
bPassOnSingleResult = false;
ValueSize = (ItemType->GetDefaultObject<UEnvQueryItemType>())->GetValueSize();```
My Generator currently has "Can Run Async = False"
The built in points generators also have Can Run Async = False
I'm not sure what's going on. Could it be it crashes if there's no test or something? Far fetched but yo discard something
I did try adding a basic distance test to score the points based on distance when I was getting to this point. I can try again later.
I don't think that has nothing to do with the state tree
If you don't run it, does the log go away?
Do the objects show up in the outliner? Are they spawned into the world?
Has anyone had any success with the UCrowdFollowingComponent? I can't get the dang thing to work. Its suppose to avoid other AI, but it doesnt seem to do anything.
https://www.loom.com/share/e5406ed8d9d14d88bd08bf357ae7fbd1?sid=5c0c06d0-4084-4837-8211-5dec1cf29e0a
I have used it but set it from c++ ages ago. What guide to use it did you follow?
I set it up in c++, there really isnt anything to it, other than adding the component:
ADRAIController::ADRAIController(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer.SetDefaultSubobjectClass<UCrowdFollowingComponent>(TEXT("PathFollowingComponent")))```
I am using the Mover plugin though. As I'm digging into the code more, I can see that UCrowdFollowingComponent uses RVO, which Mover doesn't support yet.
If you set a breakpoint in the object constructor where you out the debug, what's the callstack?
Do you have the state tree debugger open while doing this?
I have tried everything and don't know what else to do.. for some reason all of my AI die when I apply damage to the AI from a projectile overlap. Does anyone know what could be causing this? I've tried to set replication on the AI, but it doesn't do anything. It's a singleplayer game btw.
They all die no matter where I place the characters
Why use an overlap why not event hit?
Is your overlap radius too big
Can you show where you are applying and receiving the damage, hard to help without any ode visible
Guys, any advice for create vehicle movement component for an RTS single player game ?
RTS vehicles don't usually follow any real physics or anything so you could just use any old movement system for that probably
Eg. just have it rotate to which way it's moving and based on terrain angle
Hello 🙂 Im trying to use the AI perception feature but whatever I do my NPC isnt seeing my player character. Ive put the perception component on my AI Controller and a stimulus source on my player character. Both have sight config enabled and Ive resized the sight radius to make sure Im actually entering and leaving the radius. But its completely ignoring me which hurts.
have you set the detect by affiliation to all? I recall the default setting won't detect anything
(the stimulus source is unnecessary usually also... all pawns are registered as stimulus sources by default, but it can be disabled)
I didnt, that fixed the issue.
And thats interesting to know
I just tested it and it didnt work
Idk. I removed the source and it didnt detect me. put it back on and it did
well no harm from having it on there either way :)
wild that printing while having the AI debugger open is still bugged...
Ugh, well that's a great Smart Objects gotcha...
I modified one of my Smart Object Definitions to include a new activity tag in addition to another one it had... wondering why isn't it working, the actors using it can find it just fine with the old tag but not with the new one
No idea what's going on, nothing makes sense
Restart editor
Now it works
????
Anyone know how I can make it so the AI doesn't clump up together and perhaps strafes around the player? (without using BT's)
Does anyone know how to optimize the source code of the MovementComponent's enemy-seeking component?
You could try using EQS or some other method to generate points around the player, and have each AI choose one of them to move towards, rather than directly at the player. Some other similar methods probably also exist
What is this "Enemy seeking component" you're referring to?
CharacterMovement Pathfinding Part
Well it kind of depends on what is expensive as it can depend on what your game is doing
But generally you can disable things like physics interactions, or use NavWalking instead of regular Walking
How to use NavWalking instead of regular Walking
There's an option that lets you choose the default ground movement mode or something like that
What is the cost of Navmesh Walking?
It snaps the character to the navmesh and doesn't do ground checks like the regular walking mode does, so it's somewhat cheaper
What about avoiding obstacles?
What do you mean?
I'm not sure how to do it and cant find a guide that doesnt include BT's
What are the parts omitted in ground inspection?
Normal walking uses the ground check to keep the character touching the ground, so it does linetraces and some checks like that
With NavWalking it puts it directly on the navmesh, so it doesn't need to do the checks
It has no effect on pathfinding or such
I took note of it, thank you.
Do you have any other AI optimization tips?
Use Unreal Insights to profile your game, it should tell you what is time consuming and should help you find what can be optimized
How many moving NPCs do you have?
Hmm yeah CharacterMovementComponent can start being a bit slow with that many depending on things 🤔
if you use Unreal Insights, try enabling Stat Named Events from the menu, this should give you more information about the CMC and some other things
My friend gave me some information
For general monster characters:
Rewrite the ResolvePenetration function: The default ResolvePenetration logic will try four position adjustments to solve the penetration problem, and the physical calculation overhead in this process is large. By simplifying the process and reducing it to a single adjustment, the performance consumption can be effectively reduced.
Remove SlideAlongSurface: Monsters usually do not need to slide along the wall after colliding with the wall. Therefore, removing this function call in the PerformMovement process can further reduce the performance burden.
Streamline PerformMovement calls: In the customized PerformMovement implementation, we can reduce multiple calls to ResolvePenetration and only retain the necessary adjustments to the final position.
For large-scale group monster scenes, based on the above optimizations:
Streamline PhysicsWalking logic: For a large number of monsters in the scene, PhysicsWalking can be completely rewritten and replaced with a simplified logic: first delete all the code, directly calculate the movement based on the direction, speed and DeltaTime provided by the navigation system, and then maintain contact with the ground through FindFloor.
Refactored findFloor functionality: Replaced the default ground detection logic and used FindNavFloor to query the navigation mesh instead of the actual terrain. This adjustment can significantly reduce the computational resources required for collision detection.
I can't write specific coverage
I don't know if ChatGPT knows much about this tbh lol
Of course not, otherwise I wouldn't ask.
But PhysicsWalking is the default Walking mode, so at least on that respect it is correct - using NavWalking instead should alleviate the cost in that and FindFloor
If your NPC movement is very simple, you could try using floating pawn movement instead which should be significantly cheaper, or write your own movement logic
CharacterMovementComponent is very robust and has stuff for multiplayer etc. in it, it handles a lot of weird corner cases etc., so it's kind of complicated
Unfortunately, it's not that simple
What does the output from insights look like?
I'm not using the engine yet
This is far from accurate.
"first delete all the code" is probably my favourite comment of the week here
Well maybe accurate is not the right word. I will better use "advisable"
The main problem with the CMC is all the physics part, which didn't improve at all when the editor switched from Physx to Chaos
Funny how it's tells you about "keep find floor" when that is one of the expensive parts due to all the physics checks (line traces and sweeping traces).
You need to use a detour crowd algorithm I think
@slow bobcatCan you help me change the CMC source code?
No, that's a titanic endeavour.
First you need to have your use case done, then profile with insights in a development build to have a very clear image of what is exactly your problem, thenadd cpu stats in engine code you are going to need and that are not there to narrow down expensive functions.
And then with that think what to modify and how.
What is exactly the problem in your game that is requiring you to cheap the CMC? I imagine your framerate is bad/low in certain situation, what is that situation? Can you share an insights screenshot of a bad frame?
I have solved the frame rate problem, but I am still looking for some optimization experience.
Yeah that's the thing. You can solve issues in many different ways, not neccesarely changing the engine hard. What's your use case? I mean things like "I have 40 characters alive at all times" or something like that? What kind of game genre? Shooter? Mmo? Bullet hell?
Have you tried approaches like creating an LOD manager for AI or Tick Aggregation?
Because those two are very effective
Has anyone compiled a project State Tree project that has tasks, evaluators, etc extended in C++ ... on MacOS? I had an extremely frustrating day yesterday trying to fix a compiler error that popped up during Mac compilation, where it was complaining about the template keyword in StateTreeExecutionContext.h
example on line 242 EventQueue->template ForEachEvent([Function](const FStateTreeSharedEvent& Event)
I wound up disabling the Unity build and going through every error that threw up, which I did... and then wound up having the exact same errors
Can't speak for Mac, but at least on Windows errors from the engine code generally means your compiler or related versions are wrong
Im not very familiar with the Mac platform, but I do know we run regular CI builds for it.
Yeah I was about to suggest making sure your compiler is of the correct version
Yes that's what I was thinking
Thing is I've compiled other projects on the Mac before and that all went fine, so this was a bit of a head-scratcher
Any idea what the 'right' version is?
hmm I wonder if this is a Rider thing
you on UE 5.5? latest Rider? On Windows you still need to install the VS compiler when using Rider, probably the same for XCode on Mac
in your output log in Rider, look for an entry early in the log that states what compiler is being used. I had issues in the past (on Windows) where an older compiler was being used even though a newer one was installed
oooh 2025.1 is out 😄 Im behind!
I think it was released just a few days ago :)
I stuck all of this on the Mac just before leaving for Easter so it had better be the latest!
I remember there being a setting in Rider to override what compiler to use, seeing if I can find it for you
Edit: Nevermind, that was just the MSbuild toolset version
Just looking for it and I see this
Enable all diagnostics
I wound up just editing the source code as I'd had enough, so I'm going to switch that off and revert and see if it gets fixed
When I build on Windows I see a log like like this, you probably have something similar
0>Using Visual Studio 2022 14.43.34809 toolchain (C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808) and Windows 10.0.22621.0 SDK (C:\Program Files (x86)\Windows Kits\10).
Yeah seen that on PC
Don't seem to get anything quite so explicit in the Mac log
Non-unity builds are looongggg
Honestly stuff like this makes me miss the PHP job I had after University
it gets easier with time 🙂 more focus on what matters, less on platform errors
Pawn sensing isn't lining up with the player's camera and sight traces are being blocked by that actor attached on the right shoulder. How can I specify the positioning for the sight trace?
Nah, you just progress to the next level of errors
😄
I think pawn sensing is deprecated? If you're using that, then you need to override GetActorEyesViewPoint in the Actor that is doing the trace
Pawn Sensing might do the same thing
yeah I was looking thru the cpp source and figured that
Also you can change the collision profile of the thing that's on the shoulder
we're working in bp right now but it seems the default pawn at least controls the height of the view position with a bp exposed param
changing the collision profile can get messy with the actor being used for other hit dependent stuff
Same compilation error if I take out -weverything from the clang command line options and do a full rebuild: 0>StateTreeExecutionContext.h(227,24): Error : a template argument list is expected after a name prefixed by the template keyword [-Wmissing-template-arg-list-after-template-kw] 0> 227 | EventQueue->template ForEachEvent(Function);
I'm just going to take that line out, compile, and do something on the project that isn't coding
@chilly nebula @misty wharf thanks for the input anyway!
sure but that's a sight trace
up to you, probably best to go with overriding that function anyway
we have a cpp character we'll change with overriding that function, but setting the base eye height in bp works good enough for our purposes, thanks
The robot character I have has a detachable head so I had to do it the hard way 🙂
If i havent learnt much about any of ai yet, is it better to start learning with state trees or behavior trees? Like, do state trees replace behavior ones?
Start with BTs. Far more information about them. And it isn't in such a state of change. They're very industry standard as well. They'll be around for a long time.
Then transition to State Trees when you feel comfortable.
yeh ok, I was thinking that, but state trees looked more fun so I was hoping they were getting replaced 😭
thanks
idk i'm not that experienced professional but i'd suggest the opposite to dive straight into state trees because this is the tool that will get new features and updates, even though i detest them and stay on BTs as long as possible
why do you detest them?
mostly baby duck syndrome, i feel myself much more comfortable building behaviors in BTs (FPS enemies and TPS action RPG people), I have my own tricks, implementations and ideas how to build specific behaviors. But to be specific but brief
- I tried STs 3 times, at 5.0, 5.1 and 5.3 ||so my view of them might be obsolete||. Each time I was pushed away by lack of provided bread and butter stuff like move to, run eqs, time limits and other minor ||when considered separatedly|| stuff, that I could have just created on my own by copypasting BTs implementation, but at that time STs were lacking cpp documentation and I just wasn't motivated enough to get to that
- I don't like the concept of everything is a state and I like the concept of composites (especially considering you can make your custom ones). It just seems counter-intuitive to me that instead of laying out a sequence of actions:
find and claim a smart object - move to it - orient to it - start using it
I must do
enter state find smart object - from that state move to state move to smart object - from that and so on
To me it seems like BTs composites, services and tasks ||and state/branch-handler decorators (i know that STs have their own entites to manage flow control, transitions they are called?)|| are blended into 1 entity but I am so used to think of orchestrating AI behaviors with these 4 concepts that moving to ST with just a concept of a state and transition seems to me like limiting my toolset
- Idk if STs have it now, but I don't like that there are no blackboards. I find blackboards a convenient tool that allows parametrization and flow control by decorators **and **decouples NPC behavior from its character but AFAIK in STs it's the opposite - the way to go is to reference your NPC and to reference its variables directly
- I find BTs graph editor more comfortable for navigation and reading, and as an AI programmer I spend quite a lot of time tinkering in BTs. I haven't tried, but I assume with complex behaviors STs get cumbersome and unreadable faster than BTs, even if you subtree behaviors
A counter argument would be the transition system in STs which is more straightforward as you can litterally specify state transitions, but idk, I'm already used to handle state transitions by decorators, even though I've read an opinion multiple times that it is bad to have a lot of decorators controlling the flow of the behavior
So (unless its been updated) BTs are more agnostic and I can throw them on more things easier? That sounds better just for that tbh
but aalso running into my first problem lmao... why doesnt wait fire after wander?
the character is moving around, and then immediately moving to the next spot
i wouldn't say that they are more agnostic, they allow you to build behavior more agnostically, but you can also reference your characters here and there
because you always finish the Wander task with a failure instead of handling success and fail with different bool param. The way sequences work is
execute everything underneath until first child (which can be either a task or another composite) failure. return success if all succeded, failure if any failed
and selectors work as
execute everything until first child success. return success if any child succeded, failure if none succeded
but if you're going to stay with BTs then i'd personally suggest you to split wander task into making a BTTask_FindWanderLocation (which you should also consider doing in EQS) which sets Vector BB parameter and use built-in MoveTo task and use the location you've got previously in Wander task
ahhh, I wonder why it wasnt defaulted to that. I guess its safer to not
yeah, that sounds good actually!
thank you 🙂
why is it red
Unless you have changed colors, red usually means "rebuilding"
weird, its staying red even in game, and i never touched the colours
only in game though, not in editor
This means something is forcing that part to be rebuilt constantly (probably). I'm guessing you are using dynamic nav and something that affects nav is constantly moving or you have a nav mesh modifier interacting constantly somehow
hi im following a tutorial(first image), and learning ab state trees, but my editor dosnt look the same (i mean the new task new condition etc), and i enabled the plugins for them, but it still looks like this (second image) what am i doing wrong 😭
What version of UE are you on?
5.3
And what version is the tutorial on?
dosnt say it just says ue5
What is the upload date
3 months ago
Then its probably 5.5
shit
And that would be why.
ugh
ok ty 😭 ig i could ask in here instead of hunting for a tutorial, im trying to make a like pet sim like ai, kinda like chao garden in sonic adventure, but im not rly sure what im doing, what would be the best way to like make something like that?
That's an awfully broad question
"How do I write AI" isn't really a realistic thing to answer in Discord.
thats litterally all i have to go off of 💀 im just starting to learn ab ai, sry i didnt word my question the best 💀
Its been a long time since I played Sonic Adventure, so I don't really recall the AI for that particular part.
But in general - like everything else in programming, break it down into steps.
its more im just trying to make like the creatures in my game can sleep, have moods, etc, i was trying to set it up w just blueprints but ik thats not a good way to do it that state tree is prolly better
Doing it in BP is fine
It just just an architectural decision.
BT and ST are just ways to design your AI
it was not working great how i had it in blueprints
That isn't a problem in BP - that is a problem in your understanding of the design. BTs and STs will help structure this stuff in some regard. (And yes, you should use them a decent chunk of the time)
I just don't want you to walk away with thinking that you have to use them.
So, first, you need to decide the rules of the AI
wdym
Sorry - jumped into a meeting
Has anyone been able to use GASP with actual AI pathfinding? All guides and videos have them use movement input directly towards the target location/actor. Which means it doesn't use pathfinding at all and can't navigate
I've been able to narrow it down to the "Future Velocity" calculation inside the Anim BP. For some reason, trajectory or future velocity isn't calculated correctly for an AI.
I could use the AI's Control Rotation to simulate movement input, but that has its own issues too.
Is sending state tree events directly from EQS query (actually from EnvQueryGenerator) a bad idea?
You can do it, sure. But it's a bad idea from an architecture point of view. A generator should only do what it's intended for: provide the raw data set of items to be tested. Anything outside that... It's really not its problem so to speak.
Why do you need to do that?
Not really need it but It seems like a big shortcut that lets me handle combat behaviour within a single iteration through known actors and sending proper events based on total stimuli strength / visibility etc
FPathFindingResult PathResult = NavSys->FindPathSync(Query, EPathFindingMode::Regular);
is there any alternative of this FindPathSync() ? , its really broken in 5.4 and 5.5
points are null even if destination location is obviously reachable
That works perfectly fine. If you get null points it's probably due to it not being reachable. What does visual logger say about your query?
it is reachable point on mesh. idk how to use visual logger
Tools-debug-visual logger. Open it, click record, play. Once reoroed the bug, stop playing. Right click on the Navigation category and look for the entry in the time line. Click it and post here what it says/shows
FVector ATurretBase::RandomMovement()
{
if (ArrayOfPoints.Num() > 0)
{
int i = FMath::RandRange(0, ArrayOfPoints.Num() - 1);
if(AIController->TestPath(GetActorLocation(),ArrayOfPoints[i])) return ArrayOfPoints[i];
}
return GetActorLocation();
}
So Im using this function to check if the path exists or not, this function will provide location to the AI to move, now as the function TestPath is returning false it gives the Actor's current location which results in the AI not moving anywhere.
in visual logger the location that im getting from behaviour tree is Actor's current location
If your draw debug a sphere at your goal location, is it's centre on the nav? Or is it above?
Is the green thing in the background the nav?
Visual logger should say if it couldn't find the path
nah thats just a material
Show the nav at runtime. You might not have nav there st runtime
Is that at runtime or without playing in editor?
That's how path following works too. Calculating the path is the first step before movement, moving along the path is also done via movement inputs (if acceleration is enabled). Paths in unreal are split into straight line segments, so it's basically always just moving along a straight line
Is testpath a custom function you wrote? Because in vanilla unreal thats a function on the navmesh, not the ai controller
bool ATurret_AIController::TestPath(FVector startLocation, FVector endLocation)
{
if (UNavigationSystemV1* NavSys = UNavigationSystemV1::GetCurrent(GetWorld()))
{
FPathFindingQuery Query;
Query.StartLocation = startLocation;
Query.EndLocation = endLocation;
Query.SetAllowPartialPaths(true);
Query.NavAgentProperties.AgentHeight = GetNavAgentPropertiesRef().AgentHeight;
Query.NavAgentProperties.AgentRadius = GetNavAgentPropertiesRef().AgentRadius;
Query.Owner = this;
const ANavigationData* NavData = NavSys->GetNavDataForProps(this->GetNavAgentPropertiesRef(), this->GetNavAgentLocation());
Query.NavData = NavData;
FPathFindingResult PathResult = NavSys->FindPathSync(Query, EPathFindingMode::Regular);
return PathResult.IsSuccessful();
}
return false;
}
This is what im doing inside the TestPath function
without playing in editor how to see nav mesh at runtime
I believe there was a commandline something like "displaynavmesh"
If youre running pie, you can just run the game, and eject, then hit p to display the navmesh
yea its on navmesh, .
So performance implications aside, theres 2 issues that might be causing this (but not necessarily):
- by not using the ai controller findpath, you are not doing any projection onto the navmesh. This means your locations could be anywhere and won't be exactly on the navmesh, which can cause these issues. By default it should use the navagent size as the query extents, so it should be ok but better to be safe than sorry
- You are using the actor location, not the actor feet location. This means you are trying to path from the midpoint of the actor instead of a point on the navmesh. Again, it uses the extents of the agent so maybe that part works, but its better to use the feet here
Or just eject pressing F8 and press P then to show/hide it
Hahha this. Sorry I just read it
well for some reason idk why but when I used TestPathSync instead of FindPathSync it started working!
I think the only difference between the two is that testpath forgoes calculating a max path cost
- how long is the path? Could it be you are trying to calculate some super long path?
nah its really like 10 steps...
human steps
wait wrong example
1-2 meters
Ummm then inspecting the log in visual logger should give some clues
Will see for now I went ahead as it fixed the issue 🗿
Oh I think I know what went wrong. Youre supposed to call "buildpathfindingquery" on the ai controller or at least copy out some parts of it. Otherwise it won't compute the cost limit and will just provide a cost limit of 0, so it wont ever find a path since the max cost is 0
FPathFindingQuery::ComputeCostLimitFromHeuristic is what probably was missing
so bcuz the cost was 0 it was returning fasle??
It is the max cost. To improve performance, the pathfinding algorithm assumes a max path cost to search within, any path that costs more than that will automatically be omitted. If the max cost is set to 0, that means it will ommit all paths
(unless there is a path of 0 cost which is unlikely)
Is it a good idea to put fundamental blackboard key valid checks inside of a decorator, instead of tasks that need the blackboard key?
The usual heuristic it applies is the euclidian distance from start to end point, that would be the minimum "cost" it assumes. It then applies a multiplier (I think its 1.2 on the default move-to) to that cost so it searches for paths that are also slightly longer than straight lines to the goal
But tbh you would be better off just creating an eqs query that does this, none of the hassle, more of the performance
eqs doesnt work well for me in this case ive tried it
I met that on headless training steps
i think yes. it makes BT more readable (e.g. a reader knows this task will fail if this BB is invalid, you can derive from vislog that the task was not executed because of pre-requirities rather than "something went wrong inside") and you can also control execution flow with it if there's a selector above the decorator and the decorator is set to abort something
Hey guys!
I'm still pretty inexperienced with unreal 5, and thought someone might be able to point me in the right direction. I'm currently trying to figure out how to implement a system for an enemy in my project that if far enough away from the player, will either despawn/respawn closer to them, OR just simply teleport. The enemy currently is using a behaviour tree to run most of its logic, split between several basic behaviour states (roam, investigate, chase). Having briefly dabbled with EQS, my initial thought was to use the EQS system to determine points in a certain radius to the player, but I am pretty uncertain how I would go about executing that.
EQS would be the right choice. All you really need to do is use that to determine the location and then call some teleport/respawn method on the pawn.
would you think a teleport or a spawn method would be a better option? I'm not familiar with either really, but I was thinking respawning might be a good way to potentially clear any hiccups the ai might be experiencing. But again, I don't know where to start learning how to do that.
That's game dependent. So you need to decide which is better for your game.
Fair enough! Do you have any suggestions as to where I should start were I to go the spawn route? I assume because I'm likely removing both the ai blueprint and the ai controller, that would require that I would need a separate ai spawner blueprint that would call the eqs system to dictate where the fresh ai would spawn?
Easiest way to go about this would probably just be to have your AI just spawn a dupe of itself at the desired location and then destroy itself. This would probably work ok if you only have one of them that needs to do this, if you have multiple then it might need a more elaborate solution
Hi guys, Ive made a "Smart Door" class that derives from NavLinkProxy so that my AI can open doors when navigating.
Problem is that the static mesh I've put on the door does not at all appear during runtime or even on the thumbnail of the blueprint deriving from the class. Anyone got any ideas as to why?
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Navigation/NavLinkProxy.h"
#include "Net/UnrealNetwork.h"
#include "Delegates/Delegate.h"
#include "SmartDoor.generated.h"
UENUM(BlueprintType)
enum class EDoorState : uint8
{
Closed UMETA(DisplayName = "Closed"),
Open UMETA(DisplayName = "Open"),
Locked UMETA(DisplayName = "Locked")
};
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FDoorStateChanged, EDoorState, NewDoorState);
UCLASS()
class ENTREEENTROPY_API ASmartDoor : public ANavLinkProxy
{
GENERATED_BODY()
public:
ASmartDoor();
protected:
virtual void BeginPlay() override;
public:
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Door")
UStaticMeshComponent* DoorMesh;
UPROPERTY(ReplicatedUsing = OnRep_DoorState, BlueprintReadOnly, Category = "Door")
EDoorState DoorState;
// Whether the door needs a key to be opened
UPROPERTY(Replicated, EditAnywhere, BlueprintReadWrite, Category = "Door")
bool bNeedsKey;
// Delegate to broadcast door state changes
UPROPERTY(BlueprintAssignable, Category = "Door")
FDoorStateChanged OnDoorStateChanged;
// Function to set door state
UFUNCTION(BlueprintCallable, Category = "Door")
void SetDoorState(EDoorState NewState);
// Callback for door state replication
UFUNCTION()
void OnRep_DoorState();
// Networking
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
private:
// Update smart link activity
void UpdateSmartLink();
// Helper function to call when the door state changes
void NotifyDoorStateChanged();
}; ```
#include "Components/BoxComponent.h"
#include "Components/StaticMeshComponent.h"
#include "NavLinkCustomComponent.h"
#include "Net/UnrealNetwork.h"
#include "Engine/World.h"
ASmartDoor::ASmartDoor()
{
// Default door state and needs key
DoorState = EDoorState::Closed;
bNeedsKey = false;
DoorMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Door"));
DoorMesh->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
// Replication setup
bReplicates = true;
}
void ASmartDoor::BeginPlay()
{
Super::BeginPlay();
}
It's visible here in the editor but during runtime the door just doesn't appear at all, or even count as nav collision
Not sure why but this is a weird approach. Usually the approach is to add a nav link component to your door actor rather than adding meshes, logo etc to a nav link proxy child.
Since the nav link proxy class doesn't render... Maybe that's why? Difficult to say
Out of curisity, what does happen if you show the nav at runtime?
It's because I wanted to use the Smart Link instead of the regular link. At runtime the nav shows the links to the ground for the AI, that's properly connected, but yeah the door doesn't show door affect nav collision at all
You can inherit from UNavLinkCustomComponent and have a smart nav link component (it's what I do)
WHAT!! Can you explain how to do that? 😭
By your question I'm guessing you don't use c++?
I'm attempting to learn to use a combination of c++ and blueprint, im still learning c++ LOL sorry
Ah wait you posted code indeed! Sorry I missed that on my phone!
OK so... Create a class that inherits from UNavLinkCustomComponent. Then add it as a component to an actor