#gameplay-ai

1 messages ยท Page 78 of 1

celest python
#

GAS is a product of C++ being too difficult to tame for engineers and alien to designers. Epic is leaning towards making systems on top of systems, abstraction layers, OOP bombs etc. but then Hazelight achieves the same thing within a scripting language in a superior workflow

#

IMHO, same goes for AI most of the time tbh - not always - best AI tool is your scripting language

harsh storm
#

Yeah - angelscript is ๐Ÿคฉ

#

If you haven't given it a look, it is definitely worth it imo.

slow bobcat
slow bobcat
celest python
slow bobcat
harsh storm
#

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.

celest python
serene scroll
#

Is there a way to call events on an owning actor directly from an owned state tree besides going through a task?

slow bobcat
harsh storm
#

The big drawbacks of the fork, if you're not really aware of the fork in general:

  1. No interfaces. So if you rely on this a lot, rest in pepperonis. Hazelight prefers components over interfaces.

  2. 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.

slow bobcat
harsh storm
#

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

celest python
# slow bobcat I question that as a heavy GAS user. But I have never been in Hazlelight so... I...

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 ยฏ_(ใƒ„)_/ยฏ

harsh storm
#

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?

celest python
#

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

serene scroll
slow bobcat
harsh storm
# serene scroll a BP event

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.

serene scroll
#

that makes sense

slow bobcat
celest python
#

capabilities seems to be fixing those issues without giving away anything from GAS-like features

harsh storm
#

Target Data is pretty crummy. There, I said it. ๐Ÿ˜พ

slow bobcat
# celest python capabilities seems to be fixing those issues without giving away anything from G...

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?

slow bobcat
celest python
slow bobcat
celest python
#

I so liked capabilities I give that vibe huh

#

though I didnt even imply such thing KEK

slow bobcat
#

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.

celest python
#

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

slow bobcat
celest python
#

sure

#

this is their BT

#

its the capability itself

#

each capability can build a tree

harsh storm
#

Pretty sure they use gameplay tags and/or wrap it into a capability in of itself.

celest python
#

interruption, blocking etc. happens through capability virtuals or the gameplaytags that you set in defaults of the class

slow bobcat
# celest python

they build the BT's in scripts? and those TRees there are built in the editor with the Bt editor?

celest python
#

it looks like its just script

#

i dont think you'd need an editor for this

#

especially considering you can hot reload

slow bobcat
#

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

celest python
#

dark souls AI is a single monolithic lua file

slow bobcat
#

DS AI is outdated and old AF

harsh storm
#

dark souls is also pretty simple AI imo.

#

Very animation driven really.

celest python
#

its not "outdated"

slow bobcat
celest python
#

its running a very cool utility system

celest python
slow bobcat
celest python
#

and you control your BT through selectors, manually setting things in editor?

celest python
slow bobcat
celest python
#

Statetree maybe most innovative thing we've seen since

slow bobcat
slow bobcat
celest python
#

in the angelscript screenshot you've seen?

celest python
slow bobcat
# celest python how come compounds are not same?

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).
celest python
slow bobcat
# celest python 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

slow bobcat
celest python
#

I just remember Final Fantasy's layered BT<->FSM system, dont recall something similar to STs

slow bobcat
harsh storm
#

I think with 5.6, we can finally actually do everything that UE's BTs could finally.

celest python
#

well I guess ST is FSM with BT capabilities ๐Ÿค”

slow bobcat
harsh storm
#

Yup - the external data communication is probably the next big pain point.

slow bobcat
#

And the low level flow. Execution Context Tick is... not easy to digest

harsh storm
#

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

slow bobcat
harsh storm
#

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.

slow bobcat
harsh storm
#

PS5 is so 5 years ago anyway

slow bobcat
#

jesus... I'm getting old. NOT HELPING DUROX

harsh storm
#

lol

summer hazel
#

Hello, what's the difference between these nodes?

near condor
near condor
near condor
silent cove
#

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?

misty wharf
#

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

silent cove
#

