#gameplay-ai
1 messages · Page 86 of 1
I'm attempting to implement a similar system and this is very interesting. Im not sure i understand why you cant use the actual ai actor/pawn itself but you use a proxy...? Also, I see you mention nav trace to ensure location is valid for the offset actors/followers but...do you check this on tick during the whole path for every actor? Else how do you ensure that followers stay on nav mesh and avoid obstacles?
Thanks for sharing this and the talk anyway!
Definitely use mass. I would look into days gone articles for example (ai pro volume 4)
- you use a proxy actor because you move that actor from/to the real pawn to follow
- IIRC I checked on a timer every 0.3 seconds I believe. Unless your characters are super fast, you should be fine checkign 2/3 times per second
<@&213101288538374145> ?
But wouldnt it be fine to just calculate the transform somewhere (probably using a director object of some sort if ticking many actors at once anyways) and just cache it there for the ai pawn to move to? Im failing to see the benefits of having another actor in the world. Maybe this will become self-obvious as soon as I start making this...
Also you mentioned that your designers can drop stuff in the world to influence the way the agents are arranged? 🙃
Because then you would use "move to location" and that part of the engine doesn't use a path observer to adapt the path when the goal changes. Move to location stops and starts a new movement request upon changing the goal. Using an actor gives you all the advantages of the path observer inside the async move to taks (c++)
Umm not sure what are we talking about here. Can you drop a link to my comment?
Aaaah but so each proxy actor is actually pathing. I thought you'd just use nav traces to check you are on the mesh and that's it for the followers. That explains then how the followers are avoiding obstacles. Oh so this system is quite expensive overall. It will be fine for me most likely as I have just a handful of actors in my herd. But just out of curiosity how many agents were you able to support in your game at once with this system?
Here!
It's not. Your AI paths to the proxy actor. You do am2 to 3 nav través per second. you will not see that in insights unless you have lots of AI's doing it at the same time (if that's your case you need to implement a frame budget and a queue system)
We used that with 30 AI's max
Nah as said i have very small groups and it will be fine anyways I think in my case. I was just curious
But now I see why using the actors of course. Wonder how complex would it be to just copy the original path update logic and adapt it to this. But id guess its not worth the effort
not too difficult. I didn't bother because there are other advantages to using actors. If you check the code, you will see them
ah that's for another use of the same system. In our current game, designers can place vectors (FVector with meta = (MakeEditWidget = true)) in a patrolling enemy to create patrol squads. Other AI's associated to that Patrolling enemy will place their Proxy actors at the patrolling follow locations to keep formation
This is all based on what Sunset Overdrive did for their AI's. They use a path deviation approach. I recommend you watch the talk, it is very very good. I posted it here serveral times
This
#gameplay-ai message
Yep, its on my plan to watch as soon as my baby falls asleep 😀 thanks!
make the baby watch, you will need a junior programmer at some point
Ahah that'd be awesome! We'll see what he wants to do
anyone have a holy grail document* for state trees? made a basic one, like them but seems like you cna get super in depth
also, this is more generic but would it make sense to make children of the controller class? the reason im thinking of this is i'd like to make many AIs based off a master but for some they wouldn't have the same perception component details
and also they'd have differtn state trees
Check the pinned messages
About the controller: makes sense you need different perception etc. Usually people handle that through a data driven approach (ie Data Assets / Data Tables with all the data) and loading things upon spawning AI's
how do i make nav mesh bounds volume have higher precision
that's a better idea for sure lmao, i wasn't sure on best method of doing so, that seems way more managable
Check the nav settings in Project Settings. There are settings for tile size, resolution etc
imo they should be in the nav mesh details
You can actually change those per navmesh instance too
Yeah that too, but if you delete the recast object for whatever reason, you need to re-set everything again
Indeed
There was also a bug some time ago where the agents didn't respect recast objects settings
Or something like that
Or maybe it was that the recast object's settings didn't respect the project settings.
Something like that. I can't exactly recall.
I've heard examples of people getting to 100+ characters without Mass (just maybe not 5k+), so I'm curious as to getting something like that working for now.
ATM I'm using 50~ super unoptimized characters doing their own pathfinding to the player and doing fine perf wise, I'd like to bump that up by getting them to share 1 path but have it get varied somehow, as well as some other tricks
Depends on how complex the logic should be. If you're doing a vampire survivor kind of thing you probably can get away with a lot. There's a nice devlog from Dani/Megabonk guy that shows how he achieved 3000+ agents. Its unity but the idea should apply anyway. Basically, the simpler the ai the more you can spawn. Then there is updating skeletons too which might be your next problem. Just try. Spawn them, see where the bottleneck is
yeah... there are people doing cool/crazy stuff to get many characters in game. Mass helps to organize data and be way more performative when modifying data at a large scale.
"doing fine perf wise" is subjective as in "depends on what you are targeting"
Iris might help with new networking performance stuff in this regard. But otherwise, you'd want to use repgraph.
Then to just have that many characters - you'd need to do AI LODing, navmesh walking, animation optimizations, etc...
You can absolutely get 100+ characters (contrary to popular belief) - but doing it networked makes it more difficult.
Also - ask yourself, do you really need 100+ characters? Or can you fake it for the clients?
IE - actually have like 40, but it feels like 100+
Yeah doing all those things atm, my biggest bottleneck atm is everything doing their own pathfinding to the player and so I'm trying to simplify that to the horde leader doing the pathfinding and everyone else following the leader etc.
Depending on your game - something like Flow Fields could help as well. Of course you'd have to build all this yourself.
As long as they can turn into characters, if a secondary player targets a random guy in the flock they should be able to become autonomous / respond, jump at them etc. But yeah exploring these optiosn as well
If pathfinding is your biggest bottleneck, then just focus in on that.
Follow the Leader approach is a fairly common optimization thing
Could also stagger the path finding
So only have like 30 AI do the pathfinding per frame
Or w/e bucket you decide meets your performance targets
Most people (if not all) won't notice if an AI updates its pathing every 5 frames for example.
yeah exactly, just looking for material on some cool tricks for making the leader pathfind and others follow that path but having it vary etc.
Saw some people mention proxy actors to get the AI to choose a different target next to the player but that sounds like they're individually doing their pathing
Appreciate the tips 👍
And if you are wanting to do this on a listen server setup - good luck
That's going to be heavy for an overwhelming majority of people
In the future - using UE's multimesh server stuff could also help
So you could have one server dedicated to all the AI stuff for example
Can somoene remind me the property in CMC that zeroes acceleration when a new moveto req happens?
Isn't it "Use Acceleration For Paths"?
right, thanks
if i have different AI types that do differnt things, would i ultimatley have to make a new AI controller for each of these? i see the process of trying to set everything is not that simple, and i also can't seem to set AI perception at runtime / dynamically. i see you can set the state tree and that i could manage, but i also haven't tested that so not sure if there are pitfalls. but yea not sure how to manage multple AIs under some sort of hierarchy
To set things dynamically in perception you have to use c++, it's the only way
lmao damn, so i just need to make a bunch of controllers ?? i mean it's not the craizest idea but ive never made a child of a controller , but this is the easiest way if cpp is the only answer
But what is your fear subclassing a controller? Also, for perception you will need c++ but to specialize behavior you dont need it. You just need a new controller with different linked trees in the state tree component.
honestly non really other than i've never done it, but AI controllers are slightly differnet than how i think about player controllers, as they are where the majority of things are happneing from a decision making pov and it's entirely on server. but yea making childs would be great tbh that would make it perfect, coul djust make childs for each different entity
I've done it (must say I had only like 5 different enemies in my game) and it works fine. And also it was just mainly being lazy but im sure that if its just to link trees there's a way to do it all in the base controller.
im kinda still learning state trees but yea i thought of how maybe i could just have a bunch of modular peices but would require some heavy prethinking vs just making per one, but i could always reverse engineer after i make each one
Hii! Is there any built-in way to debug state trees to know the exact state that a particular instance is in? 
The state tree debugger. There's a good documentation pinned called "your first 60 min with state trees" that will solve a good bunch of doubts like that one
awesome thank you very much, I'll have a look
I think it is also logged in the VisLog ? 🤔
Move to actor is not moving to objective, the character does a bit of movement in place but that's about it
Does anyone have a clue as to why?
you can check the Visual Logger to have more information
they meant this one
Guys do you know how much performance we gain if we transition from behavior trees to State trees ? Does the transition worth it ? I am having around 15 - 20 enemies alive in a fight in my game ( I am building some thing similar to risk of rain 2 )
Perf aside, state tree is just a superior framework to work with AIs
But yeah, depending on your system state tree will scale better than behavior treees
Thank you
It genuinely doesn't matter at this scale. Neither ST or BT will be your bottleneck.
Go with whichever you understand more or are more comfortable with or want to learn
One could argue the data flow and execution flow is more simple/straightforward in BT than in ST
To be proved. So far... 50/50 (depends on personal preference)
Depends how you architecture your code/game.
is this the place to ask about learning agents feature or is there a separate channel for that?
Well, anyways. Long story short, the question is - is it ok to have multiple interactors and training environments and separate set of NN data assets for them or should I do the contrary and have just 1 of each?
Short story long:
So i'm just trying to get into that stuff and i'm going through a tutorial on https://dev.epicgames.com/community/learning/courses/GAR/unreal-engine-learning-agents-5-5/7dmy/unreal-engine-learning-to-drive-5-5#beginplay
and there's a part at begin play where you set up interactors and training environments. The tutorial has a small scope so there is only 1 interactor and training environment, but as I'm doing my stuff, intuitively I want to make several interactors and environments: like a separate entity for combat state, locomotion and orientation state, character attributes states, etc. However, I could squash them all into single interactor/TE had I wanted to, but they would be bloated.
But looking at BeginPlay part of the tutorial I see that besides interactors and TEs, there are several other entities we must create: Policies, Critics, PPO trainers, and creation of each of those entities takes an interactor/TE as an input. Policies and Critics also must be provided with NN data assets ||so I guess they would contain the weights of the "model"||. So I guess if I go with approach to having multiple interactors and TEs, I must also have multiple policies, critics and PPO trainers for each interactor/TE pair, and I could either
- reuse a single set of NN data assets, but I'm afraid in this case learning result can end up inconsistent because all of those entities (interactor and so on) would just interfere with each other.
- have a separate set of NN DAs, but in this case I'm afraid the learning could end up too loose and independent, whereas in reality the concepts and logic behind all those separated interactors and TEs actually connected, like I would want the AI to move differently depending on its state of health, equipped items, various traits of other surrounding NPCs, etc, but observations for all of these are made in separate interactors, for example.
Sooo, what would be the best approach here?
it says destination not valid, what should I do?
The line above has your locsiton, which looks like an unitiliazed vector or garbage
Debug your logic to know why
Your actor is nullptr most probably
I can't place empty actors as objectives?
Empty actors are not a thing. Either your pointer points to a valid memory address of an actor object or not
It may not be that your actor is wrong - but that it simply wasn't ready by the time the task ran
Yep. I would imagine you are storing some actor in a variable and you are using it in your move to node. The variable probably hasn't been process yet (you haven't call Set() on it)
I'm using actor io
It's stored in a logic actor
Which it's selected from details
Check your logic, see how are you setting it. Set a breakpoint at the move to node, check if valid... You are going to have to debug your logic to know what's going on
Looking back through the stuff that you posted - you appear to be using your own custom approach to AI and not using BTs or STs. If you could provide more information on how you have things set up, we could possibly help spot an issue that you may not notice. But you'd have to provide more information than what you have thus far. @gentle hamlet
Alright, so I managed to get my StateTree logic to allow enemies to pick up weapons and do a random move. But for some reason, despite defining transition rules back, they only execute one of these tasks and never do anything else. Did I do my transitions wrong? What is happening?
I re-enabled the movement speed tasks and surprisingly this also works now. But I still can't get them to go again
I made sure to get rid of any conditions and have it go back to root, but still nothing happens :/
Hi everyone,
I'm seeking architectural advice for my top-down, 4-player co-op game in the style of Vampire Survivors\League of legends Swarm. The core loop involves flooding the map with enemies, and I'm unsure about the best approach to handle the AI efficiently.
My Current Setup:
Using Unreal Engine 5.6
Player characters utilize the Gameplay Ability System (GAS)
Planned two enemy archetypes:
"Trash" Mobs: High quantity, simple behavior (move toward nearest player, damage via collision)
"Special" Enemies: Lower quantity, will use GAS for complex abilities (AoE, Invisibility...)
The Core Dilemma:
I need to support hundreds of simultaneous "trash" enemies efficiently. Their requirements are simple:
Stats (Health, Speed, Damage, Scale...)
Status (Slowed, Stunned, Bleed...)
Move toward the closest player (with potential threat-weighting)
Damage players on collision
Play spawn/death VFX and hit sounds
Drop experience shards on death
Basic walking animation
Etc...
I'm considering several approaches but would love insights from those who have tackled similar problems:
Mass AI System – Seems powerful, but most examples showcase thousands of entities. Is it overkill for ~600 units?
Dedicated AI plugins (like World Director NPC PRO, NPC Optimizator)
My main concern: While GAS works well for players and special enemies, I'm worried it won't scale efficiently for hundreds of simple AI.
Has anyone successfully implemented a similar horde system? I'd particularly appreciate insights on:
Performance trade-offs between these approaches
Whether GAS can realistically handle this scale for simple entities
Recommended architectures for this "two-tier" AI system
Thanks in advance for any guidance!
heyo
anyone know a good tutorial on making a behavior tree control multiple enemies, essentially using one mother ai for all the enemies
Im wondering how to approach the patrols for this
Plenty in YouTube but to summarise: you make a general tree with general states like idle, combat, patrol etc. Those have decorators to control how/when each state is entered. Then what you do in each is yo have a "run dynamic bt". You create a data asset per enemy type where you define which tree should each run per state. ie: melee will run a Melee_combat_bt while ranged enemies will run Ranged_combat_bt. You can specialise bosses and what not. Then, when your enemies are spawned, on Possess, you run the "master bt", read their data asset and inject the behaviors defined in it in the master enemy tree
Key question here is if you need collision between enemies or not (vampire survivor doesn't have this).
If you don't, things will be very simple. If you do, that's where things get expensive/complicated.
Collision ! = flocking/spread
- mass is definitely the way to go when having large numbers (large means "over 50" for unreal)
- GAS gas nothing to do with one or many enemies. Gas is cheap to run, just a hassle to set up initially due to the sheer amount of moving parts it has. You can use it with very large numbers. It will all bake down to what your GA's and GC's do in the end when it comes to performance
Your main issues are going to be: collision among characters, movement (forget about using the character moving component) and animation. You might want to look into the new Mover Plugin. It's in very easily stages but night help
hello, can we abort the move to task if it was the middle of execution i mean a long run is ordered and my ai is on 30% of way. so if the ai see the enemy can decorator cancel the move ? and rerun the bahavior?
surely we have some service to update data like bIsEnemyOnSight = true
is the methodology similar for state trees or is it different/not possible?
would be the same using linked trees I presume
I see, as I couldn't find anything on YouTube can you link me to some? And also wdym by run dynamic bt?
I think your trying to say there will be a ton of mini BT s that each enemy has, my problem is I am doing something similar, but when I have more information than 5 enemies the game gets extremely cpu intensive
So I thought maybe I can have the mother bt tick every 3-4 frames maybe , then not use a patrol bt for enemies and instead do a AI move to function for the patrol that the mother bt links too??
Ummm not sure I know any video that explains data driven approach for Bt's right now... Sorry.
Run dynamic bt is a Node you can use in your Bt's, a bt task
Your problem is not with the Bt's, they are not particularly heavy to run. You are probably doing tons of other things that are impacting your Cpu on other places. I would check with Insights to see what's causing the issues
Got it, it's only when I add the enemies so I'll check!
thank you so much for the detailed response!
you helped me a lot!
any time
I am using BTs
actor IO is a level scripting tool
Oh - is that the thing that someone made to be like Valve's stuff
Well, pesonally, I'm not convinced - but no matter. Let's go back to square 1. Describe your total setup and the flow of data. Screenshots (that aren't unnecessarily cropped) also help.
this is the function, it is triggering
What is "it"?
We don't have your project in front of us
For all we know, Logic Actor Base initializes things incorrectly
Or how you're getting the actor is wrong
Or that you're calling things too early
Or any number of reasons
Don't provide as little information as possible.
Agree with Durox, no clue what's going on, but I see unsettling things. If the array Enemies is empty, your task will never call Finish Task it seems
Also you are calling move to actor on all enemies but you are in a enemy task? That looks dodgy
I don't see where is Objective being set
Which is probably the thing that is nullptr
The means next to nothing without more context
Hello, I've scoured some of the post history and seeing this topic come up often, but I'd like to know if there's more material on this I could learn from :
AI currently ACharacters, CMC is expensive, could we potentially move them to pawns that pathfind similarily to characters? and handle movement in some custom fashion (manually applying gravity, etc)
Otherwise I'm seeing posts about people optimizing their AI such that they have 100+ units with CMC's enabled, in that case what are some tips for achieving this. Navwalking, anim sharing, etc are all a given, characters are super simple and have small amt of bones. Currently doing 30-40 with no issues, but would like some pointers about optimizing this further if anyone's got any.
Generally when there's a lot of AI they should "swarm" together so potentially some group optimizations there that I'm not familiar with
At this point - I'd say to show your complete setup, from start to finish.
You can do it yeah. 8f you are willing to jump into uncharted territory, look into the new mover plugin. But yeah, you can path and use the result in a custom movement logic
Have y'all switched to Mover yet Bruno?
Nah that thing is way to experimental for production. If I were to start a 3/4 years project now... Maybe. I would definitely consider it, but since we have 20 enemies tops in a very simple movement setup... Makes little sense for us
similarily here staying away from unproven systems for production, but I'm not seeing too much talks about optimizing group AI while keeping them as characters. switching to MASS also doesn't fit our timeline atm
Well, I'll ask the same question I always ask in these situations. Do you actually need a bunch of AI or can you fake it and make it feel like a bunch?
As an example - a game like L4D may never actually have 100 AI running at once, but when you're in the thick of things in a horde, it can certainly feel that way.
Where as a game like Dead Rising does need a crap ton of AI going
Extremely simple AI - but AI none-the-less
L4D probably only has like 30 AI at a given time. If even. Just clever level design and spawn points.
yeah very simple AI in our case as well, there are special variants that are smarter and a lot less frequent , but for the dummy horde they do still need to all individually break off and get killed etc as needed.
can currently pull off a decent amount (30~) just fine but was wondering how those pushing 100+ were doing it. seeing claims of 200+ on screen CMC's in some previous posts here. wondering if there's a neat GDC talk about something like this
I don't know of any GDC talk about it for Unreal
But I was able to do it via AI lods, animation sharing (or budgeting), navmesh walking, significance manager
Usually people use Significance Manager to create a LOD system for AI and tweak ticks, anima etc etc
Pretty much what Durox says
And if you identify exactly what you need from the CMC - you can also write a more simple movement component that does exactly what you need and nothing more as well.
Like - maybe you don't need it to test penetration like 40 times lol (exaggeration mind you)
Cool, anim sharing will be the next big one that I had planned, others are mostly already implemented. How many are you able to have on screen at once using CMC in your project @harsh storm
It's been awhile since I've touched it - but I had like 500 on screen. They weren't moving though (but that isn't what you asked 🥁)
lol fair enough. ty.
Anim sharing really helps reduce the animation cost
But it comes with its own caveats
Moving AI characters around though? I was able to get like 150+ if I recall. But that is an extreme case for a vast majority of cases.
An overwhelming majority of games really do have less than like 40 AI at a given time. Regardless of engine.
@signal hamlet It is hard to see - but I can't download the video, so enjoy this crappy screenshot. But this was 4 years ago in UE4. The FPS is 67 though. Non-packaged.
(And I definitely don't have the video anymore)
yeah that's awesome.
on my end 20-25 would be fine but we're moving to multiplayer and i'm mostly trying to save the servers from blowing up, ~3-4 groups of 4-5 players aroudn the map handling their own "hordes" of 15-20 AI.
If the server is only going to have 20-25 AI, you should be fine.
Just do the basics of optimization
Shouldn't need to go extreme.
Or are you saying that it'd be 4 groups of 20 AI? (IE - 4 groups of players and each group has up to 20 AI)
yeah that one.
So actually 80 AI
so less worried about clients they'll just have what's relevant to them but the server will be aware of all of them , so trying to do as much as possible for the servers
You'll also want to optimize networking stuff
how do you do that ?
tell all AIs in the same state to use a given anim instance ?
very nice
does it supports runtime remove/add ?
if for example want to play an anim montage on a specific SKMC
anyone run into issues with state trees? I have a simple state set up where the AI goes into a state , then the child state determines a random location via a STTask, then moves to the location (the location has been set as a parameter) I had this working with no issues last week, I have not touched anything that I am aware of. The AI now apears to be looping its tasks before it finishes them. resulting in the AI spinning in place. The Ai will also not transition to the wait task that it is supposed to once the tasks have finished.
state tree
the BP of the task
Tasks run in parallel. First task finished will execute the state transition. See that part that says "Any" in your tasks group? Change that so the state will only transition when all the tasks are done
What is probably happening is that the random location task finishes 1st and triggering the transition. I also suggest you move the move taskinto a child state of Move To Random locsiton state, it's the only way to guarantee the random location param is ready when the movement starts. Since tasks run in parallel, chances are move to is starting before get random is finished
An example
https://youtu.be/Turj7ZIuPzE
Another casual blog post of a work in progress "RTS" plugin for Unreal Engine 5.
The goal is to use the power of Niagara (for rendering) and Mass Entity (for logic) to render and control 10,000 + units for top down RTS and tower defense style games.
Does ST event data is auto clear in next frame.
Yep. They are "consumed"
How, I does not call consume method. 
they are processed during tick of the tree and then the queue is deleted
the comment has a spelling mistake, it actually means "had the chance", not the "change"
Thanks, Just find out.
Now... The async context... No idea if it works differently. I just discovered it today and I have no idea how it fits in the overall logic
i dont understand the point of K2_GetRandomReachablePointInRadius since its a pure node with 2 returns
meaning you cant check for a small pure call if the output location was with a true retuned boolean
Guess they just goofed with pure as seems to happen from time to time. At least now you can convert it into a regular node which will solve that problem
How to stop this. I want my child state is optional.
What do you mean?
I have a state with one child state that have Enter Condition, if the condition is failed, It exit parent state also.
yeah, because it makes no sense to run the parent if no child can run. Or is your parent executing a task too that is being interrupted?
Yeah. My parent state has task to run.
It is not event run parent task.
yeah, if the state is not selected, the task doesn't run
so you need a task to run no matter what happens in the state... which is odd
I need my parent state still run task, if the child is not selected.
Maybe you can re-think the structure? or make that a global task? Answering this without knowing if there's an option to select a state if it has a task but the children are not runable (doubt there is)
For example here.
I'm trying to figure out why "event smart link reached" is working with a generated nav link class but not a manually placed nav link with the same logic, it makes no sense
are they both the same object class?
have you tried these options?
I assume Generated Nav Links Proxy is a descendant of Nav Link Proxy
they are not
Generated Nav link proxy
nav link proxy
Change to use Try Enter seem working, But I am not sure how state is transition. 
maybe something not done right in the setup... there's definitely a funtion for it
not sure I get the question. What do you mean?
I mean that when child state SpawnEncounter is not selected. How parent is transition? Because it only has one transition to child state.
Well, both have an overridable smart link reached event, but only the generated link trips the break point
I guess you need to create a transition for it? not super sure, never had your problem. My main concern would be for a case where the children enter condition is valid, what happens then?
is your placed Nav Proxy set up as a smart navlink? you have to do that
check how does this look and try enabling the relevancy, copy the start/end points etc
It should be
and you copied start/end clicking the button too right?
Correct
then you are going to need to debug code to know why is it not triggering
there's a log for it in visual logger. Maybe you can start there
So the crux of your issue is that you want the Send Objective Event to run regardless if OnOverlapGate or SpawnEncounter actually enter because of their enter conditions?
Check the pinned messages
I know the bare basics (like next to nothing) but feel free to ask if you need something
https://youtu.be/YfL2FpiXt-s?si=l485U8r_JTt2wybE
I'm not sure what's going on with my enemies right now. I tried adding more transitions to allow more than an initial move or picking up a weapon, but now I can't tell if the transitions are happening way too fast, or if it's just the leaf re-executing until the move finally stops. This is just so weird.
seriously how in the fuck do I control this mindless shuffling
(Since he was doing a shuffle I figured I'd give him a good beat)
Check with the state tree debugger to understand what's going on
O_O
I'm guessing it might be declaring a new move every frame?
I just don't understand why this is happening though. Shouldn't the AI MoveTo necessarily slow the execution flow?
do I need to decouple the task and execute the move outside of the task?
I'm guessing I have to break tasks down a lot more than under behavior trees. With a BT I just run the EQS query, load the location generated into the blackboard key, and run a path to it
I think I was trying to do too much in one task
it's still not transitioning properly though
Is there a feasible way of making state trees jump to certain tasks on keyboard inputs?
I want to OnOverlapGate alway active regardless Spawn Encounter is failed to enter.
You could have event transitions in root that trigger when the keys are pressed into a certain state
Okay. Then yeah, you want Try Enter on that state. Then any transition logic and stuff like that needs to be handled by you as well. You can effectively look at it as a state that is always selected when it gets to it.
You might need to have a parent state on it though
I just tested it - yeah, just change OnOverlapGate to be TryEnter and then treat it like any other taks that you have to handle transitions for.
This was the set up
Though - that won't select the SpawnEncounter state
Okay - so, you can organize your states in a funky way
Pretty much - have a param on the Base state that your OnOverlapGate state will alter. Then have a sibling state that just holds the other states that you want to run based on that.
Now, if you want only one state (so just the spawn encounter) - then OnOverlapGate and SpawnEncounter can be sibling states. With OnOverlapGate's transition being "On State Completed" and having it go to the SpawnEncounter state.
And you don't have to fiddle with the selection behavior
But - you do need to handle the situation where SpawnEncounter can't be entered.
It really depends on what you're trying to achieve
So if you only have one child state on the OnOverlapGate state - then set it to TryEnter and set the transition to be On State Completed -> SpawnEncounter
But if you have multiple child states that you'd want to run in order (or try in order), then have an intermediary state
So it'd look something like this. The whole point of the HolderState is to go back to the Try Select Children In Order seletion behavior
Of course adapt this to your specific needs. But uhhh - I think I gave you some things to work with 😅 @robust veldt
CC: @slow bobcat in case you had a slight curiosity (saw you say you haven't encountered this issue before so you weren't sure)
While I get the issue and the solution... It still smells to me the problem is more how the AI architecture is built. Sounds like a re-think of the structure would solve the issue in a more natural way. For example: if you need A to always happens unless option B or C can happen, sounds to me like a Selector approach. I don't read the dependency of "B and C are children of A" anywhere in the issue. I would probably think on a different solution less convoluted / easier to read
I'd probably rearchitect as well - but I also wanted to provide a solution that could work as well.
I haven't encountered this issue in my travels either.
If the issue is "A should happen always", it is even more of a reason to re-think The structure of the tree
Current flow I want to implement is when player first enter gate then spawn encounter. Otherwise just process overlap gate event.
So enter gate - spawn encounter -> overlap gate event
Enter gate again -> overlap gate event
?
That is in pseudo code. Problem is structure in ST.
Enter gate condition is a bool on the door "already entered == false". Set to true in the state once entered
Once you enter the first time, it will never meet the condition and skip it, but the other two will always evaluate
Either of our approaches would work. Really just depends on how you want to go about it.
But uhh - yeah, this is a much easier problem
Yeah - the formatting sucks in discord to try and model the ST
Basically the door will have a root state and 3 child states, one of them will only happen once (a task inside will block the enter condition flipping the bool)
I would put a task on my GateState that, on Enter, would set the GateEntered bool (I named it SpawnedEncounter for w/e reason) to true. Yeah - it will run each time the ProcessGate state is done as well, but w/e. If that is an issue for you, then go with Bruno's 3 state approach.
Either way - the main takeaway is to just flip your states.
Durox will pass you the bill for our Saturday consulting
Here is current flow. I thought I could simple add a optional child state to OnOverlapGate. 🥲
The new flow:
Is there a way to use FStateTreePropertyRef in BP?
hm, FProperty is not even exposed to this type
no wonder why its not on BPs
so how do we take ref from BP?
this type looks like a weird way of reinventing FInstancedStruct in a way that it'd be local memory instead
FStateTreeBlueprintPropertyRef 
types are not exported 
Anyone have takes on SmartObjects, specifically if they should use a 'nesting' style.
Take the stall in the witcher 4, I'm wondering if it's like a "Work" object with a bunch of different slots inside, or they're each unique actors/components of differing actors.
Keep in mind that's a super doctored/tailored tech demo. That said, I would imagine a real implementation would be just one smart object with different slots
Yeh given the extreme collab I'm hoping it's the intended standard but I can't find the video snippet anymore to see if they showcased editor view of the SO setup.
Most things seem to fit in the scale of 1 SmartObject with users transition or taking independent slots but then I think about something say a tavern. At that scale you'd likely want seperate objects. Trying to understand where best that line would sit. (Otherwise you'd have two different setups for differing "zoom" levels)
A smithy for example feels like 1 SmartObject would be clean for development it's all 'self contained' to some extent. But likely should be independent SOs at that stage
Anyone had any luck getting this working? Having trouble getting it to behave the same as setting that "Linked Asset" to the state tree outside of runtime
Thanks
Oh dang - looks like ST is getting migrated to a different debugger in 5.7 https://portal.productboard.com/epicgames/1-unreal-engine-public-roadmap/c/1927-state-tree-rewind-debugger
(Current one will still be available)
No, that's only support for the rewind debugger.
You can already see some AI debug in it. Also VisLog
You could use FStateTreeRunParallelStateTreeTask to run a state tree as a parallel task. Not exactly the same as running 2 parallel states, but it may meet your needs
Can you limit an EQS query inside a specific area? I have a query that gets nearby walls/solid objects and maps around them, but I want to limit this to a room by room query to simulate room clearing. Would I need to define a trigger volume to contain the query, or do I need to put invisible marks to call the query from?
with EQS and navigation on a sphere do i still require a navigation volume for it to work?
I have the combat variant ai working on my planet but in the eqs bp, he doesnt seem to find a path and just perminently bounce between idle/flanking
Maybe you use a test that gets the trigger through the context. If the item (locsiton is or actor) is not within the trigger box, then discard it
Does it happen if you disable the dot test too?
just reinstalling the combat character i kind of messed the State tree stuff unreal wouldnt let me undo
nm f it unreal screwed the pouch there
didnt offer me the combat varient and the proceed to f up something else
yep started to work after i repaired the combat variant and enabled a navmesh
any ideas what is preventing these NPC's from generating the navmesh? when using nav mesh invoker ?
this was sitting in the output log also
LogStateTree: Error: UStateTreeComponentSchema::SetContextData: Could not find context actor of type BP_CombatEnemy_C. StateTree will not update.
LogStateTree: Error: UStateTreeComponentSchema::SetContextRequirements: Missing external data requirements. StateTree will not update.
LogStateTree: Warning: Context Requirements in UStateTreeComponent::StartTree failed. Component tick is disabled.
LogStateTree: Warning: Parameters for 'ST_CombatEnemy' stored in StateTreeReference were auto-fixed to be usable at runtime.
LogStateTree: Error: UStateTreeComponentSchema::SetContextData: Could not find context actor of type BP_CombatEnemy_C. StateTree will not update.
LogStateTree: Error: UStateTreeComponentSchema::SetContextRequirements: Missing external data requirements. StateTree will not update.
LogStateTree: Warning: Context Requirements in UStateTreeComponent::StartTree failed. Component tick is disabled.
LogStateTree: Warning: Parameters for 'ST_CombatEnemy' stored in StateTreeReference were auto-fixed to be usable at runtime
LogCrowdFollowing: Warning: Unable to find RecastNavMesh instance while trying to create UCrowdManager instance
LogStateTree: Warning: Context Requirements in UStateTreeComponent::StopLogic failed. Component tick is disabled.
LogStateTree: Warning: Context Requirements in UStateTreeComponent::StopLogic failed. Component tick is disabled.
LogStateTree: Warning: Context Requirements in UStateTreeComponent::StopLogic failed. Component tick is disabled.
So I've been trying to adapt some tasks from my Behavior Tree to StateTree and I keep running into weird shit. Despite using the same EQS, the StateTree refuses to pickup the weapon or even path to it. The Behavior Tree version of this task worked perfectly fine with the same basic setup (use the EQS to look for weapons in view, set the location of the weapon as the pathing location, path to the weapon, do an Interaction, which adds the weapon to inventory and equips it). But for whatever reason, the STT version of the task just refuses to execute.
"Could not trigger completion transition" seems to be the issue
I wasn't checking for any more criteria here, I just wanted to move to the spot, then call Arm.Self, so I went OnStateCompleted, but it just doesn't work.
Not sure what I'm doing wrong
hrm just curious why there is this difference in AI setup, like my AI i am playing with dosnt have a blackboard tree
but instead it has SST
oh just saw you posted your SST as well
my one has the default -> root which might be what you need
if you look at the combat variant SST, you could use Evading and Flanking in some kind of sequence
its setup to just choose randomly as is ... but there is also "on state completed"
Eh? I'm trying to just get them to path to and pick up a weapon atm
which I was able to do super easily in BTs
yeah the only reason i mention.. about the combat variant... because in the evading SST it deals with rotating toward character and flanking is basically path finding/move to a location where the character is (in your case your pickup), then you would just need to make a SST in theory to make the character execute your pickup / interact code, in combats case it just attacks which is also just another sub SST
ah i see now the reason theres a difference in the approaches is because SST can use EQS natively
and thats how it does its path finding
crazy shiz
that is growing in realtime .. i did a radius of 64000 and removale radius of 32000 but yep because the two ais do not get allowed to contribute to the navmesh we are screwed here
well more then two .. there about 20 of them the engine culls for what ever reason
so weird - even with tile removal radius of 255
fun and games 😄
wait i wonder if spawn another hudge structure if it will limite the range of the path finding again
Hello guys! Iam new in StateTree. What is the best way implement abort, just like in Behavior Tree.
In my experience, an event transition in root. I would check delegates introduced in 5.6
<@&213101288538374145>
So would a two tiered approach be a better idea- the moment to moment immediate needs like finding a gun, firing, moving to a location, etc. be handled in a BT, but with the location values and considerations being handled in a statetree?
yea i guess that is basically why.. its just a flexibility thing
is there any issue with putting the AI perception component in the pawns vs the controller? i am just finding it way less beneficial to do things via the controller vs the pawns, as the pawns are where all the differentiating logic is. i could just do it in the controller still but i don't really see a benefit for this unless im missing the reasoning why most things direct you to put it in the ai controller class
Well - when you put it on the pawn, UE yells at you.
Just build a basic getter and still do your logic on the pawn
You can sub to the same delegates that you would in the controller
yea this is essentially what im doing , but that AI perception component has the distances for sight, hearing, dmg, and those all are kinda hard to hard set for all pawns, and that is the main thing i'd like to be able to adapt
You'd have to go into C++ and do that. Create a new AIController base that will set it.
https://zomgmoz.tv/unreal/AI-Perception/Configuring-AIPerception-Senses-in-C++ - zomg has some notes on how
So your base controller would just handle this in its possession event.
yea that might be needed. not really too good w c++ but i think i could manage to make a new base class for this
would i then be able to set this in the bp classes?
Honestly - you should at least get a basic understanding of C++ in Unreal. It opens the door for so many more possibilities. And as long as you stick with the Gameplay Framework (IE - actors, components, UObject, etc...) - it is pretty easy to write. You don't really deal with the raw C++ bullcrap (though you can!).
Nope, no need. Your base controller (that all of your BP controllers would inherit from) would automatically grab the config information from the pawn and set it. So your pawns need to have the information.
ahh yea that's the ticket
and completely agree, im good with structs/enums (easiset thing for me to start with) but yea need to start to get faimilar with classes and basic functions
Yup, structs and enums are a very good entry point into C++ with UE
it is quite simple but there's just that inital learning curve for every like syntax quirk
That's just because C++ hates you.
lmfaoooo
Now, C++ can't really talk to BP (well, it can, but you really shouldn't in gameplay code). So if you don't want to have to create a new base AI Pawn, you will have to also create a C++ interface in order to get the config from your BP pawns.
Then your BP pawn would need to implement said interface.
But I'd recommend creating a base C++ Pawn
It is kind of annoying boilerplate, but I always have my own custom base version of the following classes for every project:
- GameMode
- GameState
- PlayerController
- PlayerState
- Character
5a) Base Player Character
5b) Base Enemy Character - CharacterMovementComponent
- AIController
Even if they are empty. Depending on the game (and smart design decisions), you can get away with not having a base player character and base enemy character though.
yea i definintely would love to be able to have the ability to make all of the base classes in cpp. im quitedeep into the project where a lot of that would require some significant and tedious changing, but assuming i did everything correctly, things should swap correctly after i'd do so. but a risk nonetheless
i really should just do it just to learn those class setups tho
You can make them in C++ and easily reparent all of your classes.
Shouldn't really break anything
that's what i figured, maybe i'll give it a go, im not too deep into the AI's yet, but character would be a risk, but that would also be most beneficial
The biggest headache is moving data over to C++ and not just reparenting.
You can keep all the data the same and just change the parent class. Shouldn't cause any issues at all.
Then, you can slowly move more stuff to C++ on an as needed basis.
And, in your base character class, you can fix the silly positioning of the SkeletalMesh component
So you don't have to do (0, 0, -90) for the location and (0, 0, -90) for the rotation on every freaking character so that they actually face forward
Just do it in your base character class. Profit.
im atually using paperzd characters (2d sprites) so i have my own unique challenges with that, but that has always baffled me for the characters lol
the biggest decision with cpp for me is always , is it better to keep working on project, or take two days and learn how to do x,y,z, so i can keep working on project better lol
Well, even just a little bit of C++ makes the experience in Unreal a lot better. You can get by perfectly fine by just doing like 5% of your project in C++
honestly structs and enums in cpp has made things so much better when it comes to organizing data and feeling confident that they wont break
i've gone much deeper into systems because of just that
so i know that's right
Can anyone give me tips on how to improve my AI? Right now it is pretty basic with patrol and can also detect sound. But doesn't always attack like it should.
Experimenting with bodycam-style in Unreal Engine 5. Walking through the test area and eliminating some robot enemies to see how the effect looks in action.
The environment is all megascans stuff, with a few from the construction pack from Dekagon Studios. Weapons are from the Military Weapon pack (dark).
#unrealengine5 #bodycam #gamedev #...
so i have asked chatbot gpt to write me a version of navmeshboundsvolume
which is supposed to have some type of planetry support but it doesnt appear to do any thing
Sounds about right
i lost the chat with the bot now but it made this function ProjectToSphere
am i supposed to call that myself
You'd have to explain more on what "doesn't always attack like it should" means in your context. What are you wanting it to do? What is it doing? What does the code look like? etc...
We don't have your project in front of us and know nothing about it.
note sure how i could trigger that projecttosphere function if that is the case
Basically if it spots me it will follow and attack and then just stop and stand there. it is intermittent. Sometimes I have to walk right up to the bot for it to attack.
sounds like there is a probability variable somewhere
Are you using State Trees? Behavior Trees? Regular BP? Some custom solution?
back in combat variant the AI has perceived threat also
but with my problem what i kind of dont get is why NavMesh cant just go to every polygon intersection point of the brush shape .. then do a ratio'd multi ray cast with radius .. toward the origin of the mesh
pcg also should also allow for something like this but they dont even have a brush to use in that respect as far as i know
even with teslation level 5 that would still be very easy to manage and not hurt performance at all
that would keep the tile count under control and nice in the (1 << 20) range
Behavior trees
Activate the gameplay debugger. The default key is ` (which is next to the 1 key on the top row on a qwerty keyboard) and go to the behavior tree visualization. There you can see where it is just stuck at.
Hey guys, I'm trying to make a custom move task and use a vector payload. But I'm getting the error:
InfectBuilding Task 'STTask Move No Complete': The type of Context property 'X' on Task 'Root/InfectBuilding/STTask Move No Complete' is expected to be Object Reference or Struct.
Payload is a vector and the tasks seem to only be able to read it as the floats, but throws that error
I'm probably doing something daft
Oh and this is how I'm creating the struct
nfi but yeah should payload struct be none?
Setting the Payload to InstancedStruct feels like it might be a starting point.
Then testing if you make a Struct that just contains a vector to confirm it's identifying it correctly.
Applying this new VectorWrapper_Struct in your MAKE as well as the payloadStruct input.
If neither of those work may be a deeper issue
Has anyone figured out any uncommon ways to improve AI Performance in UE? I'm currently shutting down / turning on AI based on how close/far players are from the AI, the images will show you exactly what I'm turning off.
I also made tick interval 0.1 to reduce the overall load on the system when the AI does turn on. Anyone got anymore tips that may not be well known?
I'm asking because right now in the editor I'm at ~70-75 FPS with 200 AI in my map (all "sleeping) and ~40-45 fps with ~90-100 AI "turned on" near me
So I've managed to get my weapon pickup task working. Apparently the reason it stopped working was because I assigned it to a sense instead of leaving it empty. I don't know why. However, after successfully grabbing the weapon, we don't transition to passive state and patrol. Additionally, I was seemingly able to sidestep having to pass the armed state through the global variables by just directly checking a bool on the actor to inform the state, which worked. I'm not sure if that's best practice, though. (I don't THINK doing it this way involves a cast, so hopefully the performance cost isn't an issue.) So it basically just loops on the failing state after picking up the weapon.
👀
Implemented SlideAlongNavMesh option for CMC NavWalking mode. This means pawns in NavWalking mode can move along a navmesh rather than just moving towards a projected point on the navmesh.
Neat
not sure where gpt's going wrong with this but it literally crashes unreal 😄
void APlanetNavVolume::BeginPlay()
{
Super::BeginPlay();
GeneratePlanetMesh();
// Adjust Recast parameters for planetary scale and rebuild
if (UWorld* World = GetWorld())
{
if (UNavigationSystemV1* NavSys = FNavigationSystem::GetCurrent<UNavigationSystemV1>(World))
{
if (ARecastNavMesh* Recast = Cast<ARecastNavMesh>(NavSys->GetDefaultNavDataInstance(FNavigationSystem::DontCreate)))
{
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 8
// ✅ Unreal 5.8+ path (future-proof)
FNavMeshResolutionParams ResParams = Recast->GetResolutionParams();
ResParams.CellSize = 50.f;
ResParams.CellHeight = 50.f;
ResParams.TileSizeUU = 4096.f;
Recast->SetResolutionParams(ResParams);
#else
// ✅ Unreal 5.7 and older path (still legal)
//UE_DISABLE_DEPRECATION_WARNINGS
Recast->CellSize = 50.f;
Recast->CellHeight = 50.f;
Recast->TileSizeUU = 4096.f;
//UE_ENABLE_DEPRECATION_WARNINGS
#endif
Recast->CleanUp();
NavSys->Build();
}
}
}
}
ngl it was close to working earlier
but yep if you guys want to have a look at what we've been up to
rewing debugger looks so badass in 5.7
I haven't got to see it yet for State Tree. I just assumed it was like the animation rewind debugger.
Not sure I get this. So you provide a direction rather than a point?
I am just picturing it as some cheaper movement for large areas maybe?
There's an image in the notes. Looks OK. Will see how easy is to add custom stuff to it
Yeah - that image didn't display for me on either computers I looked on
@chilly nebula Can you expand on this? (the replied comment)
Not my team actually, but afaik it does raycasts to the navmesh and moves the capsule accordingly?
😱
How is this like any different than what we had?
Like, what is the intended usecase
sorry, dont have an answer for you 🙂 but I think we used this on the Witcher demo to get around issues with slopes? Not sure!
Is there a way to set up a blueprint function so its accessible to pass into a state tree input parameter?
like i have Actor Foo. Actor Foo is included in the state tree scheme. Actor Foo has a function that returns a transform. I'd like that pass that transform into an input on the state tree.
I know sometimes you need magic out param names ect to wire this up and wanna sanity check if its possible before i just push to a variable and reference that.
how can I make a state tree task abstract/hidden so its not showed in the task picker ?
USTRUCT(meta = (Hidden))
i have an open world map with landscape and world partitions in a multiplayer game setup, now with static navigation mesh and data chunks, does the server load all the map for bots? or what actually happens?
Look into property binding functions 🙂 they can fetch external data via the context
Normally the server loads all the data yes. #level-design might have more details
https://zomgmoz.tv/unreal/State-Tree/StateTree-design
So I'm looking this over and I'm just not clear. I have a bool that's supposed to control execution flow into SearchForGun. If we don't have a weapon, go into the state and look for one, and if not, don't go in and transition down to the passive state. However, the flow never reaches State.Passive despite successfully locking out of SearchForGun with the bool control. According to this link, the completion state for an empty state will never trigger. Does this qualify as an empty state? Do I need a task to check the bool to run before the transition will work?
What is saying the debugger?
basically the passive state never fires, it just loops on SearchForGun
Can you screen the enter condition debug ?
On the timeline, you will see if your enter condition passed or failed at any time
basically, the bool is supposed to be false to lock off SearchForGun, and then the fail condition is supposed to trigger State.Passive (we want to patrol when we have a gun)
I see in your screen that the boolean is never true so it comes back to SearchForGun and select "Locate.NearestWeapon"
Also you will fail to transition to Passive if the "IsArmed?" is false
Make sure the boolean "IsArmed" is properly updated
And add a state that act as fallback that has no any condition
We can see that the transition failed here! Probably because of a task within the state "Locate.NearestWeapon"
Since locate.nearestWeapon fails SO it triggers the failed transition -> which is State.Passive
But State.Passive has an enter condition that require your AI to have a weapon (which is not the case)
So you're indeed stuck.
You can either add an extra state as i suggested without any enter condition or add a child to State.Passive.NoWeapon and move the entercondition to another child State.Passive.WithWeapon
Huh... that's really odd! By the time they are supposed to hit the passive state, they have armed themselves. The pickup task fires without issue, they just don't do anything afterwards.
sorry it took me a moment to reply, I finished a Tarkov quest and had to play inventory tetris
Thank you very much for this, I'm working backwards from the bool in the actor. Is it bad practice to grab a bool direct from actor instead of using a STT global binding? Because for whatever reason when I was trying to use the global binding it wouldn't set correctly
I made sure the bool flags in the actor after the action is called
what I don't understand is how this is comparing like this
Actor.IsArmed is being correctly set in the actor's blueprint
and the state should enter upon being flagged as true
even when I invert the condition, it keeps saying false is true
I also tried switching from Actor.IsArmed? to using the value of that to push the value to IsArmed as a parameter
Thankfully the pickup task still works, but it still won't transition to passive
Alright, progress!
swapping the bool over to the parameter and inverting the bool compare made the bool clear
@wise sluice THANK YOU I got it working!!!!
Does anyone know more about the AI Perception Stimuli Source with sound?
How I fire it, rather?
any ideas why the octree is llike this?
hehe its like its trying to build some kind of house for nav to live in 😄
well i dont think gpt can come right with this because it just endless runs into the header drift between the versions
and then forgets to keep the entire code base together between changes .. ai for ya
but yeh ... when sphereical nav mesh devs?
CodeLikeMe did a planetry LOD in BP's ffs.. its not impossible
and not to be horrible it looked a damn sight better then that octree
Hey, I have a problem with navmesh at the world partitioned level. I am using this guide: https://dev.epicgames.com/documentation/en-us/unreal-engine/world-partitioned-navigation-mesh
Navigation is present and working in the editor, but unfortunately it is not present in the navigation build. The AI are standing still because there is no navmesh.
I have a 2x2 map. It is a city. There is a navmodifier on the roads and pavements. I also use navfilters.
Could someone tell me what might be causing this navigation to not exist in the build?
not 100% as i havnt tried to do a runtime .exe build
but you might need to make the recastmesh/boundvolume a external data asset
There are function to trigger stimulus to specific senses. Not at home to show you, but look on code, it's easy.
Your octree is set to have a big bound size, it's sub divind the space as needed. You can probably use soemthing smaller but not sure if it will give you any noticeable improvement
That's not better than the octree judging by the image. That's pure voxelization without hierarchy, so looking for stuff might be expensive unless there's some weird broad phase logic checking halves of the planet based on location coordinates
Are you using dynamic or static/with modifiers only nav?
What? Not a thing
Hi there, is there any way to make a StateTree task latent in blueprints? It's returning completed before i actually call finishtask.
I think it's report noise or something.
Please could someone tell me where I am going wrong with this as Im kinda lost now, I have a StateTreeAIComponent attached to the AIController, and a NavmeshBoundsVolume placed in the world but the AI Move To is always failing in the state tree's task and I am not sure why, It states Aborted even though Pawn has a valid value etc. Please see the Task and the Tree attached.
nvm I forgot i needed a Floating Pawn Movement or MovementComponent for the AI to actually move....
Hey, guys. I wanted to ask those of you who have been working with State Tree for a long time. I recently decided to rewrite my entire AI from Behavior Tree to State Tree. And I'm starting to run into some nasty bugs, such as a parameter from another task being invalid.
Example:
I have a state with tasks: A - FindRandomLoc, B - MoveTo. And today I caught a bug several times where the location from A is not passed to B and it just runs to FVector(0,0,0) . I tried to implement my task for MoveTo, everything worked, but when I returned the original native MoveTo task back, everything magically worked fine this time.
There were also times when the EventTick or EnterState methods simply weren't called until I reconnected the pins. How often have you encountered such problems within the State Tree, and have you had similar situations? I really want to use something new, but I don't understand how much these bugs or glitches can slow down the development process.
are your tasks within the same state?
static
Everything is set up the same as in the Epic guide.
If I use dynamic, it works. But then the fps drops significantly.
5.7's RewindDebugger is amazing.But where are these function,I can't found the re-enter behavior even in cpp🥹
@solid hinge I think your question currently is simple.StateTree begin use will have some confuse,but keep work with it you will figure out.See Offical's content example and youtube's video will help a lot.
In non-world partition (world composition, sub levels) you have to add a nav bounds volume in the persistent level, otherwise the Recast Object will be placed in a sub level and no nav will show up until you load said sub level. Maybe you are experiencing soemthing similar? Your recast object is places in some WP tile that is not loaded yet? Check in editor who owns the recast object
I like they say "you can enable them" but not how or where
lol,but the new rewindDebugger really surprise.More intuitive and powerful, of course, there are still some minor issues.
I found binding property and executionRuntimeData in cpp's context's instance data relvant.Below two new feature in picture really hard found for me.
I have roughly understood the first point,now can bound In/Out property in StateTree's relvant node/function,the variable which bound will update dynamically.
I have bounds volume on the level, I have recast object, and I even have navdatachunk after building paths, but when I enable debug in build, there is no navmesh.
Who owns the recast object? If you a function where you get the recast object and print the name, is it there in the build?
On world composition it has to be owned by the Persistent Level
How can I check this? This object is created automatically when I click to refresh/build navigation.
I do these things in code. For actors you can check the owning level in the details panel, but that doesn't work for recast
If you open the gameplay debugger in the build and open the Nav section, does it show data?
Yes, it is.
Then difficult to say. Except for checking in code what's going on... Maybe someone has some other suggestion?
For world composition you need yo load all the sub levels during cooking to generate the nav for the entire game. Could it be you need to do the same for WP somehow?
It allows you to bind the output of a task to a parameter on a parent state or tree parameters. Its similar to passing "by ref" and the output task will then change the value of the parameter bound to.
I believe this also works for tasks that tick, but not yet for async tasks.. currently working on that.
I believe its a bool on the transition. These two features are not fully ready yet, so we put them behind a cvar to prevent people having issues 🙂
You should be able to find the cvars if you look at commit history for the state tree plugin
https://github.com/EpicGames/UnrealEngine/commits/5.7/Engine/Plugins/Runtime/StateTree
Thanks!
yah got it semi working 😄
still has a few issues like when it starts its like it takes nav mesh a little minute to acknowledge the path finding but at least the FPS isn't absolutely in the gutter.. giving a glimmer of hope... (just need to work out how to make it use less area now)
the whacky octree remains sadly but yep nfi why its doing that at this stage.. but yep as a drop in volume nav system for a large planet its getting closer
Hey guys, is there something easy to use for grid based enemy movement using pawn sensing inside a character blueprint? Making a fp dungeon crawler like Level and i dont want enemys to move diagonal to the player
a navmesh+landscape really shouldnt be difficult at all
combat variant is already setup like that out the box isnt it?
I'm still stuck on figuring out why smart nav link objects placed manually aren't working properly but auto-generated ones are
i am not sure how they work but do they need multiple volumes to make connections?
i did see some tweakable values that seem to govern what gets connected at what distance
like jumpable zones and what not
I don't think so
As I said, generated links work just fine, so I'm not sure why manually created smart links aren't working, I've tried a bunch of things
ah i see is smart link like a component such as nav invoker ?
I'm specifically using Nav Link Proxies
hm i just switched it on on mine to see ..
it knows it has a link 😄 but to what .. i guess we need to debug the nav links thing in the display part
Specifically, the "Receive Smart Link Reached" event does not fire
Also, I'm pretty sure this ain't right:
i wonder if the automatic ones are taking a different settings to the party
so the distance to connection is different or something along those lines
Generated links are a completely different class from places smart objects. You will have to debug the code of the placed ones to understand where is that callback used and why is not triggering for you
Oh, great, now the navmesh has completely stopped regenerating
if its on static then yeah
No I mean it's just not building at all and there's no navmesh period
Okay, had to try a new map but it seems to be working better there
...okay, so it was a problem with the level?!
That is so weird
(Apparently now smart links are actually working for some reason)
well i want to see what your up to.. no nav mesh at all could be vital for my planet project
lmao idk I think the level was just bugged
i think these smart links these are probably a custom class or something as i dont see them in the component or editor side
Nah, they're a component in the Nav Link Proxy class
ah right
ok let me take a look at this .. because yeah would be nice to limit the range of navmesh a bit .. even though you say this has no nav mesh so yeh 😂
Yes
Then that's your issue. Tasks run in parallel. Move to is probably starting before it gets the param from find random location
Put the move to in a sub state
There should just be a checkbox to flag a task as being exclusive or parallel execution
Just don't put two tasks in one state
There's at least delegates now you can use to hand data between at timed intervals and potentially StateTreeEvents and their payloads may work.
Hi all! I'm trying to make a Smart Object toy ball that uses a Gameplay Behavior Config instead of a Behavior Tree.
I was wondering If It's possible to just loop the behavior class? Im trying to have my AI kick the toy ball and subtract from it's Boredom variable, but loop until it's no longer bored, and THEN end the behavior.
On another note, I'm also trying to make it so that if the AI has to cancel it's behavior, do I just call a delegate in the behavior or is just ending the task connected to the smart object, enough?
Any help appreciated! Just trying to get this Utility AI system Ive got to work 😭
do a default back to root to create a loop in the main StateTree if thats what you mean
i am wondering why the path finding isnt working all the time with the system me and gpt made .. hard to tell if its the navmesh or the state tree
but it makes a very nice performant navmesh that works on the planet
when they do decide to path find they beat the living hell out of you when theres three or more of them
but yep also not clear why its not able to run up the slopes even when max walkable slopes is 89 universally
absurd step height
ones stupid little that really screws up path finding is if you have a relative camera reference mesh (for gravity camera) like my character has and its not been set to no collision
that was causing so much hell for navmesh
does anyone know if learning agents training and inference is executed on the game thread? if so, is it possible in theory, obviously with some delegations back to game thread, to move these processes to a background thread?
if you you are using a navmesh and using dynamic i think it makes sense to tick the do fully async data gathering option
not sure which one i turned on .. but that was one of them and it runs like a rocket for navmesh invokers
takes a little while to do the initial generation
its a settings in the recast actor btw
What I'm finding is that the BehaviorConfig seems best to be the generic logic then StateTrees Tasks handle the modifying etc, unsure this is the optimal flow though curious what you create
Had to make a setup similar to this today, using the Delegates and by ToggleCompletion on the first State, you can decide when and how things flow.
Then your delegates look like this, although caveat I'm running 5.7 unaware if 5.6 has any quirks.
Tried a few different struct/nesting setups and can only manage to get individual Structs or Arrays of Dispatchers to appear on the Listener options.
Imagine wanting a Tag to Dispatcher Map or something along those lines to have a bunch of events in a Task, but then can enable them in details per-use case. Wondering if anyone's had success?
Array indexes are a bit too prone to error but nice that they work.
But you could imagine some BroadcastDelegates coming off something like UseSmartObjectWithGameplayBehaviour, that each Task instance can toggle.
so I'm trying to get a sound sense working in StateTree to percieve gunfire or other combat noise. I'm trying to pass it through the global variable stack. However, I'm not sure how to make this flow. I'm guessing I need to vary the state tree event based on the stimulus. Seeing a character for a certain amount of time vs hearing combat should have the AI react differently. I feel like a gate is probably the flow control I would need, but I can't figure out how it would work in this case. Is there a different flow control I should use instead?
Hey So i Setup a simple spline with Ai controller and Behaviour Tree and its working fine, for single NPC´s. But as soon as i SPawn more then 5 at the time everyone after the fourth just walks directy to the last spline point. And i couldn´t figure out a solution yet
maybe someone of u got a good advise for me
I’ll see what I can do! I haven’t messed with state trees yet though but hopefully whatever I come up with can just work. Thanks!
https://youtu.be/AT_u5GlNn2g - kind of having a similar problem not sure where in the state tree it is but something makes them stop flanking/perusing the player..
its either in the state tree or something with the nav mesh invoker/radius is all i can think for my problem
Can someone please tell me what is the use of a State's Gameplay Tag? Afaik, there isn't a way to query your current state's tag from within a transition or an enter condition, or is there?
check out the sub state tree
it might have something that can check the tag off one of the various nodes it outputs
and if was referenced inside of blueprints this its just a case of hastag()
Are you talking about setting a State's Type to Subtree?
Also, I think you are oversimplifying your answer. A matter of HasTag? HasTag simply checks a container to see if it has a tag. There doesn't appear to be a way to query a tag from a given state from within a Blueprint.
yeah thats why i said .. with the substates it makes sense that they could find out the tags as children of the main state and perhaps blueprints.. but other then that i dont know a really valid answer to provide you at this point 😄
Yeah it's okay. I agree that it would make sense for a subtree to be able to query states.
As of right now it appears that states have this "Tag" property that is not usable in any way lol
yep learning the ropes with this ai stuff bit by bit
never imagined how much of a important part of the game design it would be
yo same!
state tree seems super cool
StateTreeOverrides can use them
Are you talking about setting a State's type to Linked Asset and choosing a state tree asset? How can you use state's tags that way?
I'd really be interested in a simple example or explanation on how a state's tags are useful
let assume some where a sub state knows about multiple main states it can now tell the difference?
so the logic isnt going bezerk
heh i dont know why but yeah with networking you tag your vlans etc to create the network separation/hierarchy you want
I can totally see how a sub state would want to know about its parent states and such but it would probably need to query some sort of parameter or an Actor/Object's exposed tag container or something
Since State tags are basically un-queryable
yeah its probably just being exposed in the C++ side because its basically a variable
that they havnt done any thing with yet
Look at the StateTree comp you put on things and underneath it you'll see a map list, add an item. It's tags mapped to StateTree.
My understanding is you can override basically any state, so lets say you have an attack state but your enemies ranged you add an override via tag.
State.Attack
Then in your comp you can define a new tree to override a state or portion of the tree with
Then you markup the tag internally with that tag
oh no way, is this really possible? If so thats effing awesome
have you done it?
Holy toledo, it really does work.
Thank you so much, this is actually really cool!
All good, honestly I found it by accident myself. I think because the value of it is that the systems are decoupled it sometimes makes discovery tough as there's no overly prompted connections between elements.
I would enjoy some more tag usage but there's other ways, like a default task or state that adds/removes tags to your context actor/object.
I think this is a core benefit of stateTrees allowing a per-instance state/subtree override etc. But people are still figuring out the best ways to use trees in general.
when I'm tracking values in the global AI variables, is it meaningully expensive to track the amount of ammunition remaining on the actor's weapon/ their overall ammo count? Or should I just be tripping bools saying "low on ammo" when hitting a certain amount? I want to control how much fire the enemy will lay down and movement decisions based on the enemy's state
Is there a way to make state in ST only transition when all task finish?
Depending on your version you can use these, then have the Tasks send an event to a "complete" task. Then when the StateSucceeds on the complete task you let it through
Which version is that. I am using 5.5
At about 11 minutes onwards you can see about task control flow, then there's also event delegates. Both will help. https://www.youtube.com/watch?v=bvWHU5nvU-0
Oh sorry, I am in 5.5, I just confuse.
You likely have to make more sub-states then than have big task lists. Unless you find options others have used.
hey fellas i'd like to ask is there something known about blackboards that i might be missing that causes the keys to not be overrideable from tasks, services, or even the owning actor bp. i'm having an issue where every key isn't changing and my decorators are returning fails. sorry for the bad england
Can you show us how are you setting the bbk value form a task?
sure these are inside a service that was the intended way, i've also tried the same exact script as a task and ran it parallel to a selector which didnt help
I'm not sure if bbks are case sensitive... Could that be it? I see you have the name in lowercase. The other thing is, if you set a breakpoint in the set call, does it stop?
yes it does stop also i have a print on the right side that prints the boolean and the bbk value and that runs too, it used to be Target in Range and all pretty but its just me losing my mind. i copied it from the key directly. this is still on testing branch so i just name stuff like whatever. i really do wonder if there's anything that might cause this under the hood or somewhere i am missing. in a new project it works and i cant seem to recreate the issue
Regarding state trees - has anyone come up with a useful "cooldown" enter condition? Like the cooldown stuff in BTs. Every solution I've come up with has sucked. Requires more plumbing than I'd like. I am hoping that the new ExecutionInstanceData could help here, but I'm not on 5.7 yet. Also don't know if it'll be accessible for enter conditions.
Solutions:
-
Use the GameplayEffect cooldown stuff. The thing that sucks about this is that it relies on GAS. But you could just check if they have the cooldown tag that gets applied. The GE will automatically remove it as well.
-
Take that same idea - but just put a GameplayTagContainer on the actor in question. Then you also have to manage adding/removing the cooldown yourself. This just removes the reliance on GAS.
-
Have cooldown times on the actor itself - check if they're off cooldown. This is very much not scalable unless you have some global cooldown for whatever action the AI is doing.
-
Have parameters in the state tree (be it global or parent states) that have the cooldown time. The state tree conditions can't alter these values because the function is a const function (haven't tried native code yet). Idea was to update the cooldown time each time the enter condition was evaluated. But couldn't because it is a const function.
-
Same idea as above, but in your action task, update the parameter to the last activated time and then for the enter condition, just do that comparison. But then this requires 2 variables per action. One for the last action time and one for how long the cooldown should actually be.
-
This is a really cursed one - Have a global task (in native) that ticks. Expose a cooldown property for each cooldown you want. On Enter state, use reflection to get them all and add references to them to an Array. Then in tick, loop over the array and update the cooldown time. The suck about this is that it is in native - so iterations suck.
We use #1, but it's natural for us since the entire game is built on GAS
Yeah - it is the solution for GAS projects. But I'd like a solution as easy as the BT cooldown stuff.
Without a dependency on GAS
And the value is the one you set before the print?
yessir it's the exact same one, i actually never seen a decorator fail. is this caused by the variable being empty?
Which variable is empty?
Then the setting works. Could it be you are re-setting it later somewhere else? If you debug the tree and observe the BB values, can you see it change?
Hi if i have a NPC Chasing the player and then i change the target, the Npc wont switch "command" untill it finnish the current behavior tree "task"
how i "reset the task" or make it complete so it can run again
Are you using BTs? STs? Custom solution?
bt behavior trees ?
Make sure the BB Key is being observed - and then when the value changes, abort self.
yeah but chaning a key value to the same value will that trigger ?
Just like how you have that decorator on the Attack Sequence
But add in an abort option
For that - you'd want to select the other one instead of value changes.
i would want the "enemy target as a blackboard key value" how do i add it ?
It is one of the two. I can never remember.
yeah i know
Also - why are you using the BT like a state machine?
but im not changing the key value
Having a key as AI_State is a big code smell for BTs
(this is a pack i bought for learning behavior trees) i did not make it :;P
Oh, well, in that case - that's concerning
Shows a fundamental misunderstanding on how to use Behavior Trees
Behavior Trees are extremely straight forward.
yeah but learning it is a a slope for sure
so i just start by tweeking stuff really, but your saying this is not the way a BT should run
?=
Its not the way it should be designed
You're (they're) just using it like a state machine.
So you're now managing the AI state AND the Behavior Tree
Not to mention you are having to handle the state machine's transitions elsewhere
IE - what sets it into the Attack AI_State
yeah well i got the state switching under controll
For now
The issue with state machines is that as they grow, the transition stuff explodes
That's what Behavior Trees solve
yeah i can imagain
Behavior Trees can be thought of as "priority" selectors
Put your highest priority behavior at the far left of the tree
And then order it appropriately
Each branch is then gated by some condition
And the Behavior Tree will then just go from left to right until it can execute stuff successfully.
That is pretty much it in its most simple form.
hm alright
but ill have to dig deeper later with that, maybe start from scratch doing my own
but for "now"
i imagain if i can add a actor reff in the "blackboard key value" section that when it changes it i can use "notify observer "on Value change" ?
right ?
or dosent work like that i suppose
You have a few concepts to understand to write a Behavior Tree in UE:
-
Selector node - Runs each of its children, from left to right. Returns success only when the first of its children succeed.
-
Sequence node - Runs each of its children, from left to right. Returns success only when ALL of its children succeed.
-
Decorator node - This is primarily used to do checks (so like you already see). At least like 95% of the time I've seen people use it.
-
Service node - This is just another way to have "parallel" running nodes. So you can put it on any other node and it can tick. That's what it is used for really. (I also like to use this as the way to alter data for a branch - though Decorator can be used to do that as well, personal preference)
-
Task node - this is the leaf most node and where you do your actual work. So like finding something, moving to something, etc...
-
Blackboard - this holds all the data that is accessible to the tree (not counting direct actor references like the AIController or Pawn)
hm alright
And with that - you have all the information needed to actually write your own behavior tree
Correct
The "Notify Observer" property is the one that you want to change.
I can never remember which one will abort regardless if the actual value changes.
50/50 shot - so that means I'll get it wrong.
Also - is there any particular reason you're not jumping over to State Trees? @scenic ingot
As it is the future going forward. With plans to deprecate Behavior Trees.
It is certainly more complex than BTs though (at least in my opinion)
hm well i just had to start somewhere
and i bough this badboy for like 5 bucks
so.. no reson just imagained this is how its done really
But thats for the info, im saving these text and i will try doing my own lateron!
Since when BTTasks are red? 🤔
My BTs keep losing data and BB reference
might be related?
side question: does SuspendBranchActions in BTComponent stop BT evaluation?
wtf RunEQS task delegates not exposed to BP
how do we get a callback??
OK bt was corrupted.. despite BBs existence it never serialized it
so my tasks were also failing because of this

is there any way to use UEnvQueryManager::RunEQSQuery in a UObject?
as in calling it from a UObject?
you can run EQS wherever you want in c++. In BP's I don't think you can outside the BT/ST/Mass ecosystem
The latent BP function only appearing in AActor derivatives but I have GetWorld override in my UObject which should make it work in it's own graph too but doesnt
Who's the querier in the UObject?
Its not, I am just trying to execute the function in a custom object that is similar to a GameplayAbility
yeah but... an EQS requires a querier that is either an actor or an AI controller if I'm not mistaken
Right, but I should be able to provide it with a param. The task function should suppose to work in a UObject too but doesnt seem to be. I guess I won't use it
Btw, to clarify, it doesnt even get pasted to the graph as a node
Not that function doesn't work when executed in runtime
the task function you men the AI Task node? not sure I follow
Yeah, I am on mobile rn. Check the function I sent*, it's a BlueprintInternalOnly that to be used in Blueprints
Or I can send screenshots later on
do you mean RunEQSQuery node?
Yes
that's a BT node. That can't work outside the BT ecosytem
But in C++ is trivial to do that kind of functionality
Its a BP node
declared in UEnvQueryManager
It doesnt work in UObjects because BP compiler requires the underlying UObject to implement GetWorld function, which normally should work but doesnt in my own UObject for some reason
probably compiler is confusing the context because of this param
aaah you mean that one! I thought we were talking about the one in you previous screenshot form a BT. Sorry I completely misunderstood you
np, I was on mobile so couldnt be communicative enough 😇
have you checked where does it fail here? I'm guessing it fails to grab the EQSManager?
due to how this works maybe?
It doesnt appear in the function call list in the BP graph
and when I try to paste it from another actor based BP it doesnt let me
so problem is I cant even call it at the first place
aaah ok ok got you now
Yeah can't help much I'm afraid. I rarely use BP for this kind of functionality. We usually do our stuff in c++ and expose things to designers in BP's
partly #cpp question instead of #gameplay-ai i guess, since its kind of related with reflection system. but thanks for the initiative! 
let us know if you manage to fix it blueprint-side please. Always nice to know solutions for these issues
anyone see any documentation or further explanation of Statetree "live property binding" from the 5.7 release notes?
Documentation is on the header files (yep....). You can find some more in the chat here
Output parameters can update the value of state/tree level parameters that you bind to it (yeah its a bit weird binding to output, think of it as property ref)
oh ok. Is this the completion/bug-fix of the feature of having a task with a property binding as a param variable? I was trying to get this to work in 5.6 but it just wouldn't update properly, especially in BP.
if that was a ticking task, async or anything else that needed to update a parameter value after initializing then yes this is a partial fix for that. If you use dispatch/listen task delegates in the same state, then a fix for that is coming in 5.8
awesome, thank you
So does it only work if the property is marked as an Output parameter?
yes at least for now. I agree the difference between parameter/input/output can get a bit fuzzy sometimes.
It wouldnt make sense binding to an input parameter, since it would be a bit confusing if that allows the task to change the value of the parameter passed in.
I just stopped using Output/Input because Parameter just allows me to do w/e I need at the time.
But in BP tasks - I just make it visible everywhere and that works too
But now I actually have a reason to use Output
I think it would be clearer if there were only two types really. One that defines a new parameter (owned by the task) and another one that passes by ref?
what do you think would be the most intuitive approach?
Well - if we're stuck with relying on Categories (which is not intuitive at all) - minimizing them overall would be nice. But I'm not sure how large teams would work. I know having more explicit intent is generally good.
But I generally try to use the simplist stuff personally. If we could reduce it down to just two (Parameter and Output) - that'd be good. But as it stands, we have like 4 or 5? Context/Input/Output/Parameter
@slow bobcat Could probably offer a different insight. Because with more structured teams - having the restrictions on how something gets bound can be important.
We might even be able to reduce it down to one (just output).
Specifically for live property binding functionality though.
Because if you make stuff public - then, it is bindable in the task.
But again - I'm only speaking from a small team perspective.
what ExecutionContext struct type should i use to cache it for a undertermined amount of time ?
it seems that none can be used since their & operator are deleted
You don't really
ExecutionContext is going to be created every frame
You can create a weak context though
Then from there, you have to make a strong context again
In 5.7, there is a new thing called like ExecutionInstanceData - that is meant for longer lived data.
But haven't messed with that yet as I'm still on 5.6
For the weak context stuff - look at how the EQS task does it.
That's what I copied
My 2 cts: makes little sense to us that each category is for a different thing. Ideally, just one type, like a parameter passed by reference to a function in c++: you can read its value and write to it. On top, you can bind it to some other param. Up to you what you do with it. I might use it in 3 different ways in 3 different functions
I would agree - but I'm not sure how to handle that in BP land.
Because variables don't really have a "by-ref" concept in BP land. Function params do.
So the bindings would need to be able to support that
So, an easy compromise for 5.8 (🙏) would be to just support the Output category and then rely on normal specifiers for everything else.
Small step towards greatness!
@chilly nebula 👆
Hope this answers your question!
A BP enjoyer lens here but one thing that's a minor QoL that I'm finding missing in my 5.7 is the out/in visual that tasks previously had.
It's such a handwave element but I think the value it houses it clearly showing intent at a glance of a task. In a world of 1 category it'd be nice to see this somehow maintained, even if there's the occasional quirky input for Ref purposes.
What is the correct way (without using the deprecated handles) to see if a StateTreeTask was transitioned into from itself in EnterState. It seems very obnoxious as
SourceState has the following deprecation
/** Transition source state. */
UPROPERTY(EditDefaultsOnly, Category = "Default", BlueprintReadOnly)
FStateTreeStateHandle SourceState = FStateTreeStateHandle::Invalid;```
but CurrentState still uses the FSTateTreeStateHandle.
How am i properly supposed to compare the source state to current state. The CurrentStateHandle is by index, and the source state is a unique ID that is not the index.
surely there is a non deprecated way to do this? been digging for 30 mins and im not really sure how to get a State via ID and then compare it against a state handle
One of my most desired features for state tree is getting a debug output for sub/parallel state trees. Right now we can only dump the root tree running in the brain component and all parallel state trees it might launch we can't dig into to get even a print out of what states are currently active. (I'm talking about in the gameplay debugger, but also any custom tool)
Unless I'm missing something?
What about the state tree debugger and the rewind debugger (if in 5.7)? And visual logger?
Yeah that definitely works. For my purposes it'd still be nice to get a quick view in game before I have to open up other windows and start drilling down into what's happening
Anyone know why the SourceStateTree and other elements was deprecated from the transition? Trying to figure how to BP access the SourceTree without having to manually expose up the data
Yep... I get you. We have this problem debugging builds with both, bt's and st's. For St's I changed the engine source code to get access to the debug data in the St and print it in a window within imGUI
It seem like I can not bound to member of tmap. Not sure it is supported in newer version.
There were some issues with binding into tmaps and arrays, I believe most are fixed in 5.7. Currently looking into fixing issues around UDS for 5.8
I am using behavior trees for first day and i am super confused
like... I defined a behavior tree task and what is proper way to call code from my character-derived blueprint class
I created ai controller, I use behavior tree in it
but my attack logic is function in my character at the moment and I doubt the proper way to interact is to use owner pin "Event Receive Execute", then use "get ai controller", then "get controller pawn" and start from there - seems to be wrong design on my side 😛
You can use the task to call the event inside the actor via casting
Not sure if that’s necessarily the best way
well this is what i have right now
but this double casting feels like i do something wrong
another thing is this task is really not universal and will only work with one class and its subclasses, and there seems to be no way to block this from misuse on other kinds of actors
Use Execute AI. It supercedes the other one.
The owner actor is the pawn that this is running on, you don't need to do all that casting. Just cast to your class.
Use interfaces, components, or base classes to make the task less hardcoded.
yeah, Event Recieve Execute AI
Anyone know why i cant use a enum on a property ref and set var on it ?
When i attempt to the enum has no spaces but when enum is used in type a space oddly gets put in when there should be none
#blueprint message you can see more on my issue here
I posted in there before i remeber there eas this channel you see
Has anyone gotten a good solution working for preventing multiple AI from selecting the same GeneratedNavLinkProxy ?
The regular nav link proxy has stuff in there to lock one up, but GeneratedNavLinkProxy doesn't seem to have that.
Overriding IsLinkPathfindingAllowed doesn't seem to prevent others from using it after they've already decided to use it for a path, we'd need something to get them to recalculate?
(This is about the auto generated nav proxy class)
Cant you set a class override for the generated nav links ?
Seriously... Does that spam ever work? Fuck off from formative servers you morons
i still havent found a way to hide a task declared in cpp
Is it a UObject class? Can you label it as abstract? Wonder if that works
C++ state tree tasks are structs
Right... It's only the isntanced data that can be done a UObject no?
Without the code in front I'm not sure
i think yeah, it got support around 5.6
but in my case i got a base task that i want abstract
but it shows in the picker
Look at at how the CommonBase task works
The tasks generally inherit from that
Then check to editor code to see if they have some special thing
seems like meta = (Hidden) should work
Is there any way to access the weight of tasks within a linked subtree? Trying to have a 'random by weight' selection process for some tasks, but i'm also using linked subtrees with nested weights.
Wondering the best way to get that data and make the roll account for it.
Yeah I have one, but I wasn't able to have a link properly lock itself when it's about to be used, others still choose it when pathing for some reason.
Need to reserve it as soon as 1 AI decides to use it in it's pathing but there doesn't seem to be much in the way of notifying when an AI is moving to it until they've reached it, by then plenty of other AI have chosen to path to it as well.
Hi... what's the best way to go about data persistence in statetree tasks? I assume that each time my state tree executes, new task instance data is created, is that right? So how do I make variable set by a task available to that same task the next time it runs?
This sounds like you want to use the StateTree Parameters, but they also mention some new features in 5.7 for longform data if you want to look into that. State Tree property Refs and how you access the ref for those parameters is covered here. https://youtu.be/bvWHU5nvU-0?si=M25kmbL-qayd4kSC&t=501
Thanks, I've used parameters before as static data. I didn't know you could also write to them dynamically. Will check that out, thanks.
Getting used to have them as inputs can be a bit strange as I'm finding but it works nicely. I feel like I should probably just make my context 'object' house a data object or something but still working through it
Hm, still doesn't look like you can use tasks to directly write to parameters. And I'm still in 5.5 so I can't even write a function on my AI controller to write to the property. Stuck with managing variables directly on my controller for the time being it looks like.
Ah in 5.6 this should work, it's just contextually not StateTree but that NPC_Data in this context in an IN of type StateTreePropertyRef. Once that variables created you then look at where the defaults normally are and can set the reference variable type.
Can't guarantee 5.5 though
In 5.5, doesn't look like that exists, sadly, not on the blueprint side nor in c++. I'll revisit maybe once I upgrade my project.
We started using ST's in 2022 so we use a Black board like with Bt's and we made custom tasks and conditions to read and write values in it. That way you can have generic tasks that do not use data in components or whatever, making them reusable in other AI's (like what you do with Bt's)
@slow bobcat the issue earlier regarding to RunEQSQuery task node not appearing in my UObject was because GetWorld was not returning a AActor outer's world
UWorld* UCapability::GetWorld() const
{
//Return null if the called from the CDO, or if the outer is being destroyed
if (!HasAnyFlags(RF_ClassDefaultObject) && !GetOuter()->HasAnyFlags(RF_BeginDestroyed) && !GetOuter()->IsUnreachable())
{
//Try to get the world from the owning actor if we have one
AActor* Outer = GetTypedOuter<AActor>();
if (Outer != nullptr)
{
return Outer->GetWorld();
}
}
return nullptr;
}
having this kind of a GetWorld function fixed it
Thanks for sharing the solution. Didn't know about TypedOuter.
You should catch GetOuter because if that's null (it can be null), you will get a crash.
I suggest you do something like this, catching it and using IsValid, since that checks for nullptr and it being garbage collected (or pending)
{
UWorld* returnWorld = nullptr;
//Return null if the called from the CDO
if (!HasAnyFlags(RF_ClassDefaultObject))
{
AActor* OutermostActor = GetTypedOuter<AActor>();
// make sure the OutermostActor is in a valid state
returnWorld = ::IsValid(OutermostActor) && !OutermostActor->HasAnyFlags(RF_BeginDestroyed) && !OutermostActor->IsUnreachable() ? OutermostActor->GetWorld() : nullptr;
}
return returnWorld;
}```
yeah fair call, thanks
That's a great solution. I take it you integrated this with a custom ST AI Component?
We use a custom st component but you don't need it really. Just do the work with the tasks and conditions
Hey guys, I need to add some custom points to my paths that might not be ready on RequestMove. So I think I need to pass a FMetaNavMeshPath as InPath to Super::RequestMove, so it can wait until the path is finished
Anybody have experience doing this? I could found little/almost none info online about this
The code snipped below is inside FPathFollowingComponent::RequestMove, and is the path of the code I hope can be useful to me
// with async pathfinding paths can be incomplete, movement will start after receiving path event
if (!bIsUsingMetaPath && Path.IsValid() && Path->IsValid())
{
SetStatus(EPathFollowingStatus::Moving);
// with path segment should be followed
const uint32 CurrentSegment = DetermineStartingPathPoint(InPath.Get());
SetMoveSegment(CurrentSegment);
}
else
{
SetStatus(EPathFollowingStatus::Waiting);
GetWorld()->GetTimerManager().SetTimer(WaitingForPathTimer, this, &UPathFollowingComponent::OnWaitingPathTimeout, WaitingTimeout);
}
the reason they are not ready at the moment RequestMove is called its because Im using a EQS query to find one of the points I want to insert in the path, so it will be ready at least the next frame
@chilly nebula is there any information available if the IN/OUT visualization was removed intentionally or as a bug? Wondering if it should be expected to no longer display going forward? Visualization being akin to how context shows here. (Soz for ping but about to build system and can't find anything about it don't wanna commit if it's a bug)
Is anyone experiencing the StateTree Exit Task triggering even though I'm returning EStateTreeRunStatus::Running on both enter state and tick?
it is on 5.7
If you look in the tree debugger, does it show any transition triggering?
looks like yes, not sure where this transition coming from, still looking on this. I tried same code base on 5.6. it is not happening on 5.6
The exit state I mentioned is Engage state. I have engage task there. I tried to put breakpoints on every possibility of "Succeeded" or "Failed" status on Engage task. it is not triggered. it keeps entering and exiting the task.
In/out should still show, if it disappeared 5.6->5.7 then its a bug yeah
FVector FTDSRecastQueryFilter::RecastToUnreal(const dtReal* RecastPoint) const
{
return FVector(-RecastPoint[0], -RecastPoint[2], RecastPoint[1]);
}
float GetPathPointCostFactor(const FVector& PathStart, const FVector& PathEnd, const FVector& PathPoint)
{
FVector PathDirection = (PathEnd - PathStart).GetSafeNormal();
FVector PointDirection = (PathPoint - PathStart).GetSafeNormal();
return FVector::DotProduct(PointDirection, PathDirection);
}
dtReal FTDSRecastQueryFilter::getVirtualCost(const dtReal* pa, const dtReal* pb, const dtPolyRef prevRef,
const dtMeshTile* prevTile, const dtPoly* prevPoly, const dtPolyRef curRef, const dtMeshTile* curTile,
const dtPoly* curPoly, const dtPolyRef nextRef, const dtMeshTile* nextTile, const dtPoly* nextPoly) const
{
dtReal BaseCost = FRecastQueryFilter::getVirtualCost(pa, pb, prevRef, prevTile, prevPoly, curRef, curTile, curPoly, nextRef,
nextTile, nextPoly);
FVector PointA = RecastToUnreal(pa);
FVector PointB = RecastToUnreal(pb);
FVector SegmentCenter = (PointA + PointB) * 0.5f;
float Progress = GetPathPointCostFactor(PathStart, PathEnd, SegmentCenter);
return BaseCost * Progress;
}
Using a custom filter?
It looks like in UE 5.7 all child states (including their tasks) are forced to complete when the parent state succeeds. I need to get the current target from the parent task OUT and evaluate it once so the child states can reuse it. But since "Get Current Target" Succeeded, all child states are being forced to complete as well. I changed the State Tree hierarchy and moved "Get Current Enemy Target" into each state that needs it. It tried global task, but it only evaluated once
Yeah I see myself doing this if I ever find the time
I believe COMPLETED has always fired down the entire (active) tree when 'sub-states' complete/succeed. It's why I tend towards succeed/fail because that complete firing constantly is very confusing at first
ye, not sure, it might have been a bug in 5.6 that was fixed in 5.7. This is more likely an issue with my design perspective
Could someone help me with my AI pelase
here you can see it is trying to get to the box on floor which is where it last saw player
now there is a nav mesh there so it should be able to reach that fine but it seems to just sit on the Move To on the state tree but not actually move to the location and I can't work out why
thats the settings of the move to
really need help here cause if I were to use target actor things appear fine but use destination and don't seem to work
you can see it seems to just stop working once its in that track player
Do you project the location to the nav mesh? Sometimes the Z might be too low meaning its not actually on the nav mesh.
so the move to appears to have a tick box to project the destination to nav mesh unless that doesn't work for destination and only the actor reference
Is the task a built in one? Not used state trees for a while.
its the move to in State tree
the one already there
so from what I can see here it's able to get the location on nav projected and this calls finish task with succeed
but for what ever reason it doesn't move on to the move to task which uses the built in move to state tree has
this only happens on this task and situation as well. all the other places I've used the move to built in state tree thing stuff is fine
i am so confused why this won't work
If you check in visual logger for the navigation and path following categories, what does it show?
so thats just before the AI looses sight of player
and thats after it looses sight of the player
that don't make sense
so thats saying the location it's trying to go to is 0,0,0 yet it can't be cause it's set
the location move to is using is a parameter on state tree which is set there on tick by a global task which is grabbing information from controller for state tree to use here and there
so i've verified the detected actor location is being set correctly to something other then 0,0,0
so i'm stuck here
from what I can see only when the AI switches to trying to move to the location does it all seem to break
where as when it's moving towards the actor etc it's fine and this is using the same node baring in mind
so you can see it has a location
and finish success task is called so it should be moving onto move to but doesn't appear it does and just fails
so that what vis log is saying when it looses sight of the player
So ive had to park the issue for now cause i cant work out why it wont move to that location and ive double triple checked the location it should move to is valid and stuff
Anyone running 5.7 ? and able to confirm they don't see the IN / OUT tiles akin to CONTEXT that you used to see?
hey guys, how is the ai seeing me (sight) through a door blueprint i have
it has scene -> static mesh
it gets sensed successful
but if i just put a static mesh without a blueprint it can block it
Check the physics config in your door
the static mesh it is block all dynamic block everything, object type world dynamic
2 doors block it but not one
it's like it's too thin or the ai can see through it lol
Umm strange. Are you checkign the setup in runtime? Just in case you are changing something without knowing
tbh the AI can just see through static meshes too by default, it's really annoying
Hello guys! Why it doesnt work? I try get player in parent state and check is valid in child state, but it doesnt work! Active state after BeforeStartSearch set OnStopFearSmellSearch
If your state has a selection type "TryEnterInChildren" it will evaluate the condition THEN enter. But here it fails cause the object is not yet set
You need to change the selection type to TryEnter instead then send an event or request a transition to check your object validity
It works! I change BeforeStartSearchFearSmell to try enter and on state complete call OnStartFearSmellSearch and it works!
Thank you
It turns out that in my case, the check was first performed in the child state, and only then the tasks themselves were executed inside the BeforeStartSearchFearSmell state?
Yes enter conditions are executed first to decide if your whole state hierarchy should be entered or not
The documentation of statetree explains how state are selected and executed
With "TryEnterInChildren" The parent is not entered if we didn't selected a proper leaf
BUT once it got executed, it executes the enter states of the whole hierarchy in order from top parent to last children
Thank you very much!!!
Can someone help me please on my issue linked here #gameplay-ai message
for some reason when the AI trys to either go to players last seen or really any location the AI breaks down and fails it seems
but when the AI is doing everything else it's fine and does it with minimal issue
Have you tried disabling require navigable end location and/ or project goal location? I was having similar issues and that fixed it for me
so don't i need project goal location to on ?
yeah that also happens to me.. the ai jsut either thinks theres no threat any more and wont flank or something else i am not sure why... (but I am using a experimental nav volume for a planet)... which overall works.. but some times the AI just gets stuck infront of another one with that option switched on ... but also seems to make it better in other ways, atleast they dont completely give up if that makes sense
and yeah they do some weird side way runnning thing also
not sure if any ones seen that
that might just actually be a faulty anim blueprint which is use left/right input turning it back to side scrolling
but if your ST does have a percieved threat and you dont fight back then it might also be functioning perfectly
fight back they start to flank/evade again
so i think I've found the issue
so I pull the detected Actor location from AI Controller and set it locally on the global task
and then when AI looses sight of player the Detected Target Location is not updated any further so should be what ever it was last set to
however it seems for some reason even though its being set, it seem to show it's always 0,0,0 and never set to anything which I don't get
fixed it
I forgot that before I was setting a global parameter using set var and I changed it to just be a vector that can be linked to in doing this I never removed the link between the vector on global task from the global parameter so it essentially was working as designed just not how I thought it was working
who ever was saying they cant see the IN / OUT stuff
?
and yep @serene fern are you ticking to the next task such as "evasion" for exaple at the end of the state
??
anyone having issues with EnvQueries on state trees? If I put this on a test pawn it works fine, but in the state tree the results always come out as empty
ok, to my understanding the perform scan is executed before the query can finish, so I guess I'll have to use different states?
ended up going with performing tasks in different states, would have liked it to be possible to do in a single one though
also with custom state tree task to run the envquery
This is just a problem with async tasks in general.
I believe Siggi said they're working on this stuff.
oh nice. that would be amazing
have to do a lot of these "hacks", different states with bool check enter conditions
you aren't using async tasks?
I am
how do you handle waiting for a result within the state tree?
Depends on the context.
Looking at just what you posted in your most recent screenshot - the enter conditions on the two states don't make sense to me.
Do you only want to scan one time or something?
Is the EQS doing the scan?
If so, why are there two tasks for a "scan"?
the eqs is acquiring the 10 locations, and the perform scan is rotating the character around those points
I don't want it to keep running the eqs everytime it goes back to the parent, if it's already running
Why would it leave the "Perform Scan" state?
I set it to, perhaps I shouldn't have?
The EQS task should only complete after the EQS query completes. Or it should fail for some other reason.
Okay - so it fails when there are no vectors. That should be an enter condition
I have it doing that
If the state requires valid entries in an array - it should be an enter condition
I'll have to make a costum one then, I don't think there is one for that
The EQS query will stop running...well, stop being useful I should probably say, once the state exits.
Correct.
perhps I don't need the check then. since the state is only completed when the query finishes
Correct
thanks for the brainstorming
And if you ever introduce state interruptions - make sure you handle the Exit State
No - I mean if you plan on supporting going from one state to another without the active state being what determines that.
IE - send state tree event
yeah I have thoses
what should I do in the exit state exactly? finish task terminate any running async task?
or query in this case
Just clean up your query.
I have check in each state if the motivation changes, for transitions
I don't recall the exact API for it. But just make sure you cancel it if it is running or something.
ok thanks for the input
Why?
Sounds like a global task that could be doing that
And then it can then tell the state tree to transition
and call an event?
Or use the State Tree delegates.
-
The "Motivation" enum seems redundant to me. It looks like your managing a state machine elsewhere AND this state machine. If I'm wrong, then just ignore me.
-
The STT Adjust Movement Speed could be on the Aggro state (not that it has to mind you). Enter State = change movement speed. Exit State = reset to default.
-
There is no reason for the enter condition on the Attack state. That's what the acceptance radius in the Move To task is for.
-
Depending on how you want the AI to behave, the "STE AIPerception LOS" enter condition could be redundant as well. Once you actually successfully get the sight, you can immediately transition to the Aggro state. Of course, if you have some other reason for it, ignore me. (Like maybe you want to have some delayed investigation or something, but even then, you don't really need that kind of book keeping)
-
just using the motivation for the state tree, mostly just for blocking entry to the states
-
hadn't thought of that, actually nice idea
-
there was a reason for me adding this, can't justify it now, I'll do a check, thanks
-
I use it for other internal checks and for investigate, but yes it is redundant for aggro state
Yeah - so, that is entirely redundant work. The State tree should already know what state it is in, and what state it should be going to.
The extra enum is extra book keeping for the sake of extra book keeping
but to my understanding the state tree will always try to run each state, so there needs to be some kind of gate keeping, no?
Proper Enter Conditions
