#gameplay-ai
1 messages ยท Page 78 of 1
IMHO, same goes for AI most of the time tbh - not always - best AI tool is your scripting language
Yeah - angelscript is ๐คฉ
If you haven't given it a look, it is definitely worth it imo.
maybe. I would need to use it extensively in a game that is not hazelight to compare it to GAS.
been trying to convice people in the projects I have been part of to use it. Never happened.
All script files are available if you download free friend pass of Split Fiction
No what I mean is the entire system. As "I want to develop the same souls game I have released with your system instead of GAS" and see how it behaves
I was ranting and raving about it a few years back.
That said - they don't have the capabilities stuff inside this. So you'd still have to build that.
I recently made a souls AI system based on decompiled files of DS1-2-3 games, on top of GAS. Probably would work better with capabilities but ymmv
Is there a way to call events on an owning actor directly from an owned state tree besides going through a task?
I question that as a heavy GAS user. But I have never been in Hazlelight so... I will never know
The big drawbacks of the fork, if you're not really aware of the fork in general:
-
No interfaces. So if you rely on this a lot, rest in pepperonis. Hazelight prefers components over interfaces.
-
No async. It is all callback driven. Which is what people are mostly used to in C++ anyway. So this is up to you.
Otherwise - it supports pretty much everything you likely care about in BP scripting. With better iteration and more performance.
@slow bobcat
And of course - there is the big potential drawback in that it is a fork.
So that can introduce some extra complications.
I would love to give this to our designers. They will do really cool shit for sure.
The no Async scares me a lot but...
Will see how good is Verse when it comes out in 2300 years aprox
Honestly - if you want a low-risk look at the workflow, you can check out U#. Because it is a plugin, so you can just drop it in and remove it as well. No fork required. But it is C# and not as stable as the angelscript one. But it is the exact same workflow (but it supports async and interfaces). Not saying to actually commit with it, just to check the workflow of C++ > text scripting language > Bp
one thing that bothers me with GAS (subjectively) is ability tasks. Epic designed GAs and tasks as "blocks of gameplay" because its mostly designed to be written in BP. Then also GAS conflicts with your AI tools. BTTask becomes wrapper of GAs which is annoying and limiting or causes you to write boilerplate code a lot of the time. I'd prefer my GA itself become a latent space on its own so I could do whatever I want but then network systems wouldnt work in replicated environment ยฏ_(ใ)_/ยฏ
I dont think so
Don't you just send the an event to the state tree? Or am I missing something?
Or are you talking about like, a BP event?
this is just a UPropertyBag encapsulation through FInstancedStruct ๐ค
Descs represent the memory offset and other data in created Upropertybag which FInstancedStruct owns the memory of
a BP event
I see your point but this is you wanting unreal to work in the way you worked before.
That said: 99% of our GAS stuff is in c++ only.
The BT stuff... yeah? The bt runs a leave that does X, in your example run a GA.
Not sure what is expeceted there otherwise.
But these are uses cases for specific approaches.
We do what we can
Yeah - then Eren is right. Any behavior is expected to be done through a task in the state tree. Calling an event on the owning actor would be behavioral.
that makes sense
yeah, that I can see. It's just "how do I use this?" "how do I get this in a mutable way from my tree?" "what's the right way to handle it?" and other stuff that is taking long
I see your point but this is you wanting unreal to work in the way you worked before
we're comparing with capabilities, not figuring out a perfect ideal version of GAS
capabilities seems to be fixing those issues without giving away anything from GAS-like features
Target Data is pretty crummy. There, I said it. ๐พ
maybe. I can't know. Gotta trust you for it.
I have suffered GAS but seeing it in action in a very complicated deep AI logic in super nice to see.
Would love to see Capabilities in action. See how 3 players with streaming levels behaves, what would happen with network prediction and rollback etc. Not that I'm an expert in that, but that's were GAS has been nice to have.
What's the "Game Play Effect" in Capabilities? does it have a similar concept? full data driven modification of a capability/owner?
not perfect by a long shot
there are effects but didnt read much into them in scripts
ah wait, I thought you worked with the system in Hazzlelight
ah ok... then I question even more your comparison against GAS XD. Right now you and me both have the exact same idea about engine limitations with it: about zero.
well I've read the scripts of split fiction which they shipped as text files directly, and carrying some of the information that people worked at hazelight directly so I have a bit of an idea
show me how their BT's run those capabilities internally and how they handle blocks and interruptions for montages and what not and then I will agree. With Angel Script files only... I can't trust it.
That said: HL knows their shit and it's obvious, so it's probably very good for their games
sure
this is their BT
its the capability itself
each capability can build a tree
Pretty sure they use gameplay tags and/or wrap it into a capability in of itself.
interruption, blocking etc. happens through capability virtuals or the gameplaytags that you set in defaults of the class
they build the BT's in scripts? and those TRees there are built in the editor with the Bt editor?
it looks like its just script
i dont think you'd need an editor for this
especially considering you can hot reload
I have over 200 BT's combined with state trees in our game doing very complicated stuff like stopping a bttask from a future task in the Sequence if the montage to be run has certain events. There's no way we woiuld handle that in text
dark souls AI is a single monolithic lua file
you'd have 200 capabilities
DS AI is outdated and old AF
its not "outdated"
no dude, I have 200 BT's with very complicated logic in many cases. Those run GA's (capabilities) when needed.
its running a very cool utility system
your BTs are fancy GA wrappers?
ok fair enough, not outdated. It's old and simple by modern standards. I have checked
and you control your BT through selectors, manually setting things in editor?
there is no modern standards. industry didnt proceed when it comes to AI since half life or so
no... my BT's are decision making logic over what to do next. One thing has nothing to do with the next. Which might be an approach valid for HL, but not for us for example
Statetree maybe most innovative thing we've seen since
eeeeh... not true. It hasn't evolved like Graphics for sure, but has changed a lot. That's why the approach of HL is ok for them, but would not work in many other cases
to be proven. So far, nothing we haven't seen.
how come compounds are not same?
in the angelscript screenshot you've seen?
there is a selector<->FSM combo in the industry publicly demonstrated somewhere else?
It might be the same, but when you have very deep logic in AI you really can benefit from:
- a visual tool
- A industry-wide standar like BT"s (despite each company having differences, the logic is the same).
so nothing is different logically?
I can't know, but doesn't look like it no.
But hay, your 1995 madza car is the same as your 2025 electric car.
No need for electric motors or cool intelligent security measures, in the end is the same.
But it's not, that's my point.
HL has a system that works for them but I wouldn't dare to say it's better
yes.
HFSM and other approaches by other companies. Game AI Pro has some similar approaches in their books for example.
And other games made in unreal have done similar things (hence Epic trying to do something for everyone based on said experiences, which is super welcomed)
I just remember Final Fantasy's layered BT<->FSM system, dont recall something similar to STs
it's a HFSM mixed with BT capabilities.
And they are adding more like more asynchronous control, interruptions (like decorators) and so on.
It's getting there, but so far, it's a mix of good ideas that were here and there.
Not taking any credit from it, just so we are clear. But nothing clearly better than what existed objectively
I think with 5.6, we can finally actually do everything that UE's BTs could finally.
well I guess ST is FSM with BT capabilities ๐ค
I think so too.
Without looking at it, I thik it will just miss more openness for debug control (grab data without changing the engine for custom debug tools), improvements in the debug tool and easiness to access and change data externaly
Yup - the external data communication is probably the next big pain point.
And the low level flow. Execution Context Tick is... not easy to digest
Yeah, let the big brains figure that out. But if you're getting paid to be the big brain. All I can say is...lol
I'm a victim of my own success, except I'm failing hard today
Right now, my "external data communication" plan is more to treat it like UMG - in that I just bind to delegates from the actor that the schema supports.
Put that on the root state of the ST and just ๐
Or even a global task to be honest.
Just depends.
"just do a global task and grab the values on tick. Never release on any console below Ps5, done"
PS5 is so 5 years ago anyway
jesus... I'm getting old. NOT HELPING DUROX
lol
Hello, what's the difference between these nodes?
Been reading through this exchange, gotta agree with Bruno
InfernoPlus wants to know your location
oh come on don't tell me that
This might be a silly question, but if I have a large null nav area surrounding my map, can I not "cut through" that nav area using a different nav area that's set to default or something along those lines? The null nav area is pre-placed but the default nav area I'm working on is dynamically placed. So maybe that's just not allowed?
the problem is that the nav area system doesn't support more than one nav area at a time, or at least not out of the box
There's some of those additional nav area properties which might allow you to do it but I've never looked at it in more depth so can't say for sure
Dang really? Like you can't have more than one overlapping? Or you can't have more than one in general? ๐ฅฒ
They can't overlap.
You can test it fairly easily in the editor, if you place two that overlap, one of them will always take priority over the other if you look at how the navmesh ends up getting generated
They can overlap but you need to tell the engine which one should be used. There's a value for nav areas that sets the priority for when they overlap. I have never used so no idea if it works, but with checking
This
It's kinda annoying, I wanted to do something with overlaps on them also
Forget what it was but it didn't work
Man that kinda sucks... I'm generating some paths at runtime and was hoping to set the map up as generally unnavigable, but then have the paths as navigable. Back to square one I guess
Try the value and see if you can tweak it somehow within the path request depending on your game context. I would imagine that's how it works
Yeah there are a whole bunch of extra values which aren't really explained anywhere that can be assigned into the nav areas
Those could allow you to do something like this but as mentioned I haven't looked into it so not sure
Oh wait... I may have just figured it out? There's a recast nav mesh variable called Sort Navigation Areas By by Cost that I think was causing my higher cost area to take priority and basically override the lower cost area
I'm struggling a little bit with StateTrees triggering functions. It feels like I need to make a task for every little thing I want the state tree to execute. It feels like I'll quickly have 100s of little tasks that are just boilerplate around an event binding. Is there a better pattern for this?
Sometimes you can merge them but generally speaking, that's the gist of it. Maybe you can give examples in case there are better ways to do things
You could in theory make a task which can call any ufunction through reflection
Whether this is a good idea... not sure
If you wish to attempt such a feat: https://zomgmoz.tv/unreal/Reflection/How-to-call-a-UFunction-dynamically
I've built a custom UI once for a gameplay scripting plugin I was fiddling with, which would iterate all dynamic delegates of an actor and allow you to dynamically bind functions into them using an approach like that, and it does work just fine :)
@simple verge Maybe this will help https://unreal-garden.com/tutorials/choosing-function-in-editor/
Yeah that's similar to what I did with my plugin proto
Wasn't aware of FMemberReference though ๐ค
Example #2 on the page I linked can be used to build something that allows you to map arbitrary parameters into the function, which is what I was also doing, where you can either let it pass the parameter from the delegate you bound it to, or you could override it manually with something else
Anyone who's worked on a climbing system for AI before, able to help out?:0
Hmm that doesn't seem to give a useful drop down in the state tree gui ๐ค
You can use TFieldIterator to iterate functions and build the UI yourself. Probably a bit more complicated but it should work.
Never worked on climbing, but there's an alternative:
You could play a start climbing anim (latching to the wall), then a montage with root motion warped to the end, then an exit animation.
Ideally you would have different anims for different wall lengths, which implies some level design rules. For example, you could have one for walls up to 3m, walls up to 10m and up to 30m. Then, depending on your wall length, play the right montage and motion warp it.
For a 9m wall, you will play the 10m anim. For a 5m wall, the 3m etc. Always the closest anim to the wall measure
I'm sure the answer is going to be a (justified) "profile it" but can anyone tell me if state trees are mature enough as of now to be used for simple routines for a few dozens very simple NPCs? Basically just asking if their current implementation as of now has some kind of non negligible overhead that can't be avoided, I'm basically planning to implement with something like this
Should be
They are much cheaper thanbst's but they do tick every frame, so keep that in mind until you upgrade to 5.6
You'll hit problems with CMC before ST I'd imagine
Great, thanks guys. Tick reduction can definitely be a thing considering my state changes will only occur rarely.
STs were used for thousands of NPCs in the Matrix/CitySample demo ๐
Oh awesome, thanks for the info!
Im on ue5.3 & Ive been having this weird issue where the nav mesh wont show up ever when I press P until I move the recastnavmesh and it forces it to rebuild the entire thing. If anybody knows how to fix this it would be very much helpful, its not a huge issue but its definitely annoying.
everything else seems to work right, it builds right and the ai can traverse it correctly but I just cant actually see it which is annoying when Im trying to fix pathfinding issues
just curious if you're using world partition and is it gone for the entire map or just part of the map?
never heard of world partition will check out but its gone for the entire map
if I build nav specifically
in the build menu sometimes it shows the nav data but its floating 100s of feet of the ground
ah I know my issues in 5.3/5.4 with navmesh sporadically not generating properly was only when using world partition
Ill check it out thank you, could help with performace too
enabling/disabling world partition on a project can cause some significant workflow changes. I ended up not using in the end for some other reasons.
got it, thanks alot for your help will make sure to check it out and see if its causing any issues or anything
You can't move the recast object ever. That causes the nav to not be correctly constructed. If anything, delete it and build nav again. Question: is your recast object created in the persistent level?
got it will delete and rebuild, not sure what you mean though by if its created in the persistent level?
Are you using sublevels for your game?
nope
Then your object should be in the persistent level I guess. But if you are using world partition, not sure how that works. No idea if you need to have some tile alive always with the recast data or how does it work
Thanks alot, I deleted it and rebuilt + verified the engine so hopefully that fixes some of the weird issues
One thing that I usually do is to disable nav auto-generation in the project settings. That alliviates problems but will requiere manual generation when you changes levels geometry.
Thanks a ton, will do๐
everything works well now thanks alot for the help again
Don't know if anyone needs this too, but just in case.
This video solved my questions about how to deal with Event Payloads (I didn't know how are them supposed to be set)
https://www.youtube.com/watch?v=7JFAsG7Cdd4
In this Unreal Engine 5.5 Tutorial we look at how you can create and send payloads to your State Tree.
These powerful payloads can contain external data which your State Tree Tasks can bind to, to control their behaviour and transitions.
Hello @chilly nebula
I posted this message yesterday about Interaction StateTree and SmartObject and i was wondering if you planned some refactor about it.
What i meant is do you plan to align LinkedAsset with StateTree started from SmartObject to ease debug.
Right now, i'm struggling to find a way to not lose sight on what is happening on my AI when we call "UseSmartObject".
The StateTree debug doesn't say much about what got triggered and same about GameplayDebugger.
So I added some custom debug
Also it's kind of cool to be able to debug different StateTree separately but not sure it's an easy task for you (Main Statetree that call use and GameplayInteraction StateTree that got started by the smartObject interaction for instance)
All I can say at this point is that we are working on some major improvements for ST debugging ๐ The instance/owner oriented debugging (to debug multiple trees) is definitely one of those things.
Sadly I cant say much more until our plans solidify.
Hi! Just as part of research to setup AI players in our RTS, I wanted to ask here if somebody has experience on that specific domain, and how it could be worked upon.
In general I have experience with State Trees, not so much with Behaviour Trees. The problem is that those fit more "sequential" processes and for an RTS AI player, we need to do parallel processing. For example, we might have some actions taken on the "macro" side (purchase units, upgrades, construct buildings, follow build order, etc) while other unrelated actions happen on the unit control department (scout map, harass enemy economy, gather army and launch frontal assault, etc).
Any insights, recommendations or resources are welcome ๐
What scale are you working with? Controlling 10 units, or hundreds/thousands? I worked on a multiplayer RTS game in the past, where each player controlled around 12 units and we used the standard pawn/controller setup.
If you need large scale and parallel processing, look into Mass + State Tree.
Regarding the other half of your question, usually you approach that by different types of AI players. You have a strategic "commander" that does the macro and issues orders, and then each unit has behaviors to follow those orders.
Both can be implemented using either State Tree or BTs.
Our game's scale is around a few hundreds up to 2k units. However, those units are often groupped in battalions, so the amount of controllable entities would range from a few dozens to a few hundreds at max.
All that is already setup and working, since our main game mode for now is multiplayer. We are leveraging Mass, State Trees etc.
Interesting approach, thanks
yeah that is a super nice pointer
also EA recently released source code for their C&C games, but it's relatively old games that have... questionable AI hahaha. Actually the game we're remaking was done in the same engine, and part of our goals is to significantly improve AI compared to those games (players found it very annoying to play against)
Red Alert 3 AI is extremely impressive to me
I dont expect to see its source code during my lifetime though ๐
I'll have a look for sure - I think that the source code released was for older games of the franchise
But maybe just playing it might give good ideas
i think the released one is for RA1
ye
also probably SC2 AI and Company of Heroes might be other interesting references to look at
@shadow python any chance you have worked on a game very similar to company of heroes ๐
SC2 AI was great ๐ one of the few games where the units were able to solve traffic jam deadlocks by moving other units to free up a path.
NDA ๐ฆ
yeah we copied something like that currently. We still need to solve the "stacked canyon" problem though hahah
Hello,when making attacks(abilities for AI) i should make them in the character or in a behaviour tree task?
abilities like teleport,spawn enemies, damaging the target of its too close(and spawning a sphere with a shader for visual feedback)...
damn hehe
its damn difficult, and at some point things just become impossible to solve ๐ I worked on an RTS where the maps were based on real cities, lots of tight spaces ๐ฆ
Yeah, I think it's a matter of polishing and improving over time, I think we've done like 2-3 passes on movement logic and still remanining.
A big improvement for us was adding battalion collision bubbles. Because our game is based on battalions (5-20 units each), but I mostly coded movement logic as if it was SC2 (invidivual units).
Adding paralell logic to battalions as if they were single entities made movement much much better
In the past it has helped me to consider if the action makes sense as an ability the NPC would have, like swing a sword or fire a weapon.. then I would make those as GAS abilities and trigger them from behavior.
There were a few games with truly large scale armies that Im sure you have looked at, including Planetary Annihilation.
There is a point where the scale is so large that the armies are almost running like a fluid simulation ๐ quite fascinating stuff.
i dont have much time left ,like one or 2 days
what would be a okay way to make this in blueprints?
im remaking this logic,so the abilities are inside the character AI and i called them from behaviour tree tasks
Heh ok 2 days is not a lot, but for the future I recommend you look into Gameplay Ability System or any other system to standardize authoring and execution of abilities ๐ just doing it all in BP doesnt scale very well.
Yeah I looked at PA, specially because it's a large scale RTS that doesn't use lockstep, in the times where we were figuring out a network model. Fortunately nowdays you can get away with client-server at our scale, being smart about it.
If you are doing multiplayer, did you start looking into Iris?
not yet, we're mostly doing careful custom replication and leveraging fast array serializers if necessary
So do i just leave it like it is?
i thought there is a little better way
better than what i have but worse than GAS
Since you have limited time, I advise just being pragmatic with what time you have. If you have pain points with the current setup, then address those.
Dont refactor "just because", but a concern I would have is maintainability and re-use of blocks between bosses etc. However if the project wont live for a long time then that isnt a major concern.
@celest python AI code for CnC indeed https://github.com/electronicarts/CnC_Generals_Zero_Hour/tree/main/Generals/Code/GameEngine/Source/GameLogic/AI
yeah,i get it
thanks
@chilly nebula i want to add a sphere mesh with no collision dinamically and its material will be panning transparent
i can figure out how i will make the material,but how do i add a sphere so its radius will be the same as the radius input
nice! game of my childhood ๐
i played this at 8 years old once and then never became the same person again
Probably a question for other channels ๐ but generally you would use a unit sphere and scale it.
hahahahahahahhahah indeeed, I had the same with Battle for the Middle Earth
I had a copy of the 2013 Generals game that EA cancelled
would have to reverse engineer my way to bypass the online login requirement which servers werent even available at the year I accessed the files but I wasnt this experienced yet so files got purged during an emergency case where I had to wipe my SSD
(got a malware in my windows)
wow
Before I dig any further into this possible bug, just wondering if others have experienced this:
Weird state tree behavior occurring if at any point you are using 'Move To Location or Actor' in a task rather than 'AI MoveTo'.
For example, it appears as though something in my tree breaks after Move To Location or Actor is called, as the state that houses the Move To Location or Actor task can no longer be transitioned into, and the Debugger will state "Could not trigger completion transition, jump back to root state."
Currently in Unreal Engine 5.5.4 and using Windows 11
does the task properly call finish task in all cases after the movement happens?
It just has a general on movement completion call finish task
umm can you post an image with the BP/code? you can paint over to cover stuff you shouldn't show to the world
Yes I can, first here is this:
I have verified the vector coming from the Context Core struct is valid each time it is called.
my guess is taht the movement is failing and the task is never ending
you don't call finish task on movement Fail
add a finish task there
I added a debug to print out the results no matter what, and hooked On Success and On Fail to Finish Task. I am not seeing a failure, nor am I seeing different results, it still is hitting "Could not trigger completion transition, jump back to root state."
does the task even run once?
Yes, breakpoints confirm this too (Just in case for SOME reason, something else were to make it move (nothing else is hooked up to even do that, but I wanted to be sure))
umm so the Task runs and you get a breakpoint in a Finish Task node in that image no?
Then the Tree tries to trigger a transition to the parent and fails.
Maybe you have a condition or somehting on the parent that prevents it from transitioning? have you tried to transition to some other state (like root)?
Yes
I used to have it set up this way:
Collect The Distance Between Myself And Target -> Do I Want To Move To A New Attack Position
But I realized, that Setup The Engagement is configured to automatically go to the next state, so letting Collect The Distance Between Myself And Target wrap up the task and moved back up to the parent (Setup The Engagement) should let it transition to Next State, being, Do I Want To Move To A New Attack Position?
Same effect each time
When it gets into this stuck state, this is what it does on repeat
I'm a bit confused maybe, but... isn't that doing exactly what you want?
Parent - > go to next
Run State A (spotted) -> go to next
Run Collect -> go to parent
it should repeat like in the image
Parent doesn't mean let the Parent handle transition?
if so, I am even more confused because sometimes Setup The Engagement does transition to Do I Want To Move To A New Attack Position
I think it just means "transition to the parent". It does that (you can see it in your video) and the parent transitions to the next thing (Next State in your case)
but I'm not sure to be honest
Well... Switching it off of parent and having it go directly to Do I Want To Move is working without issue, which is super frustrating because I know for a fact from other recordings, I already had that set and enabled originally.
Thank you for walking through it with me
Wait... which engine version are you at? I don't have Parent within my options...
that's all I get
@near condor quick question, did you verify the state you want to transition to can be entered? No enter condition or anything else preventing the transition from executing correctly?
Correct, I actually haven't even included a single enter condition in this tree yet.
5.5.4
Parent appears if you don't have any transitions
ah right. ok ok
@chilly nebula I've been playing with 5.6 more and more. These few changes made (roadmap wise) for State Tree make it so much better to work with already. Just wanted to give it some time to sink in with me building stuff before I made the claim ๐
I am excited to use it. Need to wait till it is looked at enough and plugins are updated.
What is your favorite things about the update?
for State Trees
Being able to tell the state to wait until ALL tasks are completed before transitioning
Ok so we have sequences with ForceSuccess in all their children, State Tree version. Thar's going to help a lot
that is so exciting actually
Interestingly though - I haven't tested what would happen if one task succeeds and another task fails. Which transition takes priority? Wonder if it is transition order based ๐ค
in other configuration languages, they map out the hierarchy of what order it takes. (looking at yaml). Do we have a map like that at all? Or does it change with it release that maintaining it would be tough for now?
~~I just discovered this:
- If you have a "Required Event To Enter" condition in your state, you can bind your task/s params to the Event Payload params.
- But if you have a Event Transition with a Payload, you can't bind to said Params in the Transition Conditions.
I thought the Event processing would happen first, then the Conditions would be check, so you can use the event payload.
But you can't ๐ฆ
What I'm trying to do (fake example): "from Idle transition to Damaged if you get the AI.Event.Damaged State tree event with Payload passing the damage float. But only transition if the Damage float of the payload is > 10.f"
I have a workaround but I was totally convinced this would work~~
This actually works.
It was a local issue.
The variable has to be set as
UPROPERTY(EditAnywhere, Category = Parameter, meta=(AllowAnyBinding))
I was using Category = Input, that is wrong and doesn't work
I haven't ever used the payload transitions. But have used the one in enter conditions, so I knew about the first bullet point. Didn't know about the second.
I can check and see if it works as you expect in 5.6 later tonight
Because that sounds like it should work like you expect.
there aren't any binding buttons in the Transition condition
Maybe Siggi can look into this when he has time.
But works for a Task
The "only" difference I see is that the Task is a UCLASS and the Condition in the transition is a FSTRUCT.
Not sure if that makes a big difference for this
this is kinda meh because I would love to skip the transition if my condition fails based on the data pased.
The alternative is to allow it and check the condition in the state following the transition, which is not ideal.
Instead of CurrentState -> Event Received (root) -> evaluate if the transition can happen -> ignore it because the condition didn't happen (which will make the State tree stay in the Current State)
What will happen is: CurrentState -> Event Received (root) -> transition to NewState -> Exit due to the condition not passing -> Back To root -> re-evaluate from Root
no Siggi?
Or will it be the exact same as the firs case because the enter condition of NewState will prevent it from entering and hence failing the transition?
Is it possible for you to test this with 5.6 preview? We did a lot of fixes related to this, but its tough for me to say exactly whats going wrong in your case.
A failing task I believe will always trigger a transition, there is no "wait for ALL to fail" ๐คฃ
But only transition if the Damage float of the payload is > 10.f"
I think that should work and prevent the state from being entered? But it will probably kick back to the root selector instead of staying in the previous state yeah.
This is interesting, I'll bring this to the team to ask for options here. I agree it feels like you should be able to have a condition on the transition reacting to data in the event.
I downloaded 5.6, but I would need to change a few things as I use a couple of plugins. I imagine the state trees are also able to be migrated over, but the abilities that the states trigger use GAS. I also have a ton of materials coupled with engine modifications (I did not make those changes)
So I can see what I can do
how can I access variables from one blueprint in blackboard?
You get the AI Controller, from there the blackboard component, from there there are functions to get/set blackboard values
Has anyone tried to generate some State Trees automatically using the unreal python API? It feels like it's not possible currently considering the exposed variables and classes (unless I'm missing something, I've been unsuccessful so far)
Check the test examples in code. There's some st's generation in c++
Ah great, thanks! I only checked the factory code and not these ones, let's see
Ok yeah looks very promising, that should get me going
if Restart Timer on Each Activation is Enabled, sometimes, Service can stop running
if i ALT+TAB viewport, and then switch back, Service enable itself again
it's Engine bug, or something is wrong at my side?
it may be related to setting " use less cpu when in background"
Hello hello! I am trying to write a custom EQS test and would love to use the EQShelpers: there are nice functions to do stuff like Traces for Nav/Profile/Channel. But, as far as i can see, the EnvQueryTraceHelpers.h is private inside AIModule... so am I supposed to not use it to write a test inside my game module?
first time I notice those helpers. It sucks it's a private header indeed
Hello !
Anyone knows how to use AbortContext of the GameplayInteraction StateTrees
the enum property is just a UPROPERTY() that is not exposed
Note: Exposed the reason as "VisibleAnywhere" fixed this but i'm not sure if that's supposed to be used any way
so, i need a setting "use less cpu everytime" to prevent service stopping, or something like this?
That setting reduces the cpu usage of unreal when it's in the background. The suggestion is that the setting might be affecting the service execution while you have unreal in the background
so, if less cpu usage is restarting freezed service, suggestion is - high cpu usage is freezing service?
no.
Context: you are having a Service that is not working properly when you alt-tab to something that is not unreal
Hypotesis: there's a setting in the engine that makes unreal use less cpu when it's in the background. That might be affecting your service if you have unreal in the background while looking at something else (ie youtube or whatever)
Suggestion: turn off that setting so Unreal runs the same (as much cpu as needed) whether it's in the background or not
Maybe that will yield different results. And if not, it's always a good thing to disable.
alt+tab is FIXING service, which is freezed for no reason after activation, with a "restart timer on each activation" enabled
ah I see. Maybe you can post an image of your tree (feel free to censor names or whatever, it's just the structure what is important).
Maybe you have something wrongly setup.
When you say it stops running, can you see if the children under the composite where the Services is are running?
Do you get any breakpoints in the service activation and/or tick at all when the bug happens?
can you post what does the service do?
nah, its tons of screenshot
looks like this bug dont exist, if i set check number 2 as True
but i dont understand, why there is a first check in this string?
if i set check number 1 here as False, string is immediately disappearing, and i dont see this option after
the only way to restore it is ctrl+Z
I can't say without analyzing what your service does. Also I'm not sure about what #2 entails
thank you anyway, i think i'm fine for now, bcz bug is fixed
Siggi I was using things wrong.
It's all my fault, things are fine.
I was using the wrong meta-tags. I was using Input instead of Parameter.
Setting this in the InstanceData struct for the variable to bind to the Event payload works
UPROPERTY(EditAnywhere, Category = Parameter, meta=(AllowAnyBinding))
@misty wharf @harsh storm tagging you both to not butn Siggi's handle.
Do you guys know if there's a list anywhere of which categories are important for State Trees?
I know of
- Default
- Input
- Output
- Parameter.
I recall there was somewhere where these are explained.
I'm just trying to see what did change for 5.5 in that sense, see if we have things set properly etc
I don't know of any official list of them anywhere - as far as I know, only Input, Output and Parameter do anything. Inputs must be bound to something, outputs can only be bound from other things, and parameters can either be bound or specified manually in the editor
it's very confusing that Input will not allow me to bind to the payload of an Enter Event in a Condition, but Param does
Oh really, I wonder if that's an oversight ๐ค
yep, noted ๐ and the 3 binding categories are Input, Output, Parameter. We are aware its not intuitive these are strings, and want to reconsider that in the future.
Well - in a way there is a 4th, the property ref ๐
maybe? Took several iterations until I discovered what was wrong.
To bind within a Condition to a Payload you have to:
- set the UPROPERTY as Param
- The uproperty has to be within an InstanceData struct in the condition. It can't be a Condition member
awsome
Yeah the categories make sense once you know they're there and that's what they do, but they do lack somewhat in being able to discover that the feature exists
Properties on tasks or conditions can be thought of as "static data" and its saved in the ST asset. Anything you need runtime instanced has to be in the instance data
I often used properties on tasks as settings/defaults set only at authoring time
Yeah I always thought of the direct props more as configuration settings for the task itself
but can Tasks use instanced data the way Conditions do?
There's no GetInstanceDataType in a Task you can override no?
What am I missing?
yeah that's 100% of our cases up until now for the "bind the UPROPERTY to the Event Payload.
I will look into the link you passed
GetInstanceDataType()
If you are binding anything you need instanced data. Anything that can change at runtime needs to be instanced
aaaah I see the problem.
GetInstanceDataType() comes from FStateTreeNodeBase
Our tasks inherit from UStateTreeTaskBlueprintBase
Hierarchy
UObject <- UStateTreeNodeBlueprintBase <- UStateTreeTaskBlueprintBase <- our tasks
None of those have the GetInstanceDataType()
But FStateTreeBlueprintTaskWrapper does.
FStateTreeNodeBase <- FStateTreeTaskBase <- FStateTreeBlueprintTaskWrapper
Since FStateTreeBlueprintTaskWrapper is a friend of UStateTreeTaskBlueprintBase, I'm guessing there's some setting we are missing here.
What should be our Tasks base class? Or how should we use the Wrapper to get access to the core functionality?
Are you making a base class for custom BP tasks or just C++ tasks?
everything is in C++. I though we would do stuff in BP's, but it hasn't been the case yet
Right - in that case isn't there something like FStateTreeTaskCommonBase which is what all the other C++ based tasks inherit from also
I would stay away from anything that says 'Blueprint" for C++ only things :D
Yeah maybe. I'm just realizing my mistake here. I did this back when State Trees rolled out as experimental, so a bunch of shit is not ok today.
I would stay away from anything that says 'Blueprint" for C++ only things :D
Yeah that's the thing, I have no idea if Designer would like to extend some task in the future doing things in BP's.
What I don't understand is why "it's known" that I need Instanced Data in tasks for changing things but then you can't have that in BP's.
Does that mean that there are indeed 2 different tasks in the system: ones that can handle runtime data and are c++ only; and ones that can be BP but can't handle runtime data?
I'm being bamboozled right now
I'm not sure if it's even possible to extend a C++ based task from BP safely given how everything works ๐ค
Never tried it, but at least it seems it might not work
The Blueprint side handles the runtime data just fine - I think they've just built a bunch of abstractions around it that enables that to work without doing it the way you do it in C++
I didn't look at the implementation for the BP base task but that's my assumption anyway :)
Dont use the BP base if you implement the task in C++. What base depends on what scema you want to use ๐ just actors, AI controller, Mass entity? Im assuming the actor one, so you can use StateTreeTaskBase
ST tasks are either C++ or BP really. In the BP task case, I think the instance data is handled for you based on the BP variables.
Things are a bit weird since ST isnt using the common BP VM types
All our Tasks/Conditions are to be used for AI using the AI Schema.
Ok thanks a lot for the explanation. This answers some doubts I was having.
I'm in the process of "let's see what should we change towards 5.5/5.6 in our implementation since it's old" and well... stuff is not great here and there
aaah I see.
So... I need to change all my Tasks from UCLASS to USTRUCT and inherit from that.
Ok ok, time to re-build stuff.
Thanks a lot for the info
np! good luck with the fixes ๐
thanks. This is going to hurt: 14 tasks that will be transformed from UCLASS to USTRUCT.
uff man, this is killing me. I had some cool stuff made within PostEditChangeProperty in some tasks and that will be gone since struct do not have that.
I wonder if you could do something with details customization to similar effect
I will look into it. I know we have done some stuff with it, but no idea if that was for STructs or not
Task heriting from FStateTreeTaskBase has the function "PostEditNodeChangeChainProperty"
Oh nice. So there's a function for it?? Awesome. I will look it o it once I have a stable version of after porting all this
Thanks a lot for the tip mate. Will do a research of functionality available alongside
You're welcome!
oh no.... I have some delegates that use UFUNCTION members as callback (mandatory). And in a struct... you can't have that. oh boy....
you can do external callbacks in tasks, but in 5.5 there might be some issues which can cause the task to be GCed and then get the callback later.
How do you bind dynamic delegates into them? ๐ค
I always thought the only way to make that work was to make the InstanceData UObject-based and then bind to that instead
get the actor through context, and grab whatever component you need that has the delegate
I think our current EQS task shows an example
(recently updated)
Interesting, will have to check it at some point. I vaguely recall it used a UObject based InstanceData which you can bind dynamic delegates into (since dynamics can't be bound to non uobjects as far as know)
we are going to rework some of this soon and need to provide a good example for doing async tasks
This is what I'm planning to do. For example: I have a task that lazy-loads assets (AssetManager) and you can't bind to its OnAssetLoaded unless you use a UFUNCTION. My idea is to have said UFUNCTION in the UObj-based instanced data of the task
I know you were answered, but whenever I forget - I just go to this guide that Epic did for ST and look https://dev.epicgames.com/community/learning/tutorials/lwnR/unreal-engine-your-first-60-minutes-with-statetree. They're in the StateTree Key Terminology section.
yeah the problem is that it doesn't have the Parameter category. That name was introduced after the article was written unfortunately. It's getting obsolete slowly
Could've sworn it did.
There is also "Context" to automatically bind to the context (or attempt to)
(Going back to the answers you were originally given)
I just woke up - so I'm catching up.
Oh yeah there is that also
You can bind delegate to your InstanceData as an UObject and have a tick in your task.
That's the best i could figure out
Yeah... In the end it's the exact same approach as with memory in bt's, but with the advantage of being able to use a UObject for it.
Not sure what do you mean with the tick part
Ah crap i don't use it anymore, but i remember having used a tick to know when the delegate was raised in my task
tick is definitely not needed anymore, at least not in 5.6
But is it needed now?
If a delegate in X component within the owner triggers it's callback to a function within the instance data, I don't need a tick no? The instance of the data that holds the function will do what it needs to do (in my case clear some values in the AI Controller).
I guess you mean you need the tick to detect the trigger and return the right finish call for the task in tasks that need to wait for something (latent actions) to finish no?
I wouldn't imagine you'd need tick regardless for this. Enter State -> setup delegate -> on callback, trigger transition.
Is there a way to trigger a transition form task that is not calling Finish Task?
Probably sending the state tree an event, lol
In 5.6, there is a way to do it if I recall.
The new delegate stuff that Siggi has spoken about.
Pretty sure it is a transition thing to do now.
Yeah. So in 5.6, you'd just set the trigger to be the delegate.
And then you'd trigger that in your callback
These would be the types for the new delegate stuff.
So you'd have a dispatcher and then broadcast it
Quick BP mockup of how it'd work.
I'm at my day job, so don't have the time to show the C++ syntax.
Aww - it didn't capture the dropdown for the delegate. But trust - it is there (the red binding icon in the transition)
Thanks a lot dude. This is super nice to have Siggi
How can you make a UE vehicle follow a path ? Like GTAV
Same way you make a person. Spline is the easiest and most straight forward.
It should be able to avoid obstacles
I would start with this type of talks and articles where they mix things like ORCA/RVO (unreal also has detour crowd control) with the concept of velocity and anticipation
https://www.gdcvault.com/play/1021986/Forced-Based-Anticipatory-Collision-Avoidance
@chilly nebula why are EnterState/Tick/ExitState const in StateTaskBase const?
It makes impossible to do logic like "upon entering the state, based on some gameplay conditions, decide if the task needs to tick or not".
I can't change bShouldCallTick in a task to decide.
If in 5.6 tick control over tasks is improved, does that mean it's possible to start/stop ticking on runtime for a task?
Tick control is 100% changed in 5.6, even automatic scheduling and tick optimizations. The code can figure out in many times when it needs to tick, and not tick in between. You can also take manual control and schedule a time for when next to tick, or set a constant Hz
I would be surprised if you cannot do everything you want with those controls ๐
amazing. That sounds neat indeed
I'm going through a painful refactor that will happen again when we move to 5.6 XD
5.6 is such a big step for ST, I honestly wish I could just magically upgrade everyone automatically ๐
Cant wait for 5.6 to be released!
I need a second brain to check if I got this right:
- If a State Tree Task needs (condition) an event to happen with a payload, the only way to access the payload is by having a UPROPERTY in the Task that binds to the payload
- If your payload has some variables you want to tweak during the execution, you can't change them in your UPROPERTY. Anything to be changed in runtime within a Task should be done through its instanced data, which is the only thing granted to be there and not garbage collected.
I know it's weird to change data in a passed payload because, technically, that should be a const object ("here, a chunck of data") and anything else needed is just Task's logic but... the payload could be a pointer to some object that is used somewhere else too and needs new data added/refreshed. The case is valid.
So... in order to do that you need:
- A UPROPERTY to bind to the Event Payload
- A payload object in your instance data
- OnEnter task, copy the data from your binded UPROPERTY into the Instanced Data object, so it's granted it will be kept.
Is that so or am I missing something here? I'm assuming the payload is not kept further than the OnEnter event
how to fix this?
Blueprint Runtime Error: "Accessed None trying to read property Trainer". Node: Run Training Graph: EventGraph Function: Execute Ubergraph BP Learning Agents Manager R Blueprint: BP_LearningAgentsManagerR
add an IsValid node before reading your variable Trainer
if it's not valid...debug why
Check output log in UE I guess, I've never used that node but I would guess the parameters to it are invalid and it can't make the object
If it isn't logging anything useful, I'd then check that all the input values you're passing into it are valid
And if you still don't see any issue, then you probably have to look at the C++ code to debug it further
@chilly nebula I'm sorry to bother you again.
Binding to the EVent payload works if your task is BP based and the property is set as Parameter.
But if the task is set as a struct (I'm re-converting all so I can use the Instanced Data), it doesn't.
Doesn't matter what do I use (Input/Parameter/Context), no binding widgets show up
On state trigger, you should be able to bind the payload to a task that sets a tree parameter by using property reference.
In generally parameter bindings works this way:
- input parameter = value is copied to the task, changing it in the task doesnt change anything
- Output = created in the task
- ByRef is only pattern where a task can mutate value of an existing parameter
Im not sure on the difference there honestly, might be an oversight or a bug.
On state trigger, you should be able to bind the payload to a task that sets a tree parameter by using property reference.
I'm a bit confused by this because I'm not sure how the task should look like
- To do the "bind payload to a task", I still need a memeber in the task to bind it no?
like this
USTRUCT(BlueprintType)
struct FStateTreeTask_Foo : public FStateTreeAIActionTaskBase
{
GENERATED_BODY()
[some task functions]
// same type as the Event
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Parameter, meta=(AllowAnyBinding))
FStateTreeReactionData FooEventPayload;
};
Or do you mean that in code I grab the Param from the tree and modify it with no UI element showing such binding?
no, always go through the property binding. I see now from your other post that something is preventing you from binding to the event there
An output parameter should be bindable to Input or Parameter really, but if you expect to change it you need to use a property ref
yeah it's weird because with a BP_based task I can make it work with that same code you see above. But for a struct, it doesn't work.
Any suggestions?
sadly at this point no, I would need time to investigate on my end or try this in 5.6
fair enough.
Let me know if you end up having the same issue.
As alway, vey much appreciated
If you have time, try to see if it repros in 5.6 as well
some major refactoring to property binding done there
Will see once we transition to 5.6. Takes some time for us to upgrade due to internal validation processes
yeah I more meant an isolated case, thats what I want to do ๐ ie create a payload for state trigger, and try to bind to a task in same state
ah yeah ok ok. Will find time to donwload and try next week
I feel like in UE 5.5.4, I broke something in my state tree unintentionally...
I went to disable all debug text tasks by toggling the "enabled" flag on them (the variable, not the disable task option in the tree).
And now it just drills into each state it ends up in without waiting for completion status of a task, claims it could not trigger completion transition, jump back to root state.
Re-enabling the debug text tasks does not fix it, and it was the only thing I changed.
is this bad? this line is green in an output log
Cmd: OBJ SAVEPACKAGE PACKAGE="/Game/LearningAgents/Red/DA_NeuralNetworkPolicyR" FILE="../../../../../Unreal Projects/MyProject4_1/Content/LearningAgents/Red/DA_NeuralNetworkPolicyR.uasset" SILENT=true
like this
I don't know why it's green but doesn't that just occur every time you press save on an asset?
I've noticed it as well and it seems like it doesn't really mean anything other than something was saved
sometimes appears during training of learning agents after pressing the play button
idk what does it mean, hope it isn't bad
What are those files for?
It could be that it's saving information into them as part of the training if they're related to it
I changed the state tree name to "*_BACKUP", and downloaded a working copy from my gitlab server, popped it in, and it works perfectly fine now, no difference between the two... so I am super confused now haha
those are data assets for trainer, policy and critics, so yeah, likely, you are right
hello im am trying to make a game where i need my enemies to scale shelves and chase player how would i go about doing that?
use behavior tree๐ง
how can I make places of interest for agents using learning agents plugin? I mean places like covers, walls, maybe some pick-ups to boost actor's reward during training and make variety
No I mean like line trace to detect if it hits the shelves
Easiest way is to use nav links to path, then implement something to climb (root motion anim, or flying mode while path following)
so GameplayBehavior is meant to work with SmartObject โ BUT on Trigger it doesnโt receive any information about which particular slot itโs interacting with? How can it know the location of where to e.g. sit on a multi-slot bench?
oops wrong channel probably, sorry! [meh, didn't find a better one]
You would probably have to create a custom use smart object task which can configure this information into it
Or you can store the info on the actor using the smart object and query it from there
Neither approach is entirely straightforward since the builtins don't really give you this info very readily so you need custom C++ bits for it
Tbh it seems like a weird omission that the data doesn't go into them - I don't know how it's intended to be used in this regard. There's no direct mechanism on them for it, so you would have to do something like extend the behavior class to add a method into it, which you then call before activating it
Maybe it's intended you'd query it from the smart object owner with the avatar? No idea
is these all it takes to indicate the wall location so learning agents' bots can use it as cover? I assume I need to change something in bp trainer and add reward for reaching the wall, but I don't know how
I tried to go down this route but actually found no way of querying the slot which a specific actor has claimed โ was surprised!
And yeah itโs totally reasonable to roll oneโs own GameBehavior-like (or deriving) interface that includes slot data in the flow, but as you point out, youโre no longer participating in the โoff the shelfโ ecosystem which includes the corresponding AITask
Epic also has Mass and StateTree based SmartObject behavior definitions/triggering flows, both of which include slot data, so that deepens the mystery about the GameBehavior version
I have toggled this option on, why it doesn't create folder with data of training for tensorboard?
Frankly a lot of the gameplay behavior stuff feels like they wanted to have some kind of BP compatible way of defining behaviors and didn't really think of it much further than that. Gameplay Interactions system via State Trees seems like it might be more thought out but I've not really used it
I think all these questions will have a better chance in the machine learning channel
There's one I think. I remember someone mentioning it here
I think you need to look for plugins like this one
https://www.fab.com/listings/0e49d138-10e1-452e-ba07-9a4bea578ace
AIChatPlus V1.6.2 + UE5.5 is LIVE Assistants / Real-time / GPU AI / Blueprint / Editor tools / and more! Documentation: LinkUE.AIChatPlus is an Unreal Engine plugin that enables communication with various GPT AI chat services. Ccurrently supported services include OpenAI (ChatGPT, DALL-E), Azure OpenAI (ChatGPT, DALL-E), Claude, Google Gemini, ...
Hello!
Using state trees, is there a way to get which state we are currently in?
Let's say I have NPCs that run a state tree, and one of the states is "idle". I want to loop through all the NPCs (in the game mode for example) and count how many are currently idle. What's the best way to do something like this?
Iirc there was something about this discussed not too long ago but I don't remember exactly what that was. If you can't find it/it doesn't work the way you want, one easy method would be to assign a gameplay tag based on which state you're in, but that would require adding a task to do that into the tree
Thanks, I'll search some more.
Look for "State Path"
I have 36 AI controllers sharing the same Behavior Tree and Instance Synced blackboard key. I dislike telling all 36 AI controllers to set the value of this bb key. What logic do you prefer to use to set instance synced blackboard keys? Right now all 36 ai controllers receieve delegate broadcast to update this value, but I dislike the 35 unneccesary calls.
I could loop through all relevant AI controllers, run set function once, then break loop. But it feels barbaric, and I was curious of a better way.
There's a setting to make bbk's static (shared value among all bt instances)
It's a setting in the bbk IIRC
Exactly, I have that set. I was curious about how to set the shared value only once without looping all ai sharing it.
If the AIs have no way of telling whether they should set it or not, I don't know if there's any way to avoid it
Keeping in mind that setting it should be a pretty cheap operation so I don't know if it's worth worrying about it that much
But I don't get it. When you enable the option I said, any AI setting its value will mean every other AI using the same bbk will have said value too. It's a static value (like in c++)
So what's the issue? Technically you set that value once and all your AI's will already have said value (no need to do 32 calls)
Thank you for the pointer. I can't find much about it, but is it UE 5.6 only?
Oh, I see it probably is. zomg's tab-based approach is a good alternative for now I think.
I have a state tree where I want the AI to be able to abort any current ticking state and process commands from the player. Is it a bad idea to have a few OnEvent triggers on the root node of that state tree? It works quite well so far.
FString DebugGetStatePath()
Hello, I have a 4 legged animal ai and it runs into stuff constantly. Like if I make it follow me and while it's between some trees I suddenly change direction it just clips through the tree so it can turn to face me, or sometimes while it's walking it gets stuck between 2 trees because i have set my navmesh to a high agent radius so it avoids trees, but the collision ends up getting stuck between no navmesh areas. I understand most of these issues ar cause by the fact that characters have capsule collisions, how do people usually deal with that? I mean with a capsule collision if an animal turns around and an object is beside it most of the times it will go right through
Ah! You fooled me! Hahaha
Anybody here tried to use AI assist with your game programming? I know how to program, but I would like to see if AI can make me move faster with it. Is there a guide or anything to read/watch?
Hello everyone! With the new updates in UE 5.6 around State Trees, Iโm wondering if itโs worth switching my AI system from a traditional Behavior Tree setup over to State Trees.
Right now, our AI is about 40% complete, so itโs still early enough to make the switch if itโs the better long-term option. Weโre working on a third-person shooter, and Iโm trying to evaluate the pros and cons of sticking with the classic Behavior Tree vs. transitioning to State Trees.
Has anyone made the switch or have experience with both systems? Curious to hear thoughts on:
-Long-term maintainability
-Performance
-Workflow differences
-Any gotchas
Thanks in advance!
- Long-term maintainability - As in like...the AI itself or the tools? Because ST is going to be the future for AI in UE
- ST should perform better than BT
- Pretty big workflow differences. ST have more concepts to them despite them being state machines.
- No Blackboard and communicating stuff to the State Tree can be annoying
- I would say as a standard for AI conception in unreal engine
In a similar situation as ours would you think State Tree is worth the switch ? (Thank you for you answer btw!)
In 5.6, ST can completely replace Behavior Trees. The only thing that it can't do that BTs can, are observer aborts. You would have to do something manual for that.
I would say, now, ST would be a better choice (on average) than BTs
You got me to finally say it @chilly nebula
BTs are definitely much more battle tested though. And there is a wealth of information for BTs.
So there is that as well.
Yeah the extended documentation on BT is what keeps hesitating, i'll give a try to statetree this week and see how it goes. Much appreciated for taking time to answer @harsh storm
Oh, shoot, lol.
@misty wharf @harsh storm I have a two questions for you both, because I think I'm going insane with this:
- do you guys make your ST Tasks in c++ derived from FStateTreeTaskBase/FStateTreeAITaskBase/FStateTreeAIActionTaskBase? I'm using the latest.
- If you do that, are you able to bind anything in the tasks in the UI? doesn't matter which category I use, I don't get any binding UI at all in my variables.
I've used FStateTreeTaskCommonBase. Never had any issues with binding ๐ค
Not sure what would cause issues like that - just to confirm you do have your values you're trying to bind in an instance data and not on the task itself? That's really the only thing I can think of, assuming those classes you're using are valid base classes for tasks
Just to confirm, what schema are you using in your ST assets? The AI Controller one?
ok... so... I know what's going on. Well... "know" might be a strong word
- First of all I forgot to add the line
using FInstanceDataType = [my type]. I had theGetInstanceDataTypeimplemented but not that line - The parent class type doesn't matter:
FStateTreeTaskBase/FStateTreeAITaskBase/FStateTreeAIActionTaskBase/FStateTreeTaskCommonBaseare pretty much all the same, they just hide different categories. - UPROPERTY's intended to be bound: if you are using the BP base class (as I wrongfully was before) can be class members of the task (there isn't any other way really, since you can't implement Instanced Data for BP based tasks in code). For C++ base classes (like the ones mentioned above), you can only bind them if they are in the instanced data class/struct. They will not work as Task calss memebers.
The INPUT category doesn't work for c++ based Tasks for it's to-be-bound UPROPERTY's within the Instanced Data<- this is a bug deffinitely. I guess this is fixed in 5.6, but in 5.5.4 doesn't work, you don't get anything to bind in the UI, only the option to "Promote as a Param". If you want them to be bound, you need to set the category asParameter. Then you get the UI to bind your stuff.
Thanks a lot of the sanity check @misty wharf , I thought I was going nuts until I tried the Input vs Param thing I had discovered for BP's the other day.
Now, for the shake of the argument, in case this is the issue, this is the data I'm trying to bind
struct FCustomStateTreeReactionData
{
GENERATED_BODY()
/** To check if this data is valid*/
FORCEINLINE bool IsValid() const
{
return !DefaultBehaviorTree.IsNull();
}
/** Default tree to run as the reaction*/
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSoftObjectPtr<UBehaviorTree> DefaultBehaviorTree;
/** Tag to the BT to run as the reaction*/
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FGameplayTag TagToBT;
/** Tree obtained from a Param to run as the reaction*/
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSoftObjectPtr<UBehaviorTree> TreeFromParam;
/** Whether the bt should run in loop or single mode*/
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bRunLooped = false;
/** The priority of the reaction*/
UPROPERTY(EditAnywhere, BlueprintReadWrite)
ECustomReactionStateTreePriority ReactionPriority = ECustomReactionStateTreePriority::LowPrio;
/** G.Tag identifying the reaction*/
UPROPERTY(Transient, EditAnywhere, BlueprintReadWrite)
FGameplayTag ReactionTagID;
/** The State Tree that will push this reaction data*/
UPROPERTY(Transient, EditAnywhere, BlueprintReadWrite)
const UStateTree* StateTree = nullptr;
/** Tags added to the owner character temporarily while the reaction runs*/
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FGameplayTagContainer ReactionTags;
};```
and this is how my instanced data looks like
class UCustomStateTreeAITask_RunReaction_InstancedData : public UCustomStateTreeAITask_PushBT_InstancedData
{
GENERATED_BODY()
public:
virtual void OnPushedTreeFinished(const class UBehaviorTree* finishedTree) override;
public:
UPROPERTY(EditAnywhere, Category=Parameter, meta=(AllowAnyBinding))
FCustom
StateTreeReactionData RunReactionEventPayload_AsInstancedData;
UPROPERTY()
TSoftObjectPtr<class UCustom
AIStateTreeComponent> OwnerStateTreeComponent;
};```
yeah
and I'm using FStateTreeAIActionTaskBase as a base class for my task
Ah yeah if you had the props on the task that would probably have been the primary reason it wasn't letting you bind them
Wasn't aware of the issue in 5.5 with the Input category ๐ค Think I'm using it in some but forget, at least nothing broke when I migrated from 5.4
thats weird, I havent had any issues with property binding in any recent version really. Let me see if I can make a minimum repro
nah I didn't, but I tested everythign to see what worked and what not
installing vanilla 5.5 now to check and compare with 5.6
Im hoping this is just some minor thing you do differently ๐
yeah, I hope it's a local issue and something is off. To add to the issue: Input category works as expected in Conditions and their instanced data
I can use input parameters just fine in 5.5... I'll take a quick look at your code above to compare with mine.
What is the source of the parameter you are trying to bind to btw?
@slow bobcat I already see two differences, I'll test them locally. You marked your instanced data struct as BlueprintType and your task is a class (I used a struct)
Why is your instanced data a class instead of a struct?
because I saw it's possible. And since UObject offers things like PostEditChangeProperty and some other helpful stuff, I decided to go for it
Try changing it to a struct please and see if that fixes things for you ๐ Im not sure how well supported this is
Will try. But then I will loose any possibility for easy customization of the UI or having UFUNCTIONS for async operations that needs them (like timers or a loading assets asynchronously with soft object pointer through the Asset Manager). That's something worth considering
ah yeah I can't do this, unloess someone knows a way for my issue:
I can't use STRUCT as Instanced Data because, among other things, my instanced data has a function callback for a timer. OnEnter the timer starts and, while the state is active, we do some stuff. A timer needs a UFUNCTION as a callback. Structc can't have UFUNCTIONS. THis will also happen with Async asset loading I believe (On Asset Loaded needs to be a UFUNCTION) if you want to control the asset loading and instance pointer within your instanced data.
I guess I could convert the timer logic into "check within the state tree task Tick" with a delta counter.
For the asset loading that's not an option because I can't have the callback function in the Task (as a task memeber). Upon calling that function (asset loaded), I need to put the loaded asset pointer within the Instanced Data, which I can't get, because the callback doesn't retrieve the context object of the Task
Hi there, I have a 4 legged animal ai and it runs into stuff constantly. Like if I make it follow me and while it's between some trees I suddenly change direction it just clips through the tree so it can turn to face me, or sometimes while it's walking it gets stuck between 2 trees because i have set my navmesh to a high agent radius so it avoids trees, but the collision ends up getting stuck between no navmesh areas. I understand most of these issues ar cause by the fact that characters have capsule collisions, how do people usually deal with that? I mean with a capsule collision if an animal turns around and an object is beside it most of the times it will go right through
so far, all I have seen is:
- easy mode: the capsule is basically a sphere around the animal
- difficult mode: there are collusions set that detect when the animal is colliding against something uppon turning and different montages are applied to do the right turn
Easy mode sounds OP
Is there any reason NOT to use easy mode ?
you might end up with a capsule with a radius larger than your nav agent radius and your animal will take paths through corridors too narrow for it.
Collision also will look weird because of the red area detecting hits etc when there's no animal body there (lots of empty space within the collision). It requeries a second set of collision boxes to handle damage for example
currently our approach is something like this
which has a different set of issues
Regarding damage and stuff my animal just needs to follow the player and collide with him so that's pretty simple
Then I would try having the capsule engoulfing the animal and see what kind of problems you get from there
Why not build your own local navigation? use a simple steering/avoidance approach
I'd not have a capsule at all
What a pawn?
just a avoidance force that scales up as you get closer to the player, bit like they do in TF2
physics implementation + Multiplayer movement replication can be a nightmare to deal with, but definitely doable
So its a soft penetration penalty rather than a physics collision
Yeah characters have physics set up
I did that with a squad of soldiers, because getting them through a doorway was a pain without a bit of squishyness
what about network replication for movement? how did you handle it?e
You can build it simply into the detour crowd avoidance stuff
Why would a large capsule make my animal to go through narrow spaces?
How did you fix this? (I tried it too but had issues)
if your agent radius used to generate the nav mesh is not >= to your quadruped capsule, the paths calculated have the risk to go thorugh spaces narrower than the capsule radius of the quadruped
we didn't really. We still have issues, mostly because the IK of the back legs make the body go up slopes is shouldn't, but that's digestible by players.
Doesn't the animal pass through stuff when turning abruptly
?
Do animals turn abruptly?
I am kinda new to ue and this is my first project so Idk if that would be very doable or effective in comparison to other approaches
Mine does
Because if it's chasing me
And I turn abruptly
It does so too
you mean the back part of the animal? not really because we don't have abrupt turns for quadrupeds. that's not how they turn. if we need to turn something between 130 and180 degrees, the play a rotation anim on the spot, then move along
quadrupeds do not turn abruptly, that's in your favour. The right to get bits and pieces of reality when it fits you XD
If its chasing you, why don't you predict the players movement forward a bit and try and figure out a path to intercept? that way you can use the time to intercept to interpolate the turn
Bit of motion warping never hurts
So that's what the turning animations were for? Lol I have an animal pack and searching through the animations I found one and was wondering
can't say about your code, but sounds like it
I hadn't even thought about that
You can do stuff like anticipate the player and telegraph the animal responding.. stuff like leading off a turn from a specific foot plant etc
How do I check how many degrees my ai wants to turn ?
Watch how a dog does it for reference
I assume multiplying the vector ?
Yeah, its called extrapolation, you basically extend its velocity forward in time by some amount
There's some code somewhere in UE for it, but its way old and never got completed if memory serves
I see
Think I spotted it in one of the sense/perception codebases
I can just make it myself right? Doesn't sound too tough
Yeah, to be honest, I'd write all this stuff myself
Its a bit outside the default UE use-cases, so better to understand it yourself IMHO
you can do this and then make the Move to move to that location. The problem: you will loose all the extra stuff of move to actor, like re-pathing within the same move to task. Which will cause a new move to task every time you re-calculate that location. That will complicate things in your bt or causing weird start/stop issues in your movement.
To avoid that, you will need to:
- ez: move to an invisible actor you position at that location and that you move when a new predicted location is calculated
- complicated: you create your own move to task that repaths upon the goal location changing
I'd expect that you could just move towards the player most of the time.. I'd do a navmesh raycast first and only path if that fails
yeah that too. You will need to ensure the point is within nav. Good point
All of this will teach you a bit about navigation, so better to at least have a go yourself
None of the default UE stuff will look good in my experience.. not with quadrapeds at least
agree. Anything byped, easy. Quadrupeds? a nightmare. The new Mover plugin supports other geometries than capsules. I would be happy if we could at least rotate the capsule in Unreal within the logic we have
I assume once they release that, there's going to be a ton of issues raised ๐
If I recall, there was a GDC session about navigating quadrupeds.. but I can't remember who by
Horizon Zero dawn has one but that's not unreal
Might have been Daniel Holden now I think about it.. he's at Epic doing anim stuff now
He's the guy that did phase function neural networks if I recall
Sure he did a dog thing, but might have been someone else
I've read a lot of papers since then, they all merge together ๐
Did you look into PostEditInstanceDataChangeChainProperty on the task?
yes, that looks nice but I would stil have the other problems with the UFUNCTION requirements
so my issue:
- we can't put variables subject to change at runtime as task members. They have to be within the Instanced Data
- The instanced data can't be a class because it's only half supported, so it has to be a struct (which seems to be the general plan ahead?)
- A USTRUCT can't have UFUNCTION, which makes it impossible for the data instance to handle async operations where a UFUNCTION is required as callback (ie Timers, Async Loading of assets and multicast delegates)
I did this in the past, but I remember I had GC issues. We want to provide a sample for best practices on this, since its a complex subject. I'll find out what the best way is and try to post something here soon-ish
much appreciated. In the meantime I will stick with
- Task are Struct based (FStateTreeAIActionTaskBase)
- Instanced Data are class based using every bind property as Category = Parameter, so I can bind them or set them up by hand in the editor (since input doesn't work)
@slow bobcat what base class are you using for your uobject instance data classes? the BP node one?
UObject
base class we use is just this
class UCustomStateTreeAITaskBase_InstancedData : public UObject
each task Instanced data class inherits from it
then what do you do with your virtual const UStruct* GetInstanceDataType() ?
pretty sure you end up with a f...ed up instance data store
We return the instanced data of the task (which inherits from the base one I posted)
{
return UCustomStateTreeAITask_RunReaction_InstancedData::StaticClass();
}```
so far... this seems to work
so you are returning the type of a uobject as a ustruct? .. what ๐
Don't ask me, I just use what you guys let me use XD
Im surprised this even compiles, let me poke at it
I'm still half-way refactoring and pending proper testing, but seems to work just fine so far. Will let you know if this was just an ilussion
well, you have property binding problems so not everything works as expected ๐
@misty wharf tagging you because I saw this hack in your blog
True
Yeah I'm pretty sure for that one I just copied how one of the builtin tasks used it
I don't know how else you're supposed to use it if you have UObject instancedata :D
Is there a node that checks if my ai is turning ?
not that you need to build yourself. One way is withint the path following component for example. You can check the angle between your current path segment and the next (if any) and figure out if the AI needs to turn hard (angle > X degrees)
where did you see a uobject instanced data used in a task? Im not seeing it in what we provide with the engine
I'm sorry I'm kinda new where do I find this?
in the Path following component code
Oh I have to tweak c++ code ?
That's interesting
hey zooom!! nice to see you back
yeah. Most of the cool movement and path stuff is c++ only
It must've been in 5.2 or 5.3
Some people say in ue you can do everything in bps but as I use the engine more it seems a lot less true, tho you can tweak your games needs to avoid cpp
Is it common practice for people to tweak epics c++ code ? Is there a possibility of breaking something ?
you don't need to tweak anything. you create your own child class to have a custom version of the component and you add code there
Hm I tried to look for it - but I can't find where the builtin tasks are in the 5.2 codebase at least with a quick search :D
It was probably the MoveTo or the EQS task or something in one of its earlier iterations
Hey!
I'm trying to make a zombie made up of pieces.
I mean for example to detach his arm at some moment and turn it into a separate AI.
The zombie model is different body parts with the same skeleton.
I have a few options and I'm not sure which would be better.
- Attach the body parts(skeletal mesh components) inside the zombie BP, set their leader pose as a torso. Detach the part at the right moment and spawn the AI.
- Spawn actors with pre-made body parts and attach them to zombies, and at the right moment detach them. More difficult to customize, but in general a working option.
- Use Child Actor Component with which to work as with the 2nd option, but I have some difficulties with this.
What in your opinion is the best option or what option would you choose?
Translated with DeepL.com (free version)
this works just fine. My guess is taht UClass has some internal conversion to structs (out of my waters here)
sorry for the spam. I had to re-edit the image 4 times in a row
ok let me know if you find it, from what I can find those (MoveTo/EQS) were first introduced in 5.4
Do you recall which module the tasks were in the earlier UE versions?
I dont think they were previously, here is the initial checkin for MoveTo
https://github.com/EpicGames/UnrealEngine/commit/7c67c890764238bd39e6fdf2b7f219ab8cbc6797
I guess I can open one of my older projects in Rider which will help me find them, it's just always a bit of a faff because it somehow gets confused about what's what :D
I'll check older experimental or tasks under StateTreeModule
does it matter since this is valid in unreal?
UCLASS(blueprintable)
class UFoo : public UObject
{
GENERATED_BODY()
}
UStruct* structType = UFoo::StaticClass();
UClass* classType = UFoo::StaticClass();```
Im discussing internally if this is something we support or not
So thaaaat's how people do it. I get it now, then where do i add the new component ?
this is offtopic now. I suggest you dig into youtube tutorials about How To c++ in unreal
You are right might as well go into the c++ section of the discord
Thanks a lot for the help
Man, where did I see that UObject instance data thing lol
I'm looking in 5.1 and I don't see it...
UStruct is base type for all class/struct types that C++ or other scripting langs can derive from to describe their types to reflection, its not converting, its like UObject* Object = AActorPointer;
the FMyStruct types would have UScriptStruct not UStruct
UStruct is the most abstract/base type among all
i think what matters here is if Epic tries to construct a struct from that UStruct looking UObject or not ๐ if so, that UObject would blow up so bad
I guess I will find out
comment implies it can be a uclass here 
@chilly nebula it's in StateTreeTask_PlayContextualAnim in GameplayInteractionsModule in 5.5
Not sure how I didn't find it initially but there it is
Oh maybe it's because Rider is excluding that entire module so it isn't showing up in the search :P wonder why it's doing that...
Thank you very much ๐
Hi, is ChatGPT legit here? My original question is:
What kind of code structure in UE5 AI can do this:
When a character in front of you started attacking, cancel everything and started blocking.
Behavior tree, state tree, or something else?
I haven't touch state tree at all, so I'm unsure and need some directions.
ยฏ_(ใ)_/ยฏ
ST's seem to be getting more work recently but I think they can still be a bit harder to get to grips with especially in more complex scenarios
Easier if you know C++.
At this point for the question you describe, I could go either way
Yeah, either would work, as would something simpler, or any of the other architectures really.. not a difficult problem to solve in almost any architecture
Havent used statetree yet, mainly because I'd find it easier rolling my own at this point unless its very well documented, which I assume it aint yet ๐
sound like i'm going with behavior tree, at least for now
Seems reasonable
So, currently you can do this by using lambdas and storing a handle in the instance data (see the EQS task in 5.6). Im putting together an example of how you can do this with a ufunction, at least in 5.6.
Regarding uobjects as instance state.. we believe it should work, but we havent been testing this path and need to make sure ๐ so consider that unsupported for now
my guys were as surprised to see that as I was ๐
Appreciated. Although anything 5.6 is not helpful for me now. It will take several months for us to switch after release (unless some miracle happens), but appreciated none the less
Ok will take this into account if shit happens. I still need to finish the reactor, test in a build etc etc. Automated tests should easily capture issues with memory if they arise
Any guess on why the categories are not properly handled when using UClass?
no idea ๐ as I said, none of us were aware this was possible
Im creating a Jira ticket as we speak to add tests and investigate further
Heh
My dayjob is working on a WYSIWYG editor thingy with its own "rendering library"... I've been at that for over 10 years at this point and we also probably have some dragons hiding in there
Just responding to say that I did read all this and I haven't had any issues (so, same as zomg)
Does anyone have a good guide on the various 'StructView' classes that can be used with State Tree? FConstStructView in particular, with 'payloads' for events
I think it's related to instanced structs but don't quote me on that. I just used it as prescribed and it worked :D
Define none and working. What does the debugger say? And visual logger?
im having a problem where I tried to implement this state tree to my NPC but it doesn't do anything. Instead the NPC capsule doesn't move around, doesn't chase, doesn't animate, doesn't do anything. So looks like none of these 4-5 lines of state-tree code work.
and Im having this implemented on my NPC's controller
nothing
Does it run at all?
no
And you have set the tree in the AI Controller with the state tree component and you have initialize it?
Are you following any guide?
yes
multiples
Some key things to note:
- im not using replication
- I've put a break point here on this task, and it didnt react
- all animations work perfectly
- ๐ชฒHow can I debug or put break points on state tree? I tried it and it doesn't do anything ๐โ (maybe i should restart the engine?)
- also if you asked about the animations & it worked before when I was working with blueprints, so all animations were properly set up on my blendspace, my animal was moving, walking, biting, running, attackign etc. All worked perfectly ๐ฏ ๐ค
Ah the old classic
Thanks, I'll dig into the code
Also here's my newly created AI controller for my animal
Can't find what's wrong


Check this guide, let's see if your are missing anything
https://dev.epicgames.com/community/learning/tutorials/lwnR/unreal-engine-your-first-60-minutes-with-statetree
About debug: my suspicion is that your trees are not running at all. Otherwise you would see stuff in the state tree debugger tool, but you already said that nothing shows up. Tray setting a breakpoint in the root state just in case
If the root state stops upon entering with the breakpoint, things might be running but you are entering root - idle - root indifinetely
Try using on possess instead of begin play
This at least used to be a problem
But the autostart doesn't care about that no? Or is there an call you still need to do?
Autostart never worked for me, I would hope it has been fixed but I don't know :D
Same here. Calling it manual on possess too
The fun thing about it is that if you spawn the AIs at runtime, you gotta use onpossess.. but if you place them in the level, you gotta use beginplay
(same disclaimer as before, this at least used to be the case, not sure if it's been fixed since I've not re-verified this behavior as of 5.4-5.5)
you sure you're not getting any warnings? StateTrees will report if there's e.g. a Context/Schema issue i think
nothing
Ehat does the tree debugger look like?
where?
whats a tree debugger?
i meant in the logger/output window
im trying to add breakpoints
but i dont see anything being added anywhere
nope
State tree debugger. You told me nothing showed up there, so I wonder if anything changed nos that you call initialization manually on posses. I also find weird nothing is in the logs
Siggis link has answers for basic concepts you will need to double chekc just in case something can give out clues
Not sure if Visual Logger was mentioned but that's where I'd go at this point. At the very least it should indicate if the ST is being started and what happens next.
visual logger?
but I didnt get any errors whatsoever
Hey guys, anybody working with state trees? I want to use them purely as data object, is it possible to access the nodes/leaves and their variables in BP or CPP anyhow?
After some testing we believe this is fine, and its the codepath that is used by the BP tasks.
I have not been able to reproduce the property binding issue you had with not being able to bind input properties on 5.5.
ooh nice. Thanks a lot for checking.
The binding issue, did you test with my provided code?
I will double check if I have something local that could affect this. Any advice in that front?
there must be something somewhere.
- either in the .log
- or Visual Logger State Tree Category
- or de State Tree Debugger
I also agree Visual Logger is your best bet, at least to see if the tree is initialzing
Not a direct copy/paste no, but I did test both struct and uobject based instance data. I setup a simple float Input parameter and bound to a state parameter just fine. Should help you narrow down if you simplify one of your tasks to just a float, and if that works try gradually add back what you had before.
ok I will do that and see. Thanks a lot Siggi
You have enter conditions on both Idle and OnSeeingPlayer, so if something fails there the tree will basically be stuck. Try removing enter condition on Idle and see if it works now.
But definitely learn and get familiar with the StateTree debugging tools
Can someone confirm me something: when World Partition was released (as experimental in preview ue5 and for a while after) it only supported Dynamic Navigation right? I recall looking into it and discarding it for a project due to it, but I need to be sure about it now.
I faintly recall the same thing
@slow bobcat I have a working example for you, but I needed to use a 5.6 feature in order to properly write payload from a delegate to a task output parameter. Maybe you can adapt this to your needs in 5.5 ๐
Keep in mind this does not work for dynamic delegates, since as you know they need a UFUNCTION. To get around that you can bind to a function on an actor component perhaps, or just use a non-dynamic delegate ๐
This is very quickly put together and might have errors, so use with caution ๐
{
if (AActor* ContextActor = Cast<AActor>(Context.GetOwner()))
{
if (UTestDelegateComponent* Component = ContextActor->GetComponentByClass<UTestDelegateComponent>())
{
FInstanceDataType& InstanceData = Context.GetInstanceData(*this);
InstanceData.Handle = Component->OnScoreChanged.AddStatic(&FStateTreeExternalDelegateTask::HandleScoreChanged, Context.MakeWeakExecutionContext());
}
}
return Super::EnterState(Context, Transition);
}
void FStateTreeExternalDelegateTask::ExitState(FStateTreeExecutionContext& Context, const FStateTreeTransitionResult& Transition) const
{
if (AActor* ContextActor = Cast<AActor>(Context.GetOwner()))
{
if (UTestDelegateComponent* Component = ContextActor->GetComponentByClass<UTestDelegateComponent>())
{
FInstanceDataType& InstanceData = Context.GetInstanceData(*this);
Component->OnScoreChanged.Remove(InstanceData.Handle);
}
}
FStateTreeTaskCommonBase::ExitState(Context, Transition);
}
void FStateTreeExternalDelegateTask::HandleScoreChanged(int32 Score, FStateTreeWeakExecutionContext WeakContext) const
{
// Need final 5.6 for this!
FStateTreeStrongExecutionContext Strong = WeakContext.MakeStrongExecutionContext();
FInstanceDataType* Ptr = Strong.GetInstanceDataPtr<FInstanceDataType>();
if (Ptr)
{
Ptr->OutputValue = Score;
}
// Ideally trigger a task delegate here to trigger a transition, and read output param in a child state.
}```
oh and the instance data struct
struct FStateTreeExternalDelegateTaskInstanceData
{
GENERATED_BODY()
FDelegateHandle Handle;
UPROPERTY(EditAnywhere, Category = Output)
int32 OutputValue;
};```
Nice. Thanks a lot.
I think the dynamic stuff will need to be supported (although it is now since you can use UClass for instance data, we now know there are issues with it) because most of the time is not even an option to to not use them since it's a requirement imposed by engine/plugin libraries. And even if we bind to an actor component, how will we expose the result back to the tree other than write it into a state tree param through a global task (tick), then a task reading from said global param. Sounds very cumbersome for something that only one task would need (ie async loading an asset)
btw I've been advised by someone on my team that its better to use AddStatic here isntead of AddRaw ๐
Im confused by your last question there, my example above writes the result into an output parameter. However in order to use it, you would need to expose a task delegate and fire it when you get the payload, trigger a transition and then read the result output param in a child state
No need to rely on ticks
Sorry. My question was about dynamic delegates where ufunctios are needed. You suggested to use functions in the actor, which creates a situation where info needed by the task will be written in the owner actor, then needs to be injected back to the tree for the task to access it. The only way I can think is by using a global task that checks on tick whenever that info is ready, so it can expose it through a param back to the task
ah ๐ yeah, I would try with a uobject-based instance data class instead. I havent tested it, but it should work I think.
Should be 100% working seeing the tests you already run
If I've got a parameter set up in an EQS Query, how can I get it to use a Blackboard key for the value? Or is there any other way of getting a dynamic value into there?
The only solution I've come across so far would be to get into C++ and build a new data provider, but I'd rather not have to get into the C++ pipeline if I don't have to.
Sorry for pinging but I am curious given that it kind of a simple PR :) @chilly nebula
I wonder what is Epic's opinion on making navmesh really extensible. This would unlock us tons of functionality at the project level.
https://github.com/EpicGames/UnrealEngine/pull/12911
https://github.com/EpicGames/UnrealEngine/pull/12914
Both are still under consideration, we just havent had time to dive into it yet. Sorry, we can sometimes be a little slow due to other priorities
I'm not sure about the earlier UE5 versions, but I had static nav meshes generating on terrain with world partition in 5.4.1 and 5.3.2, but it was extremely buggy and frequently wouldn't generate for large segments of the world.
no prob, thank you!
thanks for the info. Those are later version for what I need to reference, but it's still useful.
Basically I'm trying to see if I can make the claim "World partition early versions only supported Dynamic Nav Generation and that's why we had to discard it" without being lying
I could always download the source code for 5.0 and check myself, but I'm trying to avoid that
sounds like you need to create your own task where that is a bindable param, which implies indeed to create your own data provider
Does anyone know what causes the standard AI controller MoveCompleted event to fire? I've got a character that's moving to an actor and for some reason it's firing repeatedly whilst the character is still in motion
Despite the character still being in motion
Is this just a case of 'move to actor' updating the target?
How are you moving your character in the first place?
Standard 'move to actor' in a state tree task
And where is that trigering from? What happens when that ai move to finishes?
Well that's the thing, it seems to be firing while the character is in motion
When I get the move completed event it's doing the following:
The same task has a 'move completed' event that I'm checking the status of to see if I need to re-path
So if the character is chasing the player, I need to pick up if it can get there or not
For example if the character jumps or otherwise winds up in mid-air
It's not an enter state thing- the debugger shows that state as active continuously
But it is getting move completed events
Whilst it's moving
Video of this happening
My guess is that the 'MoveCompleted' event is firing with the 'aborted' status because it's using 'move to actor' and constantly updating the position, but it'd be nice to know if that's actually the case so I can work around it
If I take the listener for move completion out, then pathing fails as soon as the player leaves a solid surface
So... Are you using bt's or st's?
Is your task running until the move to finishes and then triggers again or is it triggering constsnl?
Visual logger can confirm this. Is the actor moving while the AI chases it?
State Tree. It's using the 'Move to Actor' once, and only once, on state entry; 'should state change on reselect' is set to false, and it's in that state until the task finishes. The task only finishes when it's either close enough to the player, or 'move completed' finishes with 'success'
That's the idea yes, it's a kind of 'active search' mode
I've just checked and 'move to location' doesn't have this behaviour, so I can work around it
Just wanted to know if anyone had experienced this before!
Thanks for the help
And to confirm: the issue goes away if the chased actor is static no?
I'll have to check in a bit- it seems to be on a regular interval rather than if the player moves
@chilly nebula Think I have a bug with the Run EQS task for state tree. It seems to cache the querier's location or something. I have this simple EQS template to test with.
When using the state tree task - it is always doing the query from wherever the actor is placed originally. When doing it through my custom simple one (ignore the lack of safeguards, just a test) - it behaves as expected. So it queries from the querier's actual current location.
Video showing the difference. Notice how the built-in task, the eqs debug stuff doesn't change. First one is showing the built in task. 2nd is showing my quickly whipped up one.
Version 5.6 p1
I originally had a couple AI in there and noticed that they kept going to the same spots. So I narrowed it down to one. I did, previously, watch one go in the same like 4 spots for 2 minutes.
Thanks, I'll investigate in the morning ๐ if its a simple bug I'll try to get it sorted in a 5.6 hotfix in the future.
are you using Mover or CMC?
because I had some odd AI MoveTo results with Mover on 5.5 that I don't get with CMC
namely I get ticks that respond an unomoved target has changed locations and restarts the move command
my game is entirely AI Move TO and i'm exceptionally succeptible to AI Move to stuff
i was experimenting with moving on the clients with a steam deck
Can anyone using state trees and source control (p4/plastic/github) do me a favour? Can you try to diff a state tree against the depot in editor? We are completely unable to diff them (we get an error from Plastic), but it works with any other asset. We have no idea if it's a local problem or if it's not posible to diff state trees
CMC- bit too invested in it now to switch over to mover
I use Azure devops with Git - can't ever diff a binary asset.
To clarify: I'm talking In Editor: right click on the asset - source control - diff against depo
Oh - I don't use UE's git integration. It is...less than ideal.
git bash for me.
As God intended.
I still can't believe people use anything but p4 with unreal (and here I am... 4 years suffering Plastic...)
That's because P4 is stupid expensive
I'd be more open to using it if it didn't cost my first born.
And my team is small enough where git isn't really much of a problem.
diff against repo seems to be working with p4
It's free for 5 users and 20 workspaces. If your team is small... We are about 170 people so...
Yes. But hosting isn't.
Ok and you see a window with the changes etc no? The it's fucking Plastic. Jesus how much I hate that thing....
Because it is UE - I still need a bunch of space.
Do it locally
One of my projects is 240GB
These are rookie numbers XD
yeah basically like diffing blueprints
Yeah, then I have to worry about the stupid data caps from my internet provider.
Right now - Azure Devops gives the best bang for buck at a big ol' free
What? Ah... You are in USA aren't you?
Yeah
Can't believe you guys didn't burn down your Internet providers the very moment data cap was even mentioned
lol - we're a bunch of lazy folk
We talk a big game. But as long as we're still comfortable, we're not going to do anything
My old residence, the isp offered an unlimited plan. But my new residence doesn't.
#indielife
โ Trying to learn State Tree and the best practices. I can't seem to write anything to my context.
I have a global evaluator that has an Actor called Target marked as Output. In my State Tree AI I am using a custom AI Controller with an Actor variable called CurrentTarget.
The plan is that the evaluator only reads and doesn't write, and that a simple task reads from the evaluator and writes to the Context bound to AIController.CurrentTarget.
It just doesn't work as expected. The variable seems to be properly read and set in the simple task (fed from the evaluator). But other state tasks don't seem to have access to the context variable AIController.CurrentTarget. The tasks work fine when reading directly from the evaluator.
Is this actually a pattern that makes sense to write to the context? Any idea what is wrong then?
Or should my state tasks just read from evaluators directly? I then don't quite get what context does beside acting as custom inputs for one or two classes (actor and controller).
State tasks should read from evaluators directly- just bind those variables in. You can think of the context as a global evaluator if you like- you're always going to want to have access to the controlled actor and maybe the controller, so it just provides those up front. You can also create your own context schemas if you extend UStateTreeComponent
You can look at how the latter is done in the StateTreeAIComponent class, although the last time I checked you can't extend that class itself
IIRC perforce changed something with their free small team agreement because I started using subversion with my UE5 project for that reason
I can't remember what it was, but i've been perfectly happy with SVN for the last year or so
Thanks a lot for your thoughtful reply! So my instinct is not appropriate to have "state" variables on the actor or the ai controller for e.g. current target? It just seemed more efficient to set it once, and when the situation changes and not constantly scan every tick with the evaluator.
~~I think I realized that at least technically my approach should work by passing in the ai controller via context to the task and then setting the variable on that controller. ~~ Update: Hm, nevermind, I guess that would require casting to my specific controller or coupling it really closely to that in the context variable.
Before I tried to magically update a context variable via binding by just setting a task variable marked as Context bound to the ai controller variable in the state tree panel.
But yea, maybe it is just still not a good practice like you allude to.
What's the recommended way to play animations for different skeletons using smart objects? One slot per skeleton type? A ContextualAnimScene with multiple tracks?
I'm trying to use the "Generate Nav Links" feature in 5.5. I want my npcs to jump down from ledges even if they are quite high, but not to try and jump up. I'm having 2 issues:
-
It doesn't seem like the "Jump Max Depth" setting actually does anything. With a high Jump Max Depth, but a low "Jump Ends Height Tolerance", No links are generated (see screenshot #1), but if I invert those values then it generates links. (see screenshot #2). Setting the "Jump Max Depth" to a high value actually deletes the links from screenshot #2. From the documentation it seems like increasing the "Jump Max Depth" should only add more nav links, not remove them?
-
I can't seem to make the links only go in a single direction (down not up). In a situation where there are stairs connecting two different elevations, I want the npcs to take the stairs to go up and jump off the ledge to go down. If I add links like in the 2nd screenshot the npcs do drop down properly but then they don't try to use the stairs to go back up.
Manually placing a proxy that is left to right only does exactly what I want
Thanks ChatGPT, you first led me down the wrong path, but we've come full circle now. Thanks again @kindred zephyr
I want to know has anyone have ever made custom ai movement in blueprints? Like they don't use ai move to node which work with only navmesh.
The custom movement function doesn't rely on navmesh
Yeah I doubt ChatGPT has anything useful on State Trees given the amount of documentation available...
Well you can do both- you can have an evaluator return a property that's on an actor, for example
So if you want to store it that way, you can
Does anyone recommend any voice recognition software, for UE5?
not completely sure, you would need to check in code if it's possible to handle things like Custom Movement Modes in the Character Movement Component or see how to apply Movement requests (like the ones used by the path following component) or Add Input to the characters in Blueprints.
There's also something called Floating Pawn which is another way to handle movement that doesn't rely on Character Movement Component.
You could also try the new Mover Plugin, but no idea how good is that for BP's
Not that kind of AI chat, but... Check in FAB for plugins, there is soemthing there for sure
Is there some example of like a good quality good AI Behaviour tree and Blackboard? or some good resource for it. I always find myself lacking in reference material of what makes good AI BTs and how certain behaviours can be setup properly
I'm not sure if you're looking to learn or trying to find very advanced resources. In my experience, most tutorials teaches you to create a very basic AI Setup at the cost of not teaching you how to properly extend it with more features. Although I don't use everything from this course, I think this course is a good starting to point when it comes to complex AIs. Not sure if this is the answer you are looking for.
https://www.youtube.com/watch?v=-t3PbGRazKg&list=PLNwKK6OwH7eW1n49TW6-FmiZhqRn97cRy
Chapters:
00:00 Info on the Full Series
01:29 Info on Part 1
01:52 Enemy and Player Setup
04:43 Basic Enemy Behavior
08:30 Fix Leg IK issue with Ue5 Mannequin
11:33 Creating the Behavior Tree and Blackboard
12:43 Quick Explanation on Behavior Trees
15:02 Building the Behavior Tree
17:20 AI controller Setup
21:27 Testing the Behavior Tree
23:05 C...
Thank you ๐ Yes exactly, I have made AIs before of varied complexity but I tend to like having some resources to explore best practices/solutions to more complex problems so I can learn from them and affirm/correct the way I do things
I'll have a look ty ๐
I really wouldn't say Ali is teaching "best practices" per se. They're doing things better than most on YT, but still not really what you'll strive for in a bigger production game. They don't make things as data driven as you should aim for.
'Nor do they handle some edge cases
I wish I could like take some UE game with complex AI and go look at their setup lol
like released production grade, efficient, good quality AI
This is in general a problem that I've ran into also
It feels like there are certain patterns to doing things that make sense but you don't know if you don't know and nobody tells you because people who know aren't the ones making youtube videos
For the most part - we mainly have Bruno and Luthage in this chat (but Luthage has stopped showing up ๐ข)
I don't know of any other fairly professional AI dev here. I mean, I'm sure Siggi can also offer advice and approaches.
And don't forget Miezsko, the guy that actually did the Bt's implementation in unreal (among other things)
My advice is you watch as many gdc vault videos from all game AI summits, AI in Games YouTube channel and UNREAL fest AI videos from the different editions. Also read Game AI Pro 1/2/3 (free online) and Game AI Uncovered (new book series). With that you will have a pretty solid base about approaching problems
He has abandoned us in favor of #mass
Moving on to bigger and better things. The nerve of people.
(I love Mieszko though)
The M in Mass stands for Mieszko
Will do ty ๐
Speaking of people knowing how to do things and not making videos on it...
I would love some ideas on how to handle the enemy AI (state tree) when a projectile from an enemy team is coming towards it so it may dodge.
I know some games will just listen for the player input and do things based on that information.
Folks like Ali have made guides where when the player fires a projectile, a boolean is ticked to true for bIsFiring, and the enemy puts up a shield, but this feels lamesauce imo
I also know some will listen to an event everytime a weapon is fired from the player and do things based on that.
Games all cheat like this
It's really a matter of what looks/feels "good" when you play it
That is why I want to avoid it haha, it is very easy to break it in games
having them detect it in some kind of more "realistic" manner doesn't necessarily make it so
especially games like elden ring
But the alternative that comes to mind is using some kind of overlap check or otherwise to determine when there's a projectile nearby, but that naturally depends on how quickly the projectile moves and whether there would be enough time to do something about it
Hmmm how about the enemy perception component?
if it sees a projectile, curve chance to dodge?
Depends. If you mean using sight, keep in mind it linetraces
Whether that's going to be a problem depends, mostly on how your geometry and such is, and how many projectiles and enemies scanning for them there is going to be
Easiest way is to project the flying tajectory and check if it will hit the target on the moment you spawn the projectile. If it does, enable a sphere trigger around the target. Upon overlapping check again if a hit will happen and play your block/dodge anim. Radius of the trigger needs to be big enough for the AI to have time to play the anim
This pretty much
Thank you, both of you
Duro got totally snuffed
๐ apologies, scattered at the moment, thank you too Duro
(phone, laptop, spotify, UE all dinging)
lol
idk if any of you use AI to create visual diagrams of descriptions, but man, it helps me out so much to have a visual aid instead of a wall of text (wall loosely used here, and it's 100% an adhd problem of mine haha)
Here is the diagram it created based on your description:
The off-center blue circle at the bottom is the equivalent of extra fingers in AI Gen images
I can check how we do it in our current game too, but that would be tomorrow
Or actually... I can ask a friend. One sec
What AI is generating that for you?
Claude Sonnet
I've never tried asking AI to generate that stuff.
It's so good because it does it with markdown rather than generate an image
Do you just tell it to generate it in that format or something?
I tell it I want an html diagram
You can also have it do Mermaid charts
check that out too, I just found it
It seems to create Mermaid charts of the repo... Which work with Obsidian Notes!
I agree, though topology views of code like this seldom are useful really
Unless you are onboarding a new person?
Hey how do you stop your animal when the anim montage needs to be played? Because I tried stop movement imediately and some weird things happen
What weird thing happens?
We spawn a very enlarged collision box that, upon overlapping with the target, assigns a g.tag that is then read by our AI system to react to the projectile incoming
That for dodge, for block shield it's decided upon impact
Thank you for that!
Well if I stop its movement like that I cant get my ai to keep moving afterwards. The montage played and then I dont know how to continue the regular path toward the player, I tried changing the movement state but it didnt help
hi ! would it be a good idea to sync an ai to an audio using a sequence to do a boss fight ? (i am trying to remake a boos from a video game, she is a ballerina and she appears and disappears at some moments of the song)
My main question about this would be how reliable is the timing with the sequence going to be. Other than that it seems like a potentially ok solution
sorry what do you mean by how reliable is the timing ? (i apologize english is not my first language)
Well I'm assuming you would play the music and use the sequence to place a call to the AI at a particular point to synchronize with the music
Sometimes things like if you get a framerate hitch could impact the precision of some systems
so it's mostly whether it's reliable enough that the timing would generally be close enough
Maybe a better way would be splitting the music in a certain way that wouldn't compromise the audio experience but it would be triggered along with the gameplay
so they both follow
You create another MoveTo request by calling the node MoveTo again
it would only be used to spawn the boss, so the timing doesn't have to be exactly perfect i think, but maybe splitting it would be better indeed
Yeah but I can't know what the previous request was about, since the montage gets played inside the anim bp
And the ai move to is placed inside my behavior tree
It sounds like for your use you could put up with some latency. Sequencer or even just a timer on the game thread should work good enough.
But wasn't your AI just following a targeted actor? The you know where to go.
- stop
- turn around
- move to target
Everything happens from the BT no?
I'm not sure I understand the issue
Yeah but that's not the only ai move to I use. Maybe the ai is moving toward the player or maybe it's executing a retreat task and running away. If I need to play a turn montage after it's end I can't know which task of the behavior tree was previously getting used or where the ai was going
Anyone have a link to a robust Rotate Character task?
Surprised it's not part of base engine.
state trees are so complicated bruh
What makes it complicated for you?
Overall, I do agree that it is more complicated than BTs were - but you can model it like the BT now (in 5.6). The only thing that it is missing is the observer aborts stuff from the decorators. But you can kind of do that manually.
Yeah that's an architecture issue.
The way I see it, either you store what you were doing somehow to resume the activity after the turn or you implement the solution within the path following component checkign the angle between your current segment and the next upon SetSegment call. If the angle is bigger than X degrees, set the velocity to 0, play the turn animation and resume movement. Since it happens within path following component, you don't need to worry about the movement task part
That's how I handle it
Set focus would be it. Just make a task calling it towards your direction
I need it as a task that waits until the character has fully faced the target.
It should be fairly easy to roll it as a Gameplay Task yourself based on your requirements
You can then reuse it for whatever quite easily in that form
What zomg says. You just check on tick the angle towards the direction and stop once it's aligned. Leave an offset to avoid jittering back and forth
Ah I see, set focus on enter then wait until focus is achieved. I'll also need to detect if focus is changed to something else.
Okay I get it thanks
Like this ? PathFollowingComponent->ResumeMove(FAIRequestID::CurrentRequest);
I don't use that. What I do is that I set the velocity to 0 while the animation happens. Once it's done, I set the velocity back to what it should be
But that function does look correct
Oh you just change the velocity ?
If I do that with max walk speed in anim BP won't it be the same ?
My friend gpt said so
Check if the function even exist....
No, it's not the same to change the max limit than saying "your velocity is now FVector::Zero"
Stop - turn - walk
But that said, setting the max speed to 0 will indeed stop the character I think.
Yeah that's why I asked lol
Okay I will try some stuff out thx
Ok functions pause/resume do exist. I will review my code and see if I can use them rather than manually changing the velocity
Seems to be a better approach
@chilly nebula I have another small issue with UCLASS based Instanced Data: it seems the "instanced" meta tag doesn't work for its UPROPERTY's
Not a biggy for me really, since I can have them as Task properties, but maybe is worth checking
๐ Hey everyone!
I'm currently working on a personal project called Synthetic Will โ a realistic, evolving simulation built in Unreal Engine 5.
In this simulation, an AI gradually gains control over a human society, learning and adapting its behavior based on how agents interact with each other and with the AI itself. My goal is to explore emergent behaviors, ethical dilemmas, and how centralized intelligence might influence a decentralized population over time.
The world is not static โ the agents make decisions, form routines, and can react in unpredictable ways. I'm especially focusing on creating a balance between complexity and performance, with a limited number of human agents to make the simulation more focused and meaningful.
I'm still early in development, so Iโd love to hear your thoughts:
Any tips on building complex agent behaviors in UE5?
Suggestions for handling AI learning or evolution in a game/simulation?
Ideas for keeping the experience engaging and not just a passive observation?
If you're into simulations, emergent storytelling, or building systems where things can go unexpectedly wrong (or right!), Iโd love to connect. ๐
Thanks in advance for any feedback or advice you can share!
For simulation needs, especially if you want to model needs (ie hunger, tired etc) a utility based approach works really well. State Tree has a utility selector. Its still pretty basic, but will be iterated on.
Depending on how large you want your simulation to be, I would offer different suggestions of tech. Like if you want hundreds or thousands of NPCs, definitely look into Mass and City Sample.
Thanks a lot for the suggestions! ๐
I hadnโt considered a utility-based approach in detail yet โ Iโll definitely look into State Tree and how its utility selector works. Even if it's still basic, it sounds like a solid starting point for modeling agent needs and priorities.
As for the scale, Iโm not aiming for thousands of agents โ more like a focused population of 50โ200 humans to keep things emergent but manageable, both technically and narratively. I want each agent to feel somewhat unique, with decisions that impact the broader system in subtle ways. That said, Iโll still check out Mass and the City Sample, especially to understand whatโs possible at larger scales and maybe borrow some ideas.
Do you have any examples (or resources) of simulations using utility systems effectively in UE5? Or tips for combining that with agent memory or long-term behavior shifts?
Really appreciate the help!
50-200 is still considered fairly large, and the current actor and skeletal mesh animation framework will struggle with that scale. + behavior tree performance doesnt really scale well to those sizes.
Study city sample, we used Mass + State Tree there and an alternative to animated skeletal meshes to get the large scale.
There are lots of resources on utility systems, including a few GDC talks like "How to build a better centaur". I dont have a sample to point you at for UE5 though.
ST isnt using the full BP VM, so not everything works no.
Thanks for the heads-up! I understand now that 50โ200 agents is still quite a challenge performance-wise, especially with the current animation and behavior tree systems. Iโll definitely dig into the City Sample, and how it combines Mass and State Tree, plus alternative approaches to skeletal mesh animations.
Iโll also look for the GDC talks you mentioned, like "How to build a better centaur" โ thanks for the tip! If you happen to come across any UE5-specific samples or resources later, Iโd really appreciate it.
In the meantime, do you have any advice on how to prototype or start small with utility systems in UE5 without hitting big performance issues too soon? Maybe some lightweight alternatives or best practices?
Thanks again for your time and help!
First steps I recommend are looking at City Sample, study State Trees and how they can be used in Mass.
If you want something generic just to learn, you can look at the ST utility selector or a framework like this one:
https://www.nooparmygames.com/products/wise-feline-utility-ai-for-unreal/
Wise Feline is a utility AI system which allows you to make immersive AI with ease. It works great for agents in complex situations and has a great visual
Thanks for the advice! Iโll start by digging into the City Sample and studying State Trees, especially how they integrate with Mass.
The utility selector framework you shared looks really useful for learning the basics โ Iโll check out Wise Feline AI for Unreal.
Appreciate your help!
No problem ๐ btw either you are really well spoken and polite, or you are an LLM bot ๐
Haha, Iโm definitely human, but Iโm not a native English speaker, so I sometimes use AI to help me phrase things better and be clearer. Just trying to learn and communicate as best as I can! ๐
Thats a great use for it ๐ GenAI is already having a big impact on how we all learn things
That's fine. Bit limiting but workable
Thank for the answer siggi
It's incredibly helpful for my adhd ass.
Just have to be good about sources, fact checking what you learned, etc.
And you can create your own databases for knowledge it doesn't have yet
Is there any way to make Navmesh to detec surface type and assign navigation cost based on this surface type, so that AI will not go on water and prefer roads over dirt. I know I can assign cost with Nav Modifiers Volumes, but they have to be placed by hand, what will take ages to put them on my level. Maybe it is possible to use Navigation Areas for this, combined with nav querry filter, but how to use that? Or EQS, but which test and filter to use for that, projection? I'm looking for an answer for this for two days already. Topics on multiple forums with the same problem as mine has no answers. I saw there is an add-on, capable to score navcost based on phismat friction. Generally, seems that Unreal navigation can't detect surface type. I hope I'm wrong.
Has anyone worked on indoor/outdoor audio occlusion/attenuation for AI perception systems?
Nav areas + nav query filters will achieve this as you mentioned, but you still have the problem of placing nav modifier volumes by hand. One thing you can do is to post-process your created nav.
I can explain it but first one question: what type of navigation are you using (static/with modifiers only / dynamic)?
asking becaus your picture looks a lot like "Dynamic around nav invokers" type and, if that's the case, post process will not cut it I think

Should still spill the beans for a static approach. Someone in the future might chance upon it.
Thanks for answering. Navigation is static, one, rectangular volume, no invokers there. I have setup quite large values on some height parameter(step height I think) to exclude steep slopes from navnesh and trees have collisions on them so also are excluded.
ok then. Static and Dynamic With Modifiers Only are friendly with post-processing.
Step one is to generate your nav as you always do.
Then you can add stuff.
The high level of it is:
- you can grab all the tiles of the nav data
- loop them and grab every polygon in it
- loop every polygon and launch a trace down from each vertex and the center.
- if your trace hits land, do nothing, if it hits water, you can change it's area flag to "water" (you will need to create nav areas with costs)
THe main problem you will have is situations like this (image)
Imagine this is your landscape. You are seeing your nav with tiles (not accurate, all tiles will be the same size etc, but you get the idea)
If your terrain is flat an nothing disturbs is, all tiles will be holding just 2 polys each (2 triangles, the minimun possible).
That will cause issues in tiles like 1, 2 and 3, where the polys will be flagged as Water, since at least one of the traces (vertices or center) will hit watter.
A path from A to #2 will look like the red line aand that might not look great because you will expect it to go through #3.
You could apply more granularity and do more traces and set a rule like "unless X traces hit watter, do not change the poly area flag"
Just do a trillion line traces and hit every cm of the navmesh. Easy.
Now the trick to this is that you can do this from a commandlet or within a bluetility, completely offline and multi-thread (each tile in a thread).
I do lots of post-processing in our build machines when making builds
this is just a second pass over your navigation building process. And since you use Static, none of this will happen in runtime
this code snipped should give you come clues. It's an extract of something I do to clean out the nav from unwanted polys
{
dtNavMesh* detourNavMesh = WorldRecastNavMesh->GetRecastMesh();
if (detourNavMesh != nullptr)
{
TArray<const dtMeshTile*> tilesToRemove;
tilesToRemove.Reserve(detourNavMesh->getMaxTiles());
for (int i = 0; i < detourNavMesh->getMaxTiles(); ++i)
{
const dtMeshTile* tile = static_cast<const dtNavMesh*>(detourNavMesh)->getTile(i);
if (tile == nullptr || tile->header == nullptr)
{
continue;
}
const dtPolyRef base = detourNavMesh->getPolyRefBase(tile);
const unsigned int polyCount = tile->header->polyCount;
unsigned int removedPolys = 0;
for (unsigned int j = 0; j < polyCount; ++j)
{
const dtPolyRef polyRef = base | j;
{
// CUSTOM TO MY GAME USELESS TO YOU except for the set methods
/**if (!NavFlags.GetFlags(polyRef))
{
detourNavMesh->setPolyFlags(polyRef, 0);
detourNavMesh->setPolyArea(polyRef, 0);
++removedPolys;
}**/
}
}
// control empty tiles than can be removed
if (removedPolys >= polyCount)
{
tilesToRemove.Add(tile);
}
}
for (const dtMeshTile* tile : tilesToRemove)
{
const dtPolyRef tileRef = detourNavMesh->getTileRef(tile);
detourNavMesh->removeTile(tileRef, nullptr, nullptr);
}
}
}```
Hey there, when I use "stop movement immediately" does something happen to my behavior tree ? I mean will it keep running normal afterwards ?
there's also this
FRecastDebugGeometry navGeo;
navGeo.bGatherPolyEdges = true;
navGeo.bGatherNavMeshEdges = true;
for (const FNavTileRef& tileRef : NavMeshTileRefs)
{
// get the navigation vertices from recast via a batch query
NavData->BeginBatchQuery();
NavData->GetDebugGeometryForTile(navGeo, tileRef);
NavData->FinishBatchQuery();
TArray<FVector>& edgeVertices = navGeo.NavMeshEdges;
const int32 totalEdges = edgeVertices.Num();
if (totalEdges > 1)
{
const FVector firstEdgeDir = GetEdgeDir(edgeVertices[0], edgeVertices[1]);
const FVector lastEdgeDir = GetEdgeDir(edgeVertices[totalEdges - 2], edgeVertices[totalEdges - 1]);
for (int32 iVertex = 0; iVertex < totalEdges; iVertex += 2)
{
const FVector edgeStartVertex = edgeVertices[iVertex];
const FVector edgeEndVertex = edgeVertices[iVertex + 1];
const FVector edge = edgeEndVertex - edgeStartVertex;
const FVector edgeDir = GetEdgeDir(edgeStartVertex, edgeEndVertex);
const float edgeLength = edge.Size();
}
}
}
That allows you to get all the geometry from a tile and do operations with its nav edges and poly edges. In the example I'm looping the nav edges to do some stuff.
A nav edge is the darker green line that defines the nav border in your tile.
Each tile will return theirs in the loop (Tried to mark them with black in each tile)
that depends on your tree implementation.
Let's say you have a sequence that
- Plays anim
- moves to place
- plays anim
if you call stop and the second task returns false, the third task will not run.
If it returns true, it will run
Wait and when is the stop movement called in this example?
forgot to paste the image
Thanks for this explanation. I will have to adrees this to our CPP programmer, since I can only use Blueprints ๐
whenever you call stop?
In the example you are moving because the second task is running and has a MoveTo node in it.
Then you call stop from wherever and that move to call is interrupted
@slow bobcat When you created your own ST factory, did you subclass the original one? The StateEditor.h header is in the private folder of the StateTree addon so I was curious about how you approached it, it's needed for those UE::StateTree namespaces
Ummm I need to check the code. Let me see. I think I did mine from scratch copy/pasting the code
(this is only a problem if you reimplement everything so I was wondering if subclassing would be a better idea and if you went with it)
Ah nice, I was trying to do that but those UE::StateTree utils are the main issues, I guess I could copy paste all the nested code that they involve manually but it doesn't sound right
I recall them having clases in the cpp file....
Let me boot the pc again (my good act of the weekend)
Much appreciated, thank you!
So wait if I call stop and then call again an ai move to since the last one stopped and this succeeds will the BT order continue?
ok yeah, I copy/pasted UStateTreeFactory and changed logic in it to show our own classes
No unless you do that within the same BT Task that is running already before finishing it.
Can you please tell me how you dealt with those?
Modified the engine adding the export macro of the module to them
Just to the validate functions in the class
Ok cool, so you need to actually edit the engine, I was wondering if I was missing a way to avoid this
I'm afraid not. And once again... I never did a PR for the change...
Heh no worries, thank you for taking the time to answer!
No worries
Hello everyone. I'm trying to build an AI character controlled by a StateTree. This character would behave like a companion to my main character and it should basically follow the player all the time, occasionally attacking when player presses a button. To do so, I created a few states for the various attacks it has, with conditions to transition to each one - and that part is working. But regardless if it's attacking or not, it should keep following the player. I tried to achieve that by having a MoveTo task in the root state, and the different attack states under the root but that doesn't seem to work since the root state cannot select a child state to activate if the character is not attacking. I know I could add the move too task in the various attack states, but that sounds a bit cumbersome and repetitive. Is there a simpler way to achieve what I'm looking for?
Interesting. Looks like if I have a noop state that the root state can select, it works like I expected. I can leave the MoveTo task in the root state so it always executes, and have separate attack states with their own conditions
So how am I supposed to continue the same task ? Is there some practical way people do it ? Because a turn animation could potentially play every few seconds so my BT stopping is kinda problematic
I remember you saying that I could store somehow what the ai was previously doing
But how?
You do it in the Path following component while processing the path in your task.
Forget about this. It implies different things that might be too complicated.
A other thing you can do is to pause the behavior through the behavior tree component, then turn, then resume.
How can I do that?
Look in the brain component for pause/resume
I'm wrapping my head around state trees pretty decently, but I'm having to learn a lot in a short amount of time. Does anyone know of a good use-case example to study?
I'd love to see a real, finished example of things like, "Here's how a character initiates combat, here's how they apply different strategies, move to different ranges, use attack patterns", etc.
Okay thx, is it done with cpp or bps?
No idea about bp's in general. I always do everything in code and then expose things to designers sorry
There are couple resources in the pinned messages that might help
Cool, thanks, I'll take a look!
Oh I see you work in a team. What I meant was if the brain component is something you access within the BT or c++
You can access it in either
Okay I will check it out
fwiw BehaviorTreeComponent is the BrainComponent if you're using it
Really?
Ok thx
So I can refference it in my anim BP for example?
As long as I have an actor or controller refference
Sure, same as any other component. I don't know what you would use it for in the anim BP though
I want to pause the BT before my montages play
And resume it afterwards
Ah... it kinda seems to me that maybe this should occur somewhere else than in the anim BP, but can't really say for sure :)
anyone able to help with QUS
EQS
I'm trying to test my EQS in world but without running PIE and I can do this if using the Testing Pawn thingy but this breaks down when I need to test things like only getting the eqs points in front of the player etc as then the EQS just doesn't return what I'd expect
Yeah that's why I asked if a refference is enough
If in your tests you use a context for the player, you can change the context for the testing pawn and grab some cube in the scene for example. Its enough to have an IF in your context that checks "if the querier is an AI, return the player, if the querier is a testing pawn, return this other actor"
What would the other actor be ??
Just a bog standard actor class which i just do get actor of class with
Doesn't matter. Some dummy thing you grab from the level. Make some empty BP and do a "get all of actors of class DummyEmptyBP". Drag one of those to the level and off you go
Another easy solution: If your context uses the player... just place the player pawn into the level
Now it will work in edit-time also :D
That's what I did earlier on after realising if I do get actor of class set for the player character bp rather then the get player character function
@misty wharf now that I have you here, do you recall what was the name of the interface needed to make any class a blackboard data provider?
What i didn't realise was the testing pawn was the quierer so spent about 20 mins earlier on swapping them in and out until.i realised
Never used it but it's like.. BlackboardKeyProvider or something? There was a discussion about it here a while back I think