Dang really? Like you can't have more than one overlapping? Or you can't have more than one in general? ๐Ÿฅฒ

misty wharf
#

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

slow bobcat
#

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

misty wharf
#

It's kinda annoying, I wanted to do something with overlaps on them also

#

Forget what it was but it didn't work

silent cove
#

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

slow bobcat
#

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

misty wharf
#

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

silent cove
#

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

simple verge
#

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?

slow bobcat
misty wharf
#

You could in theory make a task which can call any ufunction through reflection

#

Whether this is a good idea... not sure

#

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 :)

harsh storm
misty wharf
#

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

obtuse igloo
#

Anyone who's worked on a climbing system for AI before, able to help out?:0

simple verge
misty wharf
slow bobcat
# obtuse igloo Anyone who's worked on a climbing system for AI before, able to help out?:0

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

devout plume
#

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

harsh storm
#

Should be

slow bobcat
harsh storm
#

You'll hit problems with CMC before ST I'd imagine

devout plume
#

Great, thanks guys. Tick reduction can definitely be a thing considering my state changes will only occur rarely.

chilly nebula
devout plume
#

Oh awesome, thanks for the info!

sonic bramble
#

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

vestal briar
sonic bramble
#

if I build nav specifically

#

in the build menu sometimes it shows the nav data but its floating 100s of feet of the ground

vestal briar
#

ah I know my issues in 5.3/5.4 with navmesh sporadically not generating properly was only when using world partition

sonic bramble
#

Ill check it out thank you, could help with performace too

vestal briar
#

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.

sonic bramble
slow bobcat
sonic bramble
slow bobcat
sonic bramble
slow bobcat
# sonic bramble 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

sonic bramble
slow bobcat
sonic bramble
sonic bramble
#

everything works well now thanks alot for the help again

slow bobcat
#

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.

โ–ถ Play video
wise sluice
#

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)

chilly nebula
dawn schooner
#

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 ๐Ÿ™‚

chilly nebula
chilly nebula
#

Both can be implemented using either State Tree or BTs.

dawn schooner
dawn schooner
celest python
#

I think red alert AI was open source

#

if it helps

dawn schooner
#

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)

celest python
#

Red Alert 3 AI is extremely impressive to me

#

I dont expect to see its source code during my lifetime though ๐Ÿ˜„

dawn schooner
#

But maybe just playing it might give good ideas

celest python
#

i think the released one is for RA1

dawn schooner
#

ye

#

also probably SC2 AI and Company of Heroes might be other interesting references to look at

celest python
#

@shadow python any chance you have worked on a game very similar to company of heroes ๐Ÿ˜…

chilly nebula
shadow python
#

NDA ๐Ÿ˜ฆ

dawn schooner
near flame
#

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)...

dawn schooner
chilly nebula
dawn schooner
# chilly nebula its damn difficult, and at some point things just become impossible to solve ๐Ÿ™‚ ...

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

chilly nebula
chilly nebula
near flame
chilly nebula
dawn schooner
chilly nebula
dawn schooner
near flame
chilly nebula
dawn schooner
near flame
#

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

celest python
#

i played this at 8 years old once and then never became the same person again

chilly nebula
dawn schooner
celest python
#

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 sad (got a malware in my windows)

dawn schooner
#

wow

near condor
#

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

slow bobcat
near condor
slow bobcat
near condor
#

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.

slow bobcat
#

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

near condor
#

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."

near condor
#

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))

slow bobcat
near condor
#

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

slow bobcat
#

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

near condor
#

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

slow bobcat
#

but I'm not sure to be honest

near condor
# slow bobcat 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

slow bobcat
#

Wait... which engine version are you at? I don't have Parent within my options...

#

that's all I get

chilly nebula
#

@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?

near condor
near condor
slow bobcat
harsh storm
#

@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 ๐Ÿ˜…

near condor
#

for State Trees

harsh storm
#

Being able to tell the state to wait until ALL tasks are completed before transitioning

slow bobcat
#

Ok so we have sequences with ForceSuccess in all their children, State Tree version. Thar's going to help a lot

harsh storm
#

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 ๐Ÿค”

near condor
#

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?

slow bobcat
#

~~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

harsh storm
#

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.

slow bobcat
#

there aren't any binding buttons in the Transition condition

harsh storm
#

Maybe Siggi can look into this when he has time.

slow bobcat
#

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?

chilly nebula
chilly nebula
chilly nebula
chilly nebula
near condor
#

So I can see what I can do

crisp vessel
#

how can I access variables from one blueprint in blackboard?

slow bobcat
devout plume
#

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)

slow bobcat
devout plume
#

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

stark tangle
#

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?

hasty turret
silent hamlet
#

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?

slow bobcat
wise sluice
#

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

stark tangle
slow bobcat
stark tangle
slow bobcat
# stark tangle so, if less cpu usage is restarting freezed service, suggestion is - high cpu us...

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.

stark tangle
#

alt+tab is FIXING service, which is freezed for no reason after activation, with a "restart timer on each activation" enabled

slow bobcat
# stark tangle alt+tab is FIXING service, which is freezed for no reason after activation, with...

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?

stark tangle
slow bobcat
stark tangle
slow bobcat
slow bobcat
#

@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
misty wharf
slow bobcat
misty wharf
#

Oh really, I wonder if that's an oversight ๐Ÿค”

chilly nebula
#

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 ๐Ÿ™‚

slow bobcat
#

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
misty wharf
#

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

chilly nebula
#

I often used properties on tasks as settings/defaults set only at authoring time

misty wharf
#

Yeah I always thought of the direct props more as configuration settings for the task itself

slow bobcat
slow bobcat
chilly nebula
#

GetInstanceDataType()

chilly nebula
slow bobcat
# chilly nebula there is: https://github.com/EpicGames/UnrealEngine/blob/ue5-main/Engine/Plugins...

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?

misty wharf
#

Are you making a base class for custom BP tasks or just C++ tasks?

slow bobcat
misty wharf
#

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

slow bobcat
# misty wharf Right - in that case isn't there something like FStateTreeTaskCommonBase which i...

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

misty wharf
#

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 :)

chilly nebula
#

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

slow bobcat
#

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

slow bobcat
chilly nebula
#

np! good luck with the fixes ๐Ÿ™‚

slow bobcat
#

thanks. This is going to hurt: 14 tasks that will be transformed from UCLASS to USTRUCT.

slow bobcat
#

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.

misty wharf
#

I wonder if you could do something with details customization to similar effect

slow bobcat
#

I will look into it. I know we have done some stuff with it, but no idea if that was for STructs or not

wise sluice
slow bobcat
wise sluice
#

Yes i'm using it in 5.4

#

Look into the FStateTreeNodeBase struct

slow bobcat
#

Thanks a lot for the tip mate. Will do a research of functionality available alongside

wise sluice
#

You're welcome!

slow bobcat
#

oh no.... I have some delegates that use UFUNCTION members as callback (mandatory). And in a struct... you can't have that. oh boy....

chilly nebula
misty wharf
#

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

chilly nebula
#

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)

misty wharf
#

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)

chilly nebula
#

we are going to rework some of this soon and need to provide a good example for doing async tasks

slow bobcat
harsh storm
slow bobcat
harsh storm
#

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.

misty wharf
#

Oh yeah there is that also

wise sluice
slow bobcat
wise sluice
#

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

chilly nebula
#

tick is definitely not needed anymore, at least not in 5.6

slow bobcat
# chilly nebula 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?

harsh storm
#

I wouldn't imagine you'd need tick regardless for this. Enter State -> setup delegate -> on callback, trigger transition.

slow bobcat
harsh storm
#

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)

slow bobcat
stiff gale
#

How can you make a UE vehicle follow a path ? Like GTAV

harsh storm
#

Same way you make a person. Spline is the easiest and most straight forward.

stiff gale
#

It should be able to avoid obstacles

slow bobcat
# stiff gale 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

slow bobcat
#

@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?

chilly nebula
#

I would be surprised if you cannot do everything you want with those controls ๐Ÿ™‚

slow bobcat
#

amazing. That sounds neat indeed
I'm going through a painful refactor that will happen again when we move to 5.6 XD

chilly nebula
#

5.6 is such a big step for ST, I honestly wish I could just magically upgrade everyone automatically ๐Ÿ˜„

hasty turret
#

Cant wait for 5.6 to be released!

slow bobcat
#

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

crisp vessel
#

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

slow bobcat
#

if it's not valid...debug why

crisp vessel
#

for some reason trainer variable isnt getting anything

#

๐Ÿซ 

misty wharf
#

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

slow bobcat
#

@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

chilly nebula
chilly nebula
slow bobcat
# chilly nebula On state trigger, you should be able to bind the payload to a task that sets a t...

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?

chilly nebula
#

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

slow bobcat
chilly nebula
#

sadly at this point no, I would need time to investigate on my end or try this in 5.6

slow bobcat
chilly nebula
#

If you have time, try to see if it repros in 5.6 as well

#

some major refactoring to property binding done there

slow bobcat
chilly nebula
#

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

slow bobcat
near condor
#

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.

crisp vessel
#

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

misty wharf
#

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

crisp vessel
#

sometimes appears during training of learning agents after pressing the play button

#

idk what does it mean, hope it isn't bad

misty wharf
#

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

near condor
crisp vessel
tough sandal
#

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?

crisp vessel
#

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

tough sandal
slow bobcat
crisp vessel
#

I want to gather "wall" location, what should I do next?

rustic flax
#

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?

rustic flax
#

oops wrong channel probably, sorry! [meh, didn't find a better one]

misty wharf
#

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

crisp vessel
#

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

rustic flax
# misty wharf Maybe it's intended you'd query it from the smart object owner with the avatar? ...

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

crisp vessel
#

I have toggled this option on, why it doesn't create folder with data of training for tensorboard?

misty wharf
slow bobcat
#

There's one I think. I remember someone mentioning it here

slow bobcat
#

I think you need to look for plugins like this one
https://www.fab.com/listings/0e49d138-10e1-452e-ba07-9a4bea578ace

Fab.com

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, ...

velvet echo
#

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?

misty wharf
velvet echo
#

Thanks, I'll search some more.

solid wedge
#

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.

slow bobcat
#

There's a setting to make bbk's static (shared value among all bt instances)

#

It's a setting in the bbk IIRC

solid wedge
#

Exactly, I have that set. I was curious about how to set the shared value only once without looping all ai sharing it.

misty wharf
#

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

slow bobcat
#

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)

velvet echo
velvet echo
#

Oh, I see it probably is. zomg's tab-based approach is a good alternative for now I think.

vestal briar
#

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.

summer hazel
#

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

slow bobcat
#

Ah! You fooled me! Hahaha

cinder plover
#

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?

harsh storm
#

This channel is about game ai btw

#

Not the overhyped AI stuff

warm pulsar
#

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!

harsh storm
#
  1. Long-term maintainability - As in like...the AI itself or the tools? Because ST is going to be the future for AI in UE
  2. ST should perform better than BT
  3. Pretty big workflow differences. ST have more concepts to them despite them being state machines.
  4. No Blackboard and communicating stuff to the State Tree can be annoying
warm pulsar
#
  1. I would say as a standard for AI conception in unreal engine
warm pulsar
harsh storm
#

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.

warm pulsar
#

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

cinder plover
slow bobcat
#

@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.
misty wharf
misty wharf
#

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

chilly nebula
slow bobcat
# misty wharf Not sure what would cause issues like that - just to confirm you do have your va...

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 the GetInstanceDataType implemented but not that line
  • The parent class type doesn't matter: FStateTreeTaskBase/FStateTreeAITaskBase/FStateTreeAIActionTaskBase/FStateTreeTaskCommonBase are 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 as Parameter. 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;
};```
slow bobcat
#

and I'm using FStateTreeAIActionTaskBase as a base class for my task

misty wharf
#

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

chilly nebula
#

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

slow bobcat
chilly nebula
#

installing vanilla 5.5 now to check and compare with 5.6

#

Im hoping this is just some minor thing you do differently ๐Ÿ™‚

slow bobcat
chilly nebula
#

@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)

chilly nebula
slow bobcat
chilly nebula
slow bobcat
slow bobcat
#

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

summer hazel
#

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

slow bobcat
summer hazel
#

Is there any reason NOT to use easy mode ?

slow bobcat
# summer hazel 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

summer hazel
slow bobcat
#

Then I would try having the capsule engoulfing the animal and see what kind of problems you get from there

ocean wren
#

Why not build your own local navigation? use a simple steering/avoidance approach

#

I'd not have a capsule at all

summer hazel
ocean wren
#

just a avoidance force that scales up as you get closer to the player, bit like they do in TF2

slow bobcat
ocean wren
#

So its a soft penetration penalty rather than a physics collision

summer hazel
#

Yeah characters have physics set up

ocean wren
#

I did that with a squad of soldiers, because getting them through a doorway was a pain without a bit of squishyness

slow bobcat
ocean wren
#

You can build it simply into the detour crowd avoidance stuff

summer hazel
summer hazel
slow bobcat
slow bobcat
summer hazel
#

?

ocean wren
#

Do animals turn abruptly?

summer hazel
summer hazel
#

Because if it's chasing me

#

And I turn abruptly

#

It does so too

slow bobcat
#

quadrupeds do not turn abruptly, that's in your favour. The right to get bits and pieces of reality when it fits you XD

ocean wren
#

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

summer hazel
slow bobcat
summer hazel
ocean wren
#

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

summer hazel
ocean wren
#

Watch how a dog does it for reference

summer hazel
ocean wren
#

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

summer hazel
#

I see

ocean wren
#

Think I spotted it in one of the sense/perception codebases

summer hazel
#

I can just make it myself right? Doesn't sound too tough

ocean wren
#

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

slow bobcat
# ocean wren Yeah, its called extrapolation, you basically extend its velocity forward in tim...

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
ocean wren
#

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

slow bobcat
ocean wren
#

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

slow bobcat
ocean wren
#

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

slow bobcat
ocean wren
#

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 ๐Ÿ™‚

chilly nebula
slow bobcat
#

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)
chilly nebula
#

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

slow bobcat
#

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)
chilly nebula
#

@slow bobcat what base class are you using for your uobject instance data classes? the BP node one?

slow bobcat
#

base class we use is just this
class UCustomStateTreeAITaskBase_InstancedData : public UObject

#

each task Instanced data class inherits from it

chilly nebula
#

pretty sure you end up with a f...ed up instance data store

slow bobcat
#

so far... this seems to work

chilly nebula
#

so you are returning the type of a uobject as a ustruct? .. what ๐Ÿ˜„

slow bobcat
chilly nebula
#

Im surprised this even compiles, let me poke at it

slow bobcat
chilly nebula
#

well, you have property binding problems so not everything works as expected ๐Ÿ˜‰

slow bobcat
#

@misty wharf tagging you because I saw this hack in your blog

misty wharf
#

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

summer hazel
slow bobcat
chilly nebula
summer hazel
slow bobcat
summer hazel
#

That's interesting

celest python
slow bobcat
summer hazel
summer hazel
slow bobcat
misty wharf
#

It was probably the MoveTo or the EQS task or something in one of its earlier iterations

vale storm
#

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.

  1. 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.
  2. 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.
  3. 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)

slow bobcat
#

sorry for the spam. I had to re-edit the image 4 times in a row

chilly nebula
misty wharf
#

Do you recall which module the tasks were in the earlier UE versions?

chilly nebula
misty wharf
#

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

chilly nebula
#

I'll check older experimental or tasks under StateTreeModule

slow bobcat
chilly nebula
#

Im discussing internally if this is something we support or not

summer hazel
slow bobcat
summer hazel
#

Thanks a lot for the help

misty wharf
#

Man, where did I see that UObject instance data thing lol

#

I'm looking in 5.1 and I don't see it...

celest python
#

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

celest python
#

comment implies it can be a uclass here sus

misty wharf
#

@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

misty wharf
#

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...

chilly nebula
sturdy phoenix
#

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.

misty wharf
#

ยฏ_(ใƒ„)_/ยฏ

#

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

ocean wren
#

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 ๐Ÿ™‚

sturdy phoenix
#

sound like i'm going with behavior tree, at least for now

ocean wren
#

Seems reasonable

chilly nebula
#

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 ๐Ÿ™‚

slow bobcat
slow bobcat
#

Any guess on why the categories are not properly handled when using UClass?

chilly nebula
#

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

misty wharf
#

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

harsh storm
kindred zephyr
#

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

misty wharf
livid scroll
#

I have a problem

#

none of this is working

slow bobcat
livid scroll
slow bobcat
livid scroll
slow bobcat
# livid scroll 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?

livid scroll
#

multiples

#

Some key things to note:

  1. im not using replication
  2. I've put a break point here on this task, and it didnt react
  3. all animations work perfectly
  4. ๐Ÿชฒ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?)
  5. 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 ๐ŸŽฏ ๐Ÿค”
kindred zephyr
#

Thanks, I'll dig into the code

livid scroll
#

Can't find what's wrong

slow bobcat
slow bobcat
slow bobcat
# livid scroll Hi

If the root state stops upon entering with the breakpoint, things might be running but you are entering root - idle - root indifinetely

misty wharf
#

This at least used to be a problem

slow bobcat
#

But the autostart doesn't care about that no? Or is there an call you still need to do?

misty wharf
#

Autostart never worked for me, I would hope it has been fixed but I don't know :D

slow bobcat
misty wharf
#

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)

livid scroll
#

still nothing

rustic flax
#

you sure you're not getting any warnings? StateTrees will report if there's e.g. a Context/Schema issue i think

slow bobcat
#

Ehat does the tree debugger look like?

livid scroll
rustic flax
livid scroll
#

im trying to add breakpoints

#

but i dont see anything being added anywhere

livid scroll
slow bobcat
# livid scroll whats a tree debugger?

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

misty wharf
#

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.

livid scroll
#

but I didnt get any errors whatsoever

low ferry
#

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?

chilly nebula
slow bobcat
slow bobcat
chilly nebula
slow bobcat
chilly nebula
# livid scroll Hi

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

slow bobcat
#

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.

harsh storm
#

I faintly recall the same thing

chilly nebula
#

@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;
};```
slow bobcat
# chilly nebula <@397712228435886091> I have a working example for you, but I needed to use a 5....

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)

chilly nebula
# slow bobcat Nice. Thanks a lot. I think the dynamic stuff will need to be supported (althoug...

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

slow bobcat
# chilly nebula btw I've been advised by someone on my team that its better to use AddStatic her...

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

chilly nebula
slow bobcat
bright timber
#

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.

haughty coral
chilly nebula
vestal briar
slow bobcat
#

I could always download the source code for 5.0 and check myself, but I'm trying to avoid that

slow bobcat
kindred zephyr
#

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?

slow bobcat
kindred zephyr
slow bobcat
kindred zephyr
#

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

#

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

slow bobcat
slow bobcat
kindred zephyr
#

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'

kindred zephyr
#

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

slow bobcat
kindred zephyr
harsh storm
#

@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.

chilly nebula
vestal briar
#

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

vestal briar
#

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

slow bobcat
#

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

kindred zephyr
harsh storm
slow bobcat
harsh storm
#

Oh - I don't use UE's git integration. It is...less than ideal.

#

git bash for me.

#

As God intended.

slow bobcat
#

I still can't believe people use anything but p4 with unreal (and here I am... 4 years suffering Plastic...)

harsh storm
#

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.

hasty turret
slow bobcat
slow bobcat
harsh storm
#

Because it is UE - I still need a bunch of space.

slow bobcat
harsh storm
#

One of my projects is 240GB

slow bobcat
harsh storm
#

Small for bigger studios

#

But for my operation - it is massive

hasty turret
harsh storm
#

Right now - Azure Devops gives the best bang for buck at a big ol' free

slow bobcat
harsh storm
#

Yeah

slow bobcat
#

Can't believe you guys didn't burn down your Internet providers the very moment data cap was even mentioned

harsh storm
#

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

shadow lotus
#

โ“ 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).

kindred zephyr
#

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

vestal briar
#

I can't remember what it was, but i've been perfectly happy with SVN for the last year or so

shadow lotus
# kindred zephyr State tasks should read from evaluators directly- just bind those variables in. ...

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.

warped tiger
#

What's the recommended way to play animations for different skeletons using smart objects? One slot per skeleton type? A ContextualAnimScene with multiple tracks?

crystal sequoia
#

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:

  1. 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?

  2. 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

shadow lotus
upper terrace
#

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

kindred zephyr
kindred zephyr
#

So if you want to store it that way, you can

final loom
#

Does anyone recommend any voice recognition software, for UE5?

slow bobcat
# upper terrace I want to know has anyone have ever made custom ai movement in blueprints? Like ...

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

slow bobcat
night robin
#

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

spiral bone
# night robin Is there some example of like a good quality good AI Behaviour tree and Blackboa...

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...

โ–ถ Play video
night robin
#

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 ๐Ÿ™‚

harsh storm
#

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

night robin
#

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

misty wharf
#

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

harsh storm
#

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.

slow bobcat
#

And don't forget Miezsko, the guy that actually did the Bt's implementation in unreal (among other things)

slow bobcat
# night robin like released production grade, efficient, good quality AI

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

harsh storm
#

Moving on to bigger and better things. The nerve of people.

#

(I love Mieszko though)

misty wharf
#

The M in Mass stands for Mieszko

near condor
#

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.

harsh storm
#

I know some games will just listen for the player input and do things based on that information.

near condor
#

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

harsh storm
#

I also know some will listen to an event everytime a weapon is fired from the player and do things based on that.

misty wharf
#

It's really a matter of what looks/feels "good" when you play it

near condor
#

That is why I want to avoid it haha, it is very easy to break it in games

misty wharf
#

having them detect it in some kind of more "realistic" manner doesn't necessarily make it so

near condor
#

especially games like elden ring

misty wharf
#

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

near condor
#

Hmmm how about the enemy perception component?

#

if it sees a projectile, curve chance to dodge?

misty wharf
#

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

slow bobcat
#

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

near condor
#

Thank you, both of you

harsh storm
#

Wooooowww

#

Just both

misty wharf
#

Duro got totally snuffed

near condor
#

๐Ÿ™‚ apologies, scattered at the moment, thank you too Duro

harsh storm
near condor
#

(phone, laptop, spotify, UE all dinging)

misty wharf
#

lol

near condor
#

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)

near condor
#

The off-center blue circle at the bottom is the equivalent of extra fingers in AI Gen images

slow bobcat
#

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

harsh storm
#

What AI is generating that for you?

near condor
#

Claude Sonnet

harsh storm
#

I've never tried asking AI to generate that stuff.

near condor
#

It's so good because it does it with markdown rather than generate an image

harsh storm
#

Do you just tell it to generate it in that format or something?

near condor
#

I tell it I want an html diagram

#

You can also have it do Mermaid charts

#

check that out too, I just found it

harsh storm
#

That's kind of interesting

#

Seems to be missing quite a number of things

near condor
#

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?

summer hazel
slow bobcat
#

That for dodge, for block shield it's decided upon impact

near condor
#

Thank you for that!

summer hazel
# slow bobcat What weird thing happens?

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

bold python
#

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)

misty wharf
bold python
misty wharf
#

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

night robin
#

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

slow bobcat
bold python
#

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

summer hazel
summer hazel
#

And the ai move to is placed inside my behavior tree

silent hamlet
slow bobcat
summer hazel
cyan sigil
#

Anyone have a link to a robust Rotate Character task?

#

Surprised it's not part of base engine.

gentle hamlet
#

state trees are so complicated bruh

harsh storm
#

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.

slow bobcat
# summer hazel Yeah but that's not the only ai move to I use. Maybe the ai is moving toward the...

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

slow bobcat
cyan sigil
misty wharf
#

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

slow bobcat
#

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

cyan sigil
#

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.

summer hazel
slow bobcat
#

But that function does look correct

summer hazel
#

If I do that with max walk speed in anim BP won't it be the same ?

summer hazel
slow bobcat
slow bobcat
#

Stop - turn - walk

#

But that said, setting the max speed to 0 will indeed stop the character I think.

summer hazel
summer hazel
slow bobcat
#

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

slow bobcat
#

@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

final grail
#

๐Ÿ‘‹ 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!

chilly nebula
# final grail ๐Ÿ‘‹ Hey everyone! I'm currently working on a personal project called Synthetic Wi...

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.

final grail
# chilly nebula For simulation needs, especially if you want to model needs (ie hunger, tired et...

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!

chilly nebula
# final grail Thanks a lot for the suggestions! ๐Ÿ™ I hadnโ€™t considered a utility-based approac...

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.

chilly nebula
final grail
# chilly nebula 50-200 is still considered fairly large, and the current actor and skeletal mesh...

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!

chilly nebula
# final grail Thanks for the heads-up! I understand now that 50โ€“200 agents is still quite a ch...

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

final grail
chilly nebula
final grail
chilly nebula
slow bobcat
#

Thank for the answer siggi

near condor
#

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

willow glen
#

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.

sacred bane
#

Has anyone worked on indoor/outdoor audio occlusion/attenuation for AI perception systems?

slow bobcat
#

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

sacred bane
harsh storm
willow glen
slow bobcat
# willow glen Thanks for answering. Navigation is static, one, rectangular volume, no invokers...

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"

harsh storm
#

Just do a trillion line traces and hit every cm of the navmesh. Easy.

slow bobcat
#

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);
        }
    }
}```
summer hazel
#

Hey there, when I use "stop movement immediately" does something happen to my behavior tree ? I mean will it keep running normal afterwards ?

slow bobcat
#

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)

slow bobcat
summer hazel
willow glen
slow bobcat
devout plume
#

@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

slow bobcat
devout plume
#

(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)

devout plume
slow bobcat
#

Let me boot the pc again (my good act of the weekend)

devout plume
#

Much appreciated, thank you!

summer hazel
slow bobcat
slow bobcat
devout plume
slow bobcat
#

Just to the validate functions in the class

devout plume
#

Ok cool, so you need to actually edit the engine, I was wondering if I was missing a way to avoid this

slow bobcat
devout plume
#

Heh no worries, thank you for taking the time to answer!

odd kestrel
#

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

summer hazel
#

I remember you saying that I could store somehow what the ai was previously doing

#

But how?

slow bobcat
slow bobcat
slow bobcat
remote magnet
#

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.

summer hazel
slow bobcat
slow bobcat
remote magnet
#

Cool, thanks, I'll take a look!

summer hazel
harsh storm
#

You can access it in either

summer hazel
misty wharf
#

fwiw BehaviorTreeComponent is the BrainComponent if you're using it

misty wharf
#

Yes

#

BrainComponent is just the baseclass for the BT comp and also iirc the ST comp

summer hazel
#

Ok thx

summer hazel
#

As long as I have an actor or controller refference

misty wharf
#

Sure, same as any other component. I don't know what you would use it for in the anim BP though

summer hazel
#

And resume it afterwards

misty wharf
#

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 :)

serene fern
#

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

summer hazel
slow bobcat
serene fern
#

Just a bog standard actor class which i just do get actor of class with

slow bobcat
misty wharf
#

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

slow bobcat
#

Ah right

#

Duh

serene fern
#

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

slow bobcat
#

@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?

serene fern
#

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

misty wharf