#gameplay-ai
1 messages ยท Page 71 of 1
which plugin?
Dont you need transitions on fail/succ
well this is my released part of it https://github.com/KaosSpectrum/KaosGASUtilities/tree/main
I did Simple tree and ended with shitload of transitions to get it working right
but it doesnt have the full team stuff
Like default go up to root is going all the way outside linked tree
I was getting flack for using BTs when state tree exists lol, should I drop my trees entirely? is it stable enough to ship anything?
Just keep using BTs if it works for you
i use BT for most of the AI
but im using mass for tings
so i need to use statetree
BTs are great for single things per thing
I was thinking about some kind of tiered system where the normal BTs are used for moment to moment behaviors but higher order planning could be in an ST or something
ST is still highly in development
Red Solstice 2 we have like 700+ behaviour trees o_0
though most are deprecated/dev only
either that or try to adapt this for the organizer:
https://www.fab.com/listings/9a9f66b4-26f0-4a83-a758-3d8d4dd94ec5
Unlike traditional approaches which uses complex (and difficult to maintain!) behavior trees or finite state machines, GOAP NPC keeps game characters' behavior simple, efficient and user-friendly.Here you can watch a short video which showcases an example scenario with different behaviors, and some explanations about how to create your own.Goal-...
but I hear this is no longer supported
i mean depends what type of AI you are after
we did semi complex ai with BT's
but if they need to make descisions organically
then BT's are not the right way
BT's are great for "designed" flow
like X and Y and Z influences a decision choice
and that choice can be multiple things
then you need a different system to BT
I guess the ideal goal, no idea if I'll get here, but the best way to describe it is like this: being on the wrong end of a tactical shooter
if the AI needs to make smart decisions to evolving gameplay where actions cant be determined
so instead of being the one who gives orders for units to clear rooms, you're being pressured from every angle, flashbanged, and relentlessly hunted down
F.E.A.R. managed to smoke and mirrors this with excellent map design and good smoke and mirrors
imean you see ai in games and think that must be complicated
but I want something less... scripted?
but i guarentee its simple stuff just looks complicated
Yes and no
like
the end goal
is to feel like there is a command heirarchy to the enemy
and that commander is making intelligent decisions based on what they know about the player and their objectives
so there's macro and micro levels to this
we achieved this kinda using tokens (based on the Doom) talk
and a AIDirector class
but even if I can't make the higher order stuff work
I want at the micro level, for the AI to be able to form squads based on nearby friendlies and properly clear rooms with realistic tactics
without having to script all the movements on splines if possible
and be smart enough to heal each other and do covered retreats
well ideally you want an AIDirector to determine all the stuff, and then order the ai to do what they need to do (both for performance and single point of responsibility). If you want it even more organic then each AI need to do the decision making based on the information it gathers from the world and its target
also stuff like bounding overwatch
stacking and breaching
I know I'll need smart objects for sure
but for whatever reason all the smart objects tutorials are out of date for 5.5
I was looking at the doom token system in Ali's tutorial awhile back
but I wasn't sure if it would really meet my goals
I initially was looking at HL2's AI for the squadslot system to control who's moving and who's firing
maybe assign roles based on detection order
who is closest
observing the 4 Fs- have the agent with best visibility on the player/player's cover to suppress while other units flank/grenade
there's a flanking plugin but 5.5 broke it and I couldn't get it working anyway
lol
I hadn't looked into the director too much because I'm relatively new to the engine, decided to focus on emulating what I knew about existing titles and scaling up over time
trying to nail the basics first
All that complicated systems and average game has ai dumb as fuck
yeah, it's amazing that F.E.A.R. is still a standard to this day
or pecieved to be
but the big advantage those devs had was that the AI programmer was basically given the freedom to go nuts for an entire year with basically no intervention from management
and the game's design- tight linearity, the slow motion mechanic- meant they could sharpen the AI to be super hard but never feel too unfair because of the power given to the player to fight them
a lot of more modern games have open worlds, so the AI has a lot more variables to consider due to the massive amounts of space
and getting ideal decision making in a manner that is performant is rough
F.E.A.R. is pretty much remembered for the AI alone, because the world design is incredibly bland. Lots of dark corridors, offices, pump stations, abandoned towns
we have much nicer looking worlds but with the greater complexity, AI programming is that much harder to make the most of it
which is why you have shit like scavs beaming you in the face in Tarkov from 300m with a 30 condition AK through multiple tree branches and a thick fog layer
I guess that's why neural networks seem to be the focus for the next generation of AI tech- just have the program copy human players
I guess the best case there would be to have some milsim developer do a training tool for the military with real soldiers doing CQB drills, and then just train an AI with that data
While I can only go off 2nd hand info, I do trust the source, but I'd avoid using GOAP. Instead, favor HTN. It achieves the same stuff as GOAP but in a more designer friendly way and more performant. There is a wonderful HTN plugin that you can pick up as well. Really really nice.
If you search for GOAP from "Luthage" - she talks about it.
(in this channel)
It would take you far longer to build it yourself
Unless you only value your time at like $0.00001 an hour, just buy it
Yeah, true. I just don't want to be accused of making an asset flip when I have something I can ship
No one gives a care about that dude
They just want fun experiences
And this is code, not a syntyty asset
Fair, I just also want to learn about this stuff because it can prove I know how to do things which might get me hired somewhere
"I optimized my time to meet deadlines" or some dumb crap
plus I already bought a few assets already, I'd like to make my money back
Then just use BT's and ST's
What you described as wanting to do is perfectly achievable with the tools UE already has
Aaah you are using mass... Then I can't help sorry. Never used mass
Deadlock? If a task fails what happens is managed by the transition on that state. I think by default it goes to root
"that state" = the state the task belongs to
Hello everyone! I was experimenting with StateTrees, which look a lot better and more flexible after the changes from 5.4 and 5.5. I`ve watched the video from unreal fest and the quick tutorial they shared, and have a good understanding of the basics. But I can't find examples on how to do a couple of things on the C++ side of things. For example, how can I store state for a given C++ state tree task? for example, lets say I have a counter in a task that once reaches a given value, the task is completed and the tree can move to the next state. How can I achieve that (changing the state of a given task) in C++ if all the virtual methods exposed are const? Does anybody know of a good C++ example I can follow?
oh actually I think I found the example I needed on Tasks\StateTreeRunEnvQueryTask.h and Tasks\StateTreeMoveToTask.h
Hi guys can you help my out with my AI
This is how im updating my ai behavior,
https://blueprintue.com/blueprint/0jncb-xj/
this function is in a service that runs on my main node. It runs on tick
I would like help on two things:
-
how do i stop the AI from turning so immediately to the player
-
i don't want it to just continuously do the jump attack every time its far away, so any idea on how i can reduce it or something? I've already added a condition so its supposed to work only half the time, but ig because its a tick, every time the behavior tree goes there it does the checks it, so basically its being checked multiple times instead of just once is my guess as to why its always doing the jumping attack.
that literally was the design for the kind of AI FEAR had...
It's a day ending in Y and I'm working on enemies so of course navigation is broken for me again.
Noticed that my humanoid enemies would shove themselves against a wall forever trying to navigate to perfectly overlap their destination in some cases regardless of acceptance radius etc, so I figured maybe I needed to fix my navigation agents.
So I go set up one that matches the capsule of my humanoids, one for the capsule of my big things, one for the capsule of my little flying dudes.
And two of those work. The big guy is, once again, completely broken and refuses to move even though I can see his color-coded navmesh on the ground and debuf says he's using the right agent. So I try to tweak cell settings and stuff in the recastnavmesh that matches his agent, the usual arcane rituals where the best advice I've ever found, the most detailed explanation of what works and doesn't, is 'lol I dunno just keep changing them'. That got a result; now it refuses to even build the data. So at least the apparent result and the in-game result match now.
Ah perfect, the strongest arcane ritual of all: complain, hopelessly do the exact same thing for the third or fourth time, now it works exactly as it should.
But of course, one shouldn't play with dark rituals, since now it's everything else that refuses to move. And then trying to fix that made it so now both are broken.
if i return succeded here if (FVector::DistSquaredXY(AgentNavLocation, InstanceData.TargetLocation) <= 100.f)
{
return EStateTreeRunStatus::Succeeded;
} the other task is still stuck running
const FStateTreeTransitionResult& Transition) const
{
const FVector& MoveToLoc = Context.GetExternalData(MoveToLocationHandle).Location;
FDominanceMassFindNavMeshPathTargetInstanceData& InstanceData = Context.GetInstanceData<FDominanceMassFindNavMeshPathTargetInstanceData>(*this);
InstanceData.MoveTargetLocation = MoveToLoc;
return EStateTreeRunStatus::Running;
}
``` this task
Yeah because you return running
The first task finishes, tries to trigger a transition. It probably fails doing that
So your state keeps running
but that doesnt make sense
Because the other task is still running
cause my move navmesh should signal
Welcome to state trees
Can you give us more context?
You have a state with 2 tasks.
Task 1 finish quick.
Task 2 stays running.
What are your transitions for the state?
Ah yeah... That's not gonna work
They run in parallel mate
Put the task 2 in its own state as a sub state of your current one
State 1- grabs point
State 1.1- moves to point
I think in 5.5 you can do something like "this task doesn't run until X value is set from some other task", but I'm stuck in 5.4 so not sure
Is there a way to get AI to turn smoothly? My AI just snaps when turning.
depending on the specifics of how it's moving and turning, you'll want to poke around things like rotation rate and whether it's using the controller yaw/rotation/etc in the movement component
though you'll ultimately need animations for turning in place if you want that to look good
I use basic AI move to function comething with state tree. My AI is a character, I have these rotation settings
Its currently turning like the the right, but I wish to end up with something like on the left.
anyone knows why UE's detour crowd is not solving collisions ? (agents get into each others), i checked dDetourCrowd sample project and its not like that. ๐ค
If you group your tasks like that, they are both ruled by the same transition. So IF you have transitions setup for complete/succeed/fail they will be triggered according to the task that completes first
You said you are making one of them succeed so it should trigger a transition. Can you share the transitions you setup for this state?
Check the Catmul Rom Curve article I'm Wikipedia, there's an unreal implementation code snipet. In your path movement component, you can calculate a CR curve as you swap between segments, to smooth the curve
I'd also love to figure out very close pathfinding for groups of AI like this game:
https://youtu.be/zkmYOfKCKSE?t=439
I'm not sure how they pulled this off in the early aughts, I'm guessing that for the player teams they had four models animated with only one player controller and then just did a group health pool instead of calculating each individual soldier's route, but we have no idea how it works
Hello everyone, Monkiedude22 and welcome to another entry in the "First Minutes" series. This time I'm taking a first look at Full Spectrum Warrior on the Xbox One X.
There is no commentary in this video, but feel free to ask me any questions about the game in the comments section and I'll do my best to reply ASAP. :)
Follow Me!
-------------...
You can achieve the same in unreal using crowd control (your units will end up in a line) + assigning a destination point to each (like in the video) + a small delay in between units when starting movement (to achieve that distance in between each when they are moving)
Each soldier ca use its own path but, as Squize points below, you don't need to
They can 90% use the same path really
Yeah, you could calculate just the first soldier path and the offset the last point of each soldier after to their own end point
Hey!
I have an enemy that should attack the player from the side. I find that location using an EQS query and I pass it to a MoveTo node.
I want the enemy to follow if the player moves, but that seems to only work with an actor target, not a vector target.
I tried to use a blackboard decorator with OnValueChanged and AbortSelf but then the enemy just freezes.
The only other solution I could find is to spawn an invisible actor, I'm trying to avoid that because that sounds annoying to manage.
Any ideas?
Thanks!
Hey yall, is there a difference between these two noise nodes that report sound to AI Perception? Seems like I should use the non-server node (Report Noise Event) since it specifically targets AISense_Hearing, but I wanted to understand the difference.
I'm pretty sure the Make Noise function has absolutely nothing to do with AI perception. It might relate to the legacy Pawn Sensing stuff which you shouldn't be using anyway
They both work in PIE and standalone for AIPerception. The AI registers the noise using either node. I'm just not sure if in a packaged game it would make a difference because of the "server only" tag on the top node. Either way, seems like Report Noise Event is the one I should be using.
Ah you're right, it does seem like the make noise code is actually supported in the perception system
MakeNoise does check that it's on server but not sure if the perception system deals with that internally somewhere also. Considering I think AI controllers would only run on server, I think it probably would be taken care of with that.
(Obviously irrelevant for singleplayer games)
You pretty much discovered the "sad" truth: if you want fluent movement while chasing something that moves, it has to be with an actor
There's probably some way to update the movement target ๐ค
Dunno how you'd do that, but if you wanted to find out, you probably would need to look at how it handles it when your movement target is an actor.
Since it needs to keep track of its position, it would need to keep updating the location while moving... so similarly you could use something else if you dig deep enough into it
but I don't know if it's ultimately worth it... you can create some throwaway dummy actors for this purpose just fine, eg. kinda like GAS sometimes uses actors for targeting and such and discards them later
Sounds like an offset would do
But cant you just chase the target normally untill within some relatively large radius, then branch out on the side ?
Guess the follow actor node also just uses some timer to update it at some frequency
Can someone that pushes to unreal engine source code make sure this is included in 5.5.2, seems like they just forgot? Overriding Linked Trees doesn't work without it
bool UStateTreeAIComponent::SetContextRequirements(FStateTreeExecutionContext& Context, bool bLogErrors /*= false*/)
{
Context.SetCollectExternalDataCallback(FOnCollectStateTreeExternalData::CreateUObject(this, &UStateTreeAIComponent::CollectExternalData));
Context.SetLinkedStateTreeOverrides(&LinkedStateTreeOverrides); <===== Not in 5.5.1
return UStateTreeAIComponentSchema::SetContextRequirements(*this, Context, bLogErrors);
}
There's nobody active here who has that kind of access... You would probably have to make a PR on GitHub and try to ping relevant people there and hope for the best
Damn that's pretty sad
Yeah that's what I ended up with for now just to keep moving
One day when I grow up I'll make a task that does it with a vector
I pretty much just ping Mieszko on github. Pretty responsive.
Looks like they already removed the override in ue5-main 4 months ago, but it hasn't been included in release. if it uses super it's all good
Ha, I ran into override tree not working before and didn't investigate it further. This answers my old question
I'm a bit outdated (5.4) in terms of state trees. What's the state tree link override for?
Allows you to override a linked state tree that is inside of the state tree asset
Pretty much - programmatically set the linked state tree asset for a particular state in the tree.
Ah nice. Makes sense. We are about to update from 5.4 to 5.5.1 and I'm sacred. We have a good bunch of custom state tree stuff... Wonder how many things will stop working....
it is such a important feature for what I need to do but unfortunately its not available
I am trying to make zombies move to and attack the player in a loop, but it seems like the zombies get stuck in a move to and just pause, this either resolves itself after x seconds or if i enter the attack radius, if anyone can help that would be appreciated thankyou
i am running a linked asset
this is the debugger
i dont know exactly why its getting caught up in the move to but here is the transition logic
it doesnt do it with my other zombie type just the melee zombie
Isn't it that zombies are getting stuck against each other? Is your movement query returning Blocked by any chance?
im not sure how would you check that?
potentially whats going on because my proxy targets are close to the player
in this instance after 20 seconds they started moving to the player again
Visual logger shoudk show it I think
how do you get to it, it was normally under window - developer tools- visual logger but i dont have developer tools
nvm they moved it i got it
ok i think this may be useful
i think i got it
one sec
ok i think i fixed it, i just increased the distance check from 85 to 350 and that seems to have worked
thank you for the visual logger suggestion
Hello Everyone!
Encountered a problem that BB Decorator act like "On value change" than "on Result change"
just for testing, I built on clean project, Simple BTree with selector and BlackBoard float decorator "Greater than 0.0" notify observer "On Result change", abort "lower priority" followed by custom task (just printstring value of bb entry) that always return "Fail", and lower priority task (just "wait"). When I change value of Bboard entry in >0 range (result of decorator check not change - pass) its trigger abort lower priority task.
Is it bug, or I just do not understand "on result change"
I run into this problem in main project and its break my logic. Thank four your Time!
video how it acts in real time
updt. U.E. version 5.51
Decorator "notify observer" acts like it "On Value change" and not like "On Result Change"
Not sure ai follow but to clarify:
- on value change: when the value changes, even if it's the same number as (0 to 1 returns true, 1 to 1 returns true)
- on result changes: when the evaluation actually changes (different value from previous check).
Now you say you change your value from 0 to 0 it passes trough and aborts?
yep, on same evaluation result (pass), but with different values (anything that satisfies the conditions) it still abort low priority task.
Example, 0.1>0 pass, 0.2>0 pass (same evaluation result ), and its trigger abort
But... I don't get it. That's right no?
You are asking "if my value is bigger than 0, execute the task below the decorator and abort the lower ones"
You are passing a 0.1 and a 0.2, which are bigger than 0, so the decorator passes and aborts the lower prio
What am I missing here?
Not sure what you mean by "on same evaluation result (pass)"
Guys a little help, someone knows how to debug the sight in AIPerception? I dont see it in the Viewport
That's right. The result is changing, so the decorator pases and aborts. As soon as it's bigger than 0, starts evaluating to true, aborts lower, runs task
You keep moving the slider in the background and the number changes. The decorator evaluates every time the value of that variable changes (short of a listener) and runs the test. If the test result changes, it passes, what I mean: at 0 and below the result is false, bigger than 0 returns true. If you let it set at a positive number for few frames, does it keep retriggering again and again or not? I expect it does if it re evaluates on tick too or just when there's an bbk change event. That I'm not sure
I will check it right now. I will set positive number, delay 0.2 and set another positive
I would do it manually since you have the slider. Set some random positive number, observe the tree for a bit, change it again to a positive.
Then to a negative and see what happens, if it triggers or not
still, every time I change value in positive range its trigger abort, in negative or 0 it do nothing. (so result of evaluation changes from pass to fail and it is do not trigger abort)

also try to play with tick interval of evaluation and task, all same
at this point i need confirmation that I'm not crazy))
So it only triggers once, the first time the value changes to positive
no-no smae result. Triggers every time value changes in positive range
0-1 true, 1-2 true, 2-0 nothing.
And 2-1?
triggers
If i change the condition (to lower than 0, for example) its triggers in the interval that satisfies the condition
"Hi, I think there might be a misunderstanding about what Notify Observer does (I still find it confusing myself). From what I see, it will always reevaluate and abort tasks as necessary when the value changes regardless of Notify Observer. What the Notify Observer affects, is whether the task itself should restart. So for example, if you would put a decorator on a sequence with Notify Observer to On Value Change, then whenever the value changes the sequence would restart itself, even if the Result of the decorator was never False. Whereas if Notify Observer would be On Result Change, then the sequence would not restart itself."
Answer from user "chrudimer" on epic forum, looks like he right.
Thank a lot Bruno, really appreciate your will to help, you are a hero!
I feel like I'm doing this very wrongly, and just completely lack the understanding of the AI system 8-)
Using the "CanMove" to block the entire tree while the task executes
otherwise i seem to get weird behaviour.. but surely this can be the way to do it
extremely simple tree, in a turn based setting
Should be able to stop the tree by getting the brain component on the AIC and running stop
But is this really the way to use the tree?
feels like im using it the wrong way and just forcing it to behave
Right
If the attack hasn't ran "Finish Execute" then the tree will be stuck on that task
untill some timeout happens, it seems
e.g. if i never call Finish Execute, the BT seem to be destroyed
That's news to me
(unless that's just a bug, with it not showing in the instance list)
I've ran this pattern in many games. Haven't encountered that
hmm alright
Putting the gate on that selector like you did shouldn't be necessary
It's probably the rest of my logic that makes it bug out then
Could be
my turn system felt robust untill i started using BT ๐
then it all became this fragile little thing, often getting stuck
unless i block it like now (or stop the brain), but that just confirms my feeling of doing it wrong then
Well, something else may be interfering with things.
Without more code and explanation - can't say really. But that pattern should work
Its a cobs web right now so I'll save the details for later I think
Also - are you sure BT is the right thing to go for in a turn-based game? ๐ค
Well .... ๐
I was gonna roll my own
because it would be dirt simple
but I keep finding excuses not to touch BT
That's fine
and thus wanted to give it another go
I would probably reach for ST for most turn based games
isn't that still beta ?
Though you could use the BT as a way to handle a units full turn
not that that matters heh
It really only became an issue once i introduced multiturn actions ๐
made me go from "fire and forget" actions to "fire and retain state untill done" actions
You could still model that in the BT to be honest
that's sort of what I tried with the CanMove blocker (which really is "HasTurn")
I'd just turn the BT off when it isn't their turn.
Then when it is, turn it on again
Yeah
On the very first branch - check if they're doing a multi-turn action, if so, continue it, if not, go to the next branch
The action itself should be on the unit, not in the BT imo
yeah it is in the unit
unless you mean even more abstract
The BT is the Action selector , as i see it
it checks and decides on the most viable action
Yeah, makes sense.
I'll go for stopping the brain as you suggested tho
it sounds more in line with what i want to achieve, without blocking it with endless updates left and right
I'll stop it between a mutli action turn aswell I think..
So its just a "Pick the best action" slot machine
Pretty much
and the state for the mutliturn action is retained in the unit, so if that's ongoing, i'll just not boot up the tree at all that turn
Should be fine.
ty for the feedback!
Is there a way to get a specific actor with the smart object component, check if it's been claimed, and also be able to manually claim and unclaim/free it without using the querying?
Hi guys
Wanted to ask is it possible to change value of "Tile Generation Radius" in NavigationInvoker in blueprint during runtime? I tried to drag invoker from components and search inside it for this but couldnt find it.
Check the C++ to see if it is accessible. Because from that, doesn't look like it is BP exposed.
GuYs is this enough to stop evaluating BT? I see debug white lines still flowing
Yes that will stop executing the tree on that controller
Is there a way to generate around friendly units? I'm trying to make a task for a soldier to path to his friend's current position and take cover from the player near that location. I tried to use ActorsOfClass and OnCircle generators for this test but I wound up with a weird test that seems to just generate on the edges of the available navmesh. Not really sure how to go about this.
Distance between 0 and 0?
even when assigning values it does nothing
Iโd say turn off each test backwards sequentially to see if a particular one is causing the issue
Hm that doesn't look like a successful result
But i don't understand if you have troubles with this or with generating points around specific "friendly" units
Also i see you have another generator in that query graph...not sure if related, depending on what the problem is
repeating this question I asked to no response a few weeks ago since I'm considering a move to state trees or state machines before I start polishing the ai for the enemies I currently have
Maybe a weird question with no good answer but 'keep at it', but who knows...
Which of state machines/Behavior trees/state trees is easiest to remember or has the most convenient debugging or transparent operations?
I find myself coming back to BTs after a while to work on something new or because I noticed a bug and it can be...challenging, just refreshing on how my own stuff works or figuring out why something is happening even when I know roughly where to look. It doesn't feel particularly intuitive.
It's a hard question. What's a transparent operation? About debugging i think they both have good tools available. I find it actually easier to debug state trees but I bet my ass someone will disagree with that.
The thing is, the answer depends on what you are making (and maybe you can share a specific case and get help on that) and what you yourself find more intuitive
I guess I'd say my enemies are mostly in the vein of what you'd see in a soulslike or survival horror game (depending on the particular enemy)
relatively simple, don't need to do much thinking outside of their interactions with the player (if they're going to sneak around and do something clever, I'm much more likely to cheat by scripting it than try to have them figure it out)
for that, I'd imagine even blueprint scripting is on the table
Souls like is quite more complex that a generic survival, zombie-like thing. The stuff that goes into npcs selecting an action during combat in souls is quite involved. But if you just want a high level "Guard" behavior (patrol-investigate-attack) you can do it with both. I personally find it simpler to think about it in states so state trees are more natural for me in that sense.
yeah, soulslikes are closer to what I need. I've been spending a lot of time just picking apart what behaviors trigger what actions in fromsoft games
it's kind of interesting to see that, say, a generic hollow in dark souls 1 will just keep swinging forever if you do this, but if you do this it will back away but if you do this it will sidehop, etc., and figuring out not just what they do but why the programmers would want them to do it.
and comparing what they've changed in their base enemies across games (some of them are almost identical but bigger, with larger weapons, and (near?)-infinite rotation on faster attacks)
my game is first person and controls pretty different, so it's not like I can just crib stuff, but it gets me thinking in the right directions
Yea but man that is not easy feat. They use some goat inspired system and do utility scoring on potential moves based on a lot of factors. Unless you're down for a proper challenge id think of something simpler ๐
Lol, goap
Maybe they used goat for the capra demon tho
yeah, I'm definitely aiming more for 'make it seem clever' than 'make it actually clever'
This gives you a high level view of what they are doing there
How do you show the green nav mesh and what does it mean if no green shows up?
Is there a way to retrieve all the EQS points?
I dont want to filter any of them I just want to get all the points that are generated by it
I think if you disable all of the tests and then load the query into the EQS testing pawn it should show you an unfiltered set
Look into Infinite Axis Utility AI + stacked behavior trees or Reaction Bt's (game uncovered ai vol.1 book has both articles). You want to have an AI that can detect when to block, parry, get stunned. You will benefit a lot from having utility AI to weight your decision making (for things like move sideways, approach target, move away, run combo sequence etc)
There's no goap really since there's no plan building, but more "run X subtree based on this conditions", which is what utility will give you. You can download hacked versions of dark souls where you can run their debug tools and see the AI's debug. Will help a lot
I'm failing to get points around a querier using EQS. I don't know what is wrong. I'm generating points around the querier. I have no filter criteria. I just want to get all the points. Here is what my blueprint looks like. I'm not sure what is going wrong here.
Here's my environmental query
Most likely the problem is you're trying to get them as actors
iirc that only works with generators that generate actors - the one you're using generates locations
Ah.
Ill try getting them as locations then
still no dice with get get query result as locations. The query status is fail anyways*
I have the actor I'm generating the query around extremely close to the navmesh where I want to generate the points on so I don't think thats an issue
๐ค
Hard to say, try using the visual logger since it should record more information about it
Maybe worth trying the eqs testing pawn and seeing if it works or not
If not maybe try turning off the navigation part of it and see if it has any effect, might help rule something out
Any idea how to get the reference to an EQTestingPawn? I tried using get all actors of class but no dice
uhh I think you need to make a new actor
and inherit from it
you just drop it in the level then and use it in editor, you don't need to do anything else with it and it should visualize queries
yeah Ive been trying to use the EQS Pawn itself
Ill try it this way with making my own BP and inheriting from the EQSPawn
darn still no luck
oh I bet I have an idea...
its probably because Im running it on beginplay for testing purposes and it cant generate the points around the querier because the land/navmesh hasnt been generated
woo
its working
Doing it on beginplay before everything was being generated + the locations thing too. Thanks @misty wharf
I don't know if this is a problem with AI or Animation but in the Content Example => Animation Physics Control level there is a Character supposed to walk through physical objects from target to target, but when you press play or simulate he doesn't walk anywhere.
This Guy
There is a navmesh on the map but it doesn't cover everywhere and when you rebuild the pathing what is outsie the displays disapears.
<@&213101288538374145>
honestly discord should just disable the markdown "ha ha change the link text ha ha" feature because it's not useful for anyone but scammers :P
Didn't they get backlash on that before even releasing it?
No idea
Not really an mp expert but if you're doing things that need to be synced with server multiple times per second I'm not sure how else would you imagine this to work when the AI contollers only run on the server
But yes you are correct in that the reason report noise doesn't work on client is because AI controllers run on the server and not on the clients
Ah, sounds like a reasonable solution
might be a ridiculous question but can you have transitions on root in a state tree?
LogStateTree (Error) BP_IslandPlayer_C_2: FStateTreeExecutionContext::Start: Failed to select initial state on 'BP_IslandPlayer_C_2' using StateTree 'StateTree /Game/Blueprint/Enemies/AI/EnemyIslandPlayer/ST_IslandManager.ST_IslandManager'. This should not happen, check that the StateTree logic can always select a state at start.
The reason I ask is because I thought the state tree automatically enters root and I can make it sit in that state till I trigger a transition with an event..
here's what my tree looks like not sure why it cant select root from the start
iirc the tree can't just enter a parent state, it needs to always enter a leaf state
so in your case it has no valid leaf states to enter
this is probably solvable by adding an extra "do nothing" state into root which is the one it enters by default when nothing else happens
and you potentially want to add a wait infinitely task into it so it doesn't just keep entering it repeatedly every single frame
Yeah I managed to get that far. Is there a reason a tree couldnt transition when I send an event though?
sec sending an updated screenshot
managed to revise it to something like this
what Im trying to solve is that I have an EQS query in my get build point nodes and it keeps triggering over and over. I thought I could just get all the points from the EQS query then transition to CheckPointsAndBuild
Well most likely if you get the error about it failing to select something from root it means the tree doesn't really start, so if you then try to transition it obviously wouldn't work
Yeah
Yeah so this is something that you would think is possible, but it doesn't seem like that's how it's intended to work
You can't be in a state that contains child states without activating at least one child
So if you wanted to have the EQS in the parent, you'd need a "waiting" state as the first child
so would I just have to "try enter" that get build points node for the selection behavior? My understanding is try enter wont try to force you to transition to the leaf nodes
With your current structure if GetBuildPoints is entered then it will either enter CheckPointsAndBuild or not enter either of them because it can't
ah okay so I'd need a child state of GetbuildPoints then I'd go to CheckPointsAndBuild?
man this is confusing haha
Yeah not sure what the big idea was with making it like that. It makes it hard to do what you're trying to do
I think I might just write this not using a state tree... I could just grab my EQS points, loop through them and test to see if I can build buildings.
It seems overly complicated to just try and do this simple thing
or maybe I can do something clever and skip some steps that are annoying to do in the tree
well thanks again @misty wharf really appreciate it
np
The way I found it easiest to approach ST with making states is...just don't have child tasks for the most part.
lol
So, something like this. The parent state could have stuff that the child states of it needs. But the actual overall state is just under that parent, but the children of that parent don't have children of their own really. (Using 1 as the example here)
For the most part though, the parent is mainly just for grouping logical states.
Yeah
It's just kind of a pain in the ass to set it up so that one state pulls some data and a second state uses it because sibling states can't bind to each other
And also - don't really have multiple tasks on one state
Because that is a headache as well
I would say only do it if you need stuff running in parallel. But don't have them rely on each other.
hi i just wana know if this is a room for genrative ai or is the npc ai kind of ai
Game AI. Generative AI is #generative-ai
oh thx ๐ ๐
yeah I thought of going this route. The whole data binding thing left me sad though
Hey everyone, can anyone explain to me why adding a child state to a state breaks my logic in state trees? For example this works fine with these two states as sibling states.
but if I add them to a group or make them a child of one or the other the logic no longer works.
im trying to find the right set up to transition to a state using an event and payload and have each sibling state be able to bind that payload
(also I realize that I didnt move the payload event to the "Group" state in my example above, but I did attempt that without any luck.)
I'm trying to get my NPC to follow the player, so I created a very simple state tree with a state that uses the "Move To" state tree task provided by the engine. The first time the tree enters the state, it works. The problem is: if the NPC eventually reaches the player, it stops following them. I did some c++ debugging and I confirmed the tree is re-entering the state, the target actor is correctly set to the player and trackMovingGoal is set to true, but when the state is re-entered, the task status is already set to finish. I'm assuming the state tree task instance data is keeping the same move task instance for performance reasons, but doesn't seem to be resetting its state? Do I need to do it manually somehow?
Try visual logger to see what happens
Pretty good talk
anyone know how state trees evaluate event transitions in unreal? I havent dug into the code yet.
so far this was my idea of how it worked? Is this right?
If I send an event to a tree will it save it? Then when it gets to a state where that event is required to enter it sees that it occurred and says "Okay you're good, go enter that state"?
I'm pretty sure events are evaluated immediately
So if you are in a state that has a transition for that event, it gets triggered, but if you later enter a state with such a transition, nothing happens (unless you send another event at that time)
Events are consumed at the very beginning of the tree evaluation. If you then trigger another event as a result of a transition into some state, the event will be handled in the next evaluation I believe (to reinforce zomg point)
so if I send an event with tag from outside of the state tree will basically discard it? It needs to be in the actual state when I send that event?
you can add a transition at the root state as it will always be active, then it will catch it always, even if in linked trees
Ah a transition from root with that event?
all states leading to the state you are in are always active and can transition
so you dont need a million transitions to "dead" on every state you could be in, just put it in the root
then send the dead event and done
also any tasks placed in higher up states are active while the childs are active. so you could put tasks that listen for certain stuff in root and then trigger transitions no matter where you are.
for example, in a combat tree, you could react to incoming attacks (place the task at the root of the combat tree) no matter where in the combat tree you currently are
sick thanks
This is what my tree currently looks like. I have that construct building as a group and that tag as a required event to enter on GetBuildPoints
oh whoops I see root is a group.. that was an accident. Meant for it to be a state and have that as select children in order..
Any idea why root cant transition to get build points when I send the event? The tag is correct and I have confirmed I'm sending the event using my BP. I have an enter condition for it.
i've stopped using those required events to enter, i found them to be a bit buggy, triggering exceptions and what not. i would just put the idle above getbuildpoints and then transition from root to get build points directly, when done, go back to root, and then it will go back to idle
I'm trying to figure out how to block it from entering that GetBuildPoint state
I originally had another state above GetBuildPoints that had a transition with event
it cant enter get build points if root leads to idle and idle leads to root. except when the event fires
Hi Devs, I've got a situation where my Behavior Tree is not running on more than one AI Controller, not sure why that is happening. I can share the code here, Any help would be great .
There's no reason for it to not work... Are you sure you actually have more than one controller trying to execute it?
@slow bobcat by the way, are you familiar at all with AI systems in games like RimWorld, where NPCs need to perform tasks based on what's going on in the game world? I'm working on adding some stuff like that into my video rental store simulator for employee AI's and this is annoyingly complicated lol
Don't know the games, but if I get your description right, I would look into the World Conditions Plugin in unreal. It's an experimental new plugin that is meant for those kind of things. But since you have one of the few articles online about it... I guess you already tried it? Maybe if you explain in deep your biggest issues, we can try to figure out something?
what kind of tasks do they need to perform?
yes @misty wharf , there are 2-3 controller i'm spawning, however BT is only working properly on one of them :/
I've made a custom task to print the name of the controller when the task gets finished, and the log is only printing for 1 controller, for others its not working, however in the BT it shows the its stuck at first task .
I'm stuck at this issue since days, don't know what side i'm doing wrong, any help would be great
The tasks themselves are not that tricky, they would generally pick up things and put them elsewhere, or do some other kinds of interactions. F.ex. pick up a video, rewind it, and put it on a shelf. The complicated part of this is what happens if the AI can't finish the task, f.ex. because there is no shelf space.
My current thinking is that I'm going to have "task generators", f.ex. if a video is placed in a "rewind" box, there's a generator that then would generate a "rewind video" task for it. But at that point, I think it would need to validate whether this task can be completed, eg. check for empty shelf space. The task generator would probably also need to monitor the conditions and cancel/invalidate tasks it generated that are no longer possible to complete. If an AI is in progress of working on this task, they'd get an event telling them to abort the task in such a scenario.
Mostly just wondering whether this is a sound approach or if there's something I might be overlooking or not considering since I've not really built these types of systems in the past.
So it's only working for the first bot you spawn?
yeah, it randomly picks one of the pawn and works fine there, for the rest, the execution is stuck at the left most leaf
i added debug in the task , and it only runs for one of the controller. Let me share the task.
#include "Bots/Task/BTUnitTask.h"
#include "Bots\BotController.h"
UBTUnitTask::UBTUnitTask()
{
NodeName = TEXT("SampleTask");
bNotifyTaskFinished = true;
bNotifyTick = false;
}
EBTNodeResult::Type UBTUnitTask::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
ABotController* BotController = Cast<ABotController>(OwnerComp.GetAIOwner());
if (!BotController)
{
UE_LOG(LogTemp, Warning, TEXT("No AI Controller found. Aborting task."));
return EBTNodeResult::Failed;
}
float WaitTime = FMath::FRandRange(2.0f, 4.0f);
// Schedule a timer to finish the task
FTimerDelegate TimerDelegate;
TimerDelegate.BindUObject(this, &UBTUnitTask::OnTimerFinished, &OwnerComp);
BotController->GetWorldTimerManager().SetTimer(TimerHandle, TimerDelegate, WaitTime, false);
UE_LOG(LogTemp, Log, TEXT("Task started, will wait for %.2f seconds."), WaitTime);
return EBTNodeResult::InProgress;
}
void UBTUnitTask::OnTimerFinished(UBehaviorTreeComponent* OwnerComp)
{
ABotController* BotController = Cast<ABotController>(OwnerComp->GetAIOwner());
if (BotController)
{
UE_LOG(LogTemp, Log, TEXT("AI Controller Name: %s"), *BotController->GetName());
}
// Finish the task
FinishLatentTask(*OwnerComp, EBTNodeResult::Succeeded);
}
void UBTUnitTask::OnTaskFinished(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTNodeResult::Type TaskResult)
{
UE_LOG(LogTemp, Log, TEXT("Task finished with result: %d"), static_cast<int32>(TaskResult));
ABotController* BotController = Cast<ABotController>(OwnerComp.GetAIOwner());
// Clear the timer in case the task was finished early
if (BotController)
{
BotController->GetWorldTimerManager().ClearTimer(TimerHandle);
}
}
I'm not a 100% sure but to use delegates in this way you might have to make the task instanced
I would try to disable the spawning logic, and place a few of the bots into the level and set them to be auto-possessed by the appropriate controller... just to rule out any potential problems with the spawn code
or place them into the memory of the task (it's what I do)e
@misty wharf I can see the controllers which are running the behaviour tree in the list when I play it in editor.
This tells that BT is loaded for the Bot Controller
Now for the task, can you share me how can I make them instance ?
I understand that I'm stuck in a very generic problem, many devs try to run same BT for multiple AI Controlled Pawns and that should work straight away.
you pretty much described GOAP.
You need to build a plan to take a tape from the box, rewind it and place it on the shelve only if the shelve has space.
Then interruption planning "what if my GOAP has to abort?"
The Transformers games (War of Cybertron and the other) had very good GOAP systems. Maybe you can find a bit of info about how they did it
I can check the books I have at home and see if there's anything decent about GOAP or any other form of planners
Interesting, I'll have to look into that then. I wasn't really thinking it needed that, since it's fairly straightforward in the sense that they don't need to plan it, they can do it perfectly in sequence :) Eg. the task has the associated video with it, so the AI which took the task from the task queue just goes there, picks it up, then searches for a smart object with the rewind activity on it, and so forth. If at any point in this sequence the next step isn't possible to complete, it either retries or gives up
@misty wharf bCreateNodeInstance = true; helped. Thanks ๐
๐
you don't need to. GOAP is a very interesting exercise but getting it right takes time (plus, in my exp, performance tends to be a problem).
You could other approaches like a Utility System.
Basically you have a bung of trees to chose from: HandleReturnedTapes would be one.
- Reserves the space in the shelve (so nobody takes it)
- It grabs the tape
- Goes to the video and rewinds
- Takes the tape back to the shelve.
The Utility will add weights like "is there a pending tape? +1", "is there space in the shelve? +1", plus other weights for other options. Then you compute that and decide the one most interesting
We do something like that to pick combos/attacks, based on distance to the target, space around to move (obstacles) and other stuff
Mark is the guy behind the Infinite Axis concept, he has this but also an amazing talk online (trying to find it)
https://www.gameaipro.com/GameAIPro3/GameAIPro3_Chapter13_Choosing_Effective_Utility-Based_Considerations.pdf
ignore the mmo part, you can apply the same principles to smaller games
also this at minute 33
https://www.gdcvault.com/play/1018040/Architecture-Tricks-Managing-Behaviors-in
State Trees already have their own utility system
Thanks, gonna have a look at those. I'll look at some planner stuff also I think - I'm not sure if it's needed but I think it might give some ideas that could be useful at some point either way :)
There's also the slots approach, where each part of your stuff has slots (imagine if each step was some sort of smart object). If you can reserve a slot in each step, then you do it. The GameAIPro book (I think it's in the second One?), has something like that to handle a queue in front of an ATM, people watching a street performance etc
Yeah I'm using the smart object system with it so it could consider slots also. It's slightly complicated by the fact that some things like a shelf can be used from a number of slots, but for different purposes, and it would be kind of silly if a customer doesn't use a shelf to browse, because an employee at the other side of the store has reserved it to put a video on it
But I think the basic idea makes sense, it just needs to take into account these types of annoying complications lol
in those cases, you can always play dirty tricks like "employees access the shelf from the back, because them being employees, have access to that route", like how big super markets stock up their fridges (they have corridors behind them)
would need to have some level design changes but, sometimes, takes less time than re-inventing the wheel
I could swear it doesnโt work, Iโve tried myself
There really is something wrong with detour ai controllers because the avoidance just doesnโt work
Is it really broken ? I would appreciate feedback from anyone else who has tried using detour ai controllers
Yeah, these are something I'll probably have to play with and see what behaviors I don't mind. I originally had all NPCs block each other because you can't clip into other people in real life either, but I changed it so they can pass through each other because it caused too many pathing etc. problems :D
Crowd control doesn't prevent collision between character. It avoids them being stuck against each other if that happens
Yes this is what I mean, for example pedestrians walking and avoiding bumping into each other
Basic avoidance
Itโs not working even in 5.5
Whatโs going on
That's not what crowd control is for. You can tweak the readioues to make it look like it but, in the end, it's just collision handling. It doesn't change paths etc
In this video, I'll show you how to use the Detour Crowd Manager in Unreal Engine 5. I'll give a brief explanation on how it works, show you how to set it up, and show you how to tune parameters so you can get the system working with your game.
Here
This one
Crowd control (or RVO for that matter) is just a way to handle AI Agents getting stuck againat each other
Neither RVO nor crowd control is working
at this precise moment the collisions are being detected by crowd control and it's pushing characters away from each other.
https://youtu.be/spI6iDz2XLY?t=235
In this video, I'll show you how to use the Detour Crowd Manager in Unreal Engine 5. I'll give a brief explanation on how it works, show you how to set it up, and show you how to tune parameters so you can get the system working with your game.
I'm guessing you are following that guide step by step?
You need cmc for avoidance
RVO does more or less the same but doesn't care about NavMesh or Pushing your characters into cliffs or inside objects
If youre using pawn..
Iโll be fine with RVO as well, but whatโs the way to get it working ?
My pawn is using cmc
sorry, can't recall how you enabled it. I tried years ago in a game I was working on and dismished since it pushed AI's within walls and what not. You will have to do some google-fu.
But I'm curious, can you share a video where you show what happens in your game when using Crowd Control?
As of now I just have pedestrians walking around and they just walk into each other as if theyโre blind
Thatโs why Iโm looking for some avoidance method
but do they resolve the "walking into each other" problem and continue walking their way or do they get stuck?
Sometimes they resolve and sometimes they canโt
and if you enable the crowd control debug what do you see?
Whole point is I donโt want them to touch
yeah, that you can control a bit with the params of crowd control. I think there's a radius param you can tweak so it looks like the video you shared
Are you doing things exactly as on that video? because the guy writes some code tweaking stuff
there's always a bunch of stuff people choose to ignore when using this system.
All that is from this book
It's for ue4, but most of it is still relevant
I would also recommend reading about flocking behaviors and combine it with crowd control. That will probably will give you the best result
im not using CMC, i used dtCrowd purely myself and the problem is if agents are not configed to avoid each others, the collision solver wont seprate them either
Hello, anyone here with crowd expertise?
I need to create a crowd of 200 characters in Blueprint for a short film in Unreal 5.4. Currently, I have a pretty advanced crowd setup with Animation Blueprints, etc. Now, I need to add cloth via Chaos. So far, so good, but as soon as I have more than 5 characters with cloth, everything starts bugging out (causing lag, and the Take Recorder captures the lag). If anyone has an idea on how to fix this issue, Iโm all ears!
Another question: I have blendshapes for my crowd characters, with different morphologies. Iโd like to easily adapt the cloth to match the morphologies. From what Iโve researched, it seems difficult to do this directly in Unreal. I was considering using Houdini with a point deform, but if anyone has a workflow tip for this, Iโm all for it!
Thanks in advance! ๐
Cloth in chaos is extremely expensive in terms of cpu. That's why games apply it to 1 or 2 characters at once tops or just for small.l things here and there.
I'm surprised you can run 200.charactera smoothly, I'm guessing they don't use Character movement component etc.
To the match morphologies part, check Mutable. Epic bought them some time ago
One thong you could do is to make a build in development or test and run Unreal Insights in it, see what is expensive out of everything, see if that gives you clues about how to optimize things
thanks ! I will check that 
Can you cache the cloth sim? I know you can with niagara, I'm just wondering if you can do the same for the cloth. That way you could capture them 1 at a time. I've done it a few times by just take recording myself controlling individual characters and then replaying the capture alongside recording the next etc.
Bit like they used to do with machinema
There's some debug you can enable to show the samples used for avoidance and a few values you can tweak. Its been years since I used it, but it definitely did work back then. Much much better than RVO implementation, which honestly doesn't work at all really. Sadly my memory is vague on the details now, but I do recall having to derive from a Detour class for my character/controller? and ended up implementing a few extras for my own purposes (I wanted to be able to push other agents out of the way).
@ruby shard thus info might help you too
Hi, wonder whether someone can help as I'm getting pretty desperate. Has anyone come across an issue where Behaviour Tree Task keys are being reset every time the project is loaded?
Bools are set to default values and keys are reset to SelfActor across all my behaviour trees that are connected to a character - Strangely, if I copy a 'backup' version the keys remain so I can copy and paste it each time, but that isn't sustainable and is a ridiculous solution moving forward.
This is absolutely tanking my project and grinding all my progress to a halt, because I'm having to manually reset tasks whenever I want to play test
Like so
Potentially this has been fixed - By going into the problematic Tasks and doing File > Refresh all Nodes
I went through all my BT Tasks and did this and, so far, it seems to be correct - huge thanks to Kareem who originally posted about this issue a few months back with no responses!
are state trees better than behavior trees?
is one more optimized than the other?
State trees should be more lightweight than BTs, but it most likely doesn't matter for you
You're asking the wrong questions
when you said lightweight you mean easier to use than BTs?
No
Again - you're asking the wrong questions
For your game, will it be better modeled as a state machine or a behavior tree?
That is the question to ask
how would i know that? when im new to the whole state tree thing, im pretty sure im asking the right questions
No, you're not
anyway if you dont mind telling me, you can
How would I know?
I don't know what game you're making
I don't know what you're doing
It is your game
You set the parameters
Not us
ok so let me brief you
The state tree is just a general purpose state machine that does state selection behavior more like a behavior tree
AI with complex tasks, such as hide away from the player, interact with other AI
That is extremely broad
for complex and large coded logic, is it better to use BTs or STs?
ok then so i dont need to learn STs
i was worried i gotta abandon the BTs and move to STs
im sure somewhere down the long road ill have to, because there will be a particular feature thats only available in STs
There isn't
and then ill have to scrap the BTs
Well - unless you are talking about something like the property bindings (which takes place of the blackboard from BTs)
I see
Hello! We implemented a component to lerp an actor's position towards a target transform (e.g for when the character is interacting with a particular prop and we want to make sure that the interaction starts in front of the prop).
The component works by lerping between the component's transform and the actor's starting transform over a certain duration (the resulting transform is directly set with Actor::SetActorTransform()), and it works fine for player-controlled character, however when we use the component with an AI controlled character, we're having an issue where at the end of the transition the character rotates back to its control rotation: the transition ends with the AI character facing the correct rotation, but it slowly rotates back towards its control rotation.
A quick and easy fix is to set in the character's CharacterMovementComponent Use Controller Desired Rotation to false and Orient Rotation Towards Movement to true, but we were wondering if there any cleaner fixes?
Seems it would have to be either that, or adjust the control rotation
in what conditions do you use Pawn over character (or the other way around) for humanoids AIs ?
in my case they would only be a maximum of 4/6 AI in the level loaded at the same time
since its a multiplayer project i thought that the CMC could come handy if i dont have the time for a custom networked system
Probably almost never? There's very little reason for it unless you're doing something where CMC just doesn't work and it's easier to make your own instead of extending/modifying it
For performance
One case that comes to mind is if you want your character to function upside down. At least last time I was playing with that it just didn't work with that kind of thing
I got 1000 optimized pawns on map pathfinding with 4ms game thread
I will benchmark vs character but last time I tried cmc it was reaaaly slow
I think that falls under "something where CMC just doesn't work" lol
But yeah performance can be one
There are measure you can take to improve CMC perf, like using NavWalking instead of PhysWalking but it'll always have some amount of overhead I think
Ah yeah that was my first first WTF when I got crowd avoidance working on pawn
and they ended up in air not navmesh
cmc is more advanced than I though
should have know, FLOATING pawn movment
thanks for the insights
Anyone else getting crashes in 5.5 if running in editor with a state tree open? It looks like something in the debugger is messing up
Can you change a State Tree Param from outside the state tree (lets say in the AIController)?
UE 5.5
I did have states dissapearing on PIE and unsaved tree
does anyone have an example of a working 5.5 state tree that uses a smart object? I cannot for the life of me get it to work... I get all the up to the point of claiming the smart object but the State tree thats attached to the smart object does not run. Any suggestions?
I continued work on an older project and can't remember how to debug this when the behavior tree is doing this... please point me in the right direction ๐
There must be an error somewhere, but where?
You can usually step through a behavior tree (similar to BP) to examine whats happening. My guess for the jumping (assuming that is the problem) could be one of the decorators as they abort lower priority, maybe also the eqs query since it does not continue past that node.
Thanks, it was the EQS
Does anyone know of an easy way to extend or create a decorator for cooldowns that takes a blackboard key for the time? Its nice that UE provides a cooldown decorator, but no idea why they wouldnt let you pass a key for the time.
If anyone else stumbles onto this, I just made a decorator child class of the Cooldown decorator and then on CalculateRawConditionValue I set the value of the cooldown float from a key then call super
is there a way to get which stimulus was forgotton off of OnTargetPerceptionForgotton?
you should just be able to make your own custom version of it? but what you want to do seems exacly like the cooldown decorator
I want to use the Lyra Starter Game Template in Unreal Engine. I have added a drone, and I want it to shoot at Lyra's enemies using AI any one help me
ummm you are asking a question that is way too broad. Kinda "how do I make AI?"
First steps would be to have a design.
- how does the drone move?
- can it fly? should it path (nav path) its flying route?
- What's a target for the drone? how does it choose it among several potential target candidates? Does it use perception (sight, hearing etc)
- what happens if the drone gets shot? does it die? do the other AIls target the drone? how?
- How does the drone weapon work? can it shoot up/down/left/right or will the drone move to align with the bullet trajectory (aiming)?
- What does the drone do if there's no target in sight?
Once you have a more or less good base design to start (you don't need to nail everything, just a base and then improve through iteration and testing while you solve unforeseen bugs/problems), decide what are you most comfortable with: Behavior Trees, State Trees or others (custom approaches you want to try or plugins).
Then design it.
Reading in between lines of your question, my guess is that you don't know much about making AI or behavior trees. There are lots of materials online about different topics. My advice is that, once you have your plan, start tackling each issue at a time: movement, target picking, attacking and so on
I might be wrong but, doesn't the callback trigger when all the stimulus have forgotten the target? as in "I can't see, hear or sense in any way the target"?
If you also check in OnTargetPerceptionUpdated, maybe you get a call there too? I'm not super sure
yeah the actors to forget are added if they don't have any stimulus
Yes thatโs exactly what it does, but I thought I could use it if a specific sense was forgotten, I found a work around though, when my stimulus of sight gets updated I have a timer of a duration that fires a sight forgotten function
I have patrol guards who wonโt agro unless you shoot them then they will forget you if they canโt see you, my workaround works perfectly
yeah you will have to play with that. In my experience, there's always an extra layer you have to add on top of the perception to control these types of things. That's why I'm not a fan of the perception component: it feels over engineered for the lack of features it seems to present
I like the base functionality for tracking perception but I combine that with eqs for more control
Hmm, poking around with State Trees again and was looking into the usual issue of "what if I want to get data but it's async"
The structure you would need for that is get data > use data, because you can only bind child state data from parents
so there is actually a mode that would allow the tree to only enter get data, without entering a child on it... namely setting selection behavior to "try enter"... but I have no clue how this is even supposed to be used ๐ค
at a glance it appears to do what you want - it will infact not try to enter the child state which uses the data until you finish the parent task... but as it enters the child, it still counts the parent as finished, which in turn... causes the child to immediately finish as well
Also, you can give the parent state a parameter. These can be accessed by all the children... so in theory, if a child could write into a parameter, you could use it to store data like this to be accessible by another sibling... but as far as I can tell, you can't bind an 'output' from a task into the parameter. So that doesn't work
Is there any way to adjust AI Sense Sight so that it not only "tracks" the origin point of actors?
I have a big vehicle, which I can hide easily behind a rock when the origin point is behind the rock.
Rear and front are very visible, but the AI doesn't get it.
Thanks, although I have no idea how to use C++ ๐ฆ
I can probably make it work if someone points me in the right direction. I have never used C++ in UE.
anyone mess with damage functionality for ai, lets say i shoot a zombie, what should the zombie do, obviously be alerted but should I make it try to find who shot it?
like search in an area?
not sure what to do and would to hear what others did
Wouldn't this depend entirely on how you want your game to work?
I think most games would probably aggro the npc being shot at but as said it would depend, eg. maybe you have a silencer on your gun or something
The pins on #cpp might have something to help get started
I second what zomg said. Entirely up to your game.
Ours have 4 states:
- idle: nothing happens
- caution: ai heard a noise, noticed something but not sure what. Go investigate
- found: state in which the AI saw the target
- combat: engaged in combat. Thus can be after approaching the target close enough during found or because damage happened (in which case we skip caution and found and go straight into combat)
I would argue you can skip found. We have it because we do some special anims, sounds, alert others and what not
yes 100% i know its completely subjective but i dont know how to start is what im saying, I already have hearing set up to where if it hears a sound it will rotate and wait for 5 sec then go over there and investigate, but im not sure how to approach the damage logic if im outside the hearing and sightt range
yea but what do you do if lets say a zombie gets shot with a sniper? run around franticly?
Well if you wanted it to f.ex. just aggro the player, you could look at who was the damage instigator, and set that as the NPC's attack target regardless of whether it's within LOS or not
yea I know but if the enemy gets shot from really far away I dont want the enemy to traverse half the map
just to get to the player
Then they don't do anything
Well then the question is what do you want it to do
Or just run towards some random position
In the direction of the player even.
Doesn't have to be the player
Not like you have a lot of choices here to be honest.
And you have to make the decision
i was thinking that but this is the first time im making this functionality and i honestly dont know, I understand its completely subjective, im hoping to atleast get a clue, thats why im asking
If it's a zombie maybe it can just lumber around at random, if it's a smarter enemy, you could have it calculate possible cover points from the direction it was shot from
So really it just all depends on how you want that specific enemy to behave
You're asking a game design question more so than an AI question imo
yea, maybe ill crank up the hearing range and when he gets shot, depending on the hearing distance aka if he heard that shot then investigattte the location, but if he didnt hear the shot then be alerted and move to another location
kind of both tbh, i wanted to gather input from more experienced people
just to get a general direction
It isn't. You're asking what your AI should do in X situation. That is pure game design. Asking how to get your AI to do X is an AI question.
but the question is related to ai though
I'm not saying it isn't
im not trying to ask irrelevant questions, but it seems like the more niche the question the fewer the resources, like for example Ai forgetting, there is no one talking about that, even though there is a built in actor forget event for the perception thats a general event that fires when it forgets eveything from an actor not a specific sense
and this question even that im trying to solve, which i do agree is like 90% game design, all of the subject matter is just general functionality, and for someone approaching this for the first time I just wanted some input on how to approach this
Most of this stuff really is just a question of thinking of what do you want to happen and breaking it down
It is possible that what you (or someone else) comes up with at first isn't going to work so you might have to try a few different things to ultimately find what works best for your game
100% agree, I dont play too many games which i think actually works against me so im not familiar with how other people are doing things
I think that can be an advantage also in that maybe you can avoid the most boring tropes lol
Or limiting yourself too much to what others are doing already
really? because my one friend who also develops plays a lot of games and he can come up with approaches based on the games that he plays, he got me playing The division to study the AI a little bit more
I didn't say your question was irrelevant
I hate asking general questions because its impossible to really answer them
I never said you did apologies for the confusion
Which is why you've received the answers that you have. We can generally help achieve most AI behaviors or point you to resources. But we need to know how you want stuff to behave.
Realistically, there are like what, 3-ish people who actually answer questions in this channel? Mostly me, zomg, and Bruno (where'd you go Luthage ๐ญ)
I suppose it depends on what you want to learn about it. If you think about the zombie example, you don't really need to know games or game AI to come up with solutions to it - you'd just think of what you as a player would think happens, or how you as the game designer want it to work... like, what would the expectation be when you shoot at a zombie? Would it pull out a gun and shoot back at you? Probably not right? This is something that you don't really need to play games to think of I think
yea 100%, and I dont even know what I want, because this is my first time messing with AI seriously so I was hoping to ask and create a spark/idea
like a domino effect
or an ah ha moment
Yeah... We all go trough this. Best advice? Whatever feels fun in your game. No clue? Play similar games and check what they do. You could make the zombie slap the guy next to him.
I would die laughing if I shot a zombie and it turned around and smacked a neighboring zombie.
funny
maybe ill add that as a probability
I think it could be a fun mechanic
Zombies are dumb so you know it gets attacked maybe it thinks whatever was closest to it did that
yea thats where I was getting stuck because since they are dumb do tthey just stand there and take it, but I have a better approach on how I want to structure it, thank you guys
appreciate the help
Most games just have them attack aggro the attacker, regardless of distance.
ima actually add the slapping functionality as a base, if he cant hear any sound he will wander in a location frantically 90% of the time, 10% of the time he will slap a zombie
ima record it and share it when its finished to hopefully get some laughs
what do you guys think? does it look like a slap?
Yeah
lol that's great
now make the other one slap him back and then they can just slap each other for a while
That's a great distraction tech. Low health? Need to go through and you have a sniper with few bullets? Shot few zombies until they star slapping each other and cross through (maybe you can reduce their sight/hearing radiuses while in slapping mode)
I tried to make my own flanking order but it's basically looping to execute constantly and using a cooldown in the BT can't disable self. Am I going about this anywhere close to correctly?
the tldr: grabbing the player's position or last known location from AI::Perception and adding on the axis, then generating an area around the new point to pick a random area inside to perform the move to with an available enemy in the level
the ideal version would be more involved, with checking who is closest to the point, prioritization based on remaining health and ammo of the player and enemies, etc.
Is this the right channel to talk about neural networks and Unreal Engine?
So basically itโs looping without any cooldown correct?
If so why not put a wait task afterwards then abort that section when finished
Running into a weird issue with StateTrees, I have an InitialState which has a transition to StateB.
StateB can then transition back to InitialState.
When that happens, once a task finishes in InitialState, I get a crash, with an invalid event struct
checkf(ScriptStruct == TBaseStructure<T>::Get() || ScriptStruct->IsChildOf(TBaseStructure<T>::Get()),
StateB has a required event to enter, with a set payload. That event is not emitted in between StateB -> InitialState, but when the task finished in InitialState and it checks transitions, it appears to transition back to StateB like it got that event, but it didn't, so it crashes with an invalid event payload.
Is this a known bug? Or am I doing something wrong?
I somehow was able to work around it, but attached is my state.
If VER-67 Dialogue has the RequiredEvent to enter, then I get the above crash, if I move that to Interacting instead, then I do not get the crash.
No other changes. And Idle will only transition to Interacting on that event, which it never gets.
Super odd, but at least it isn't crashing now.
In case you are using the Motion Matching template, and want to use an ai move system, check this
Has anyone else had this issue with random integers?
Iโm using a behavior tree, and calling a service that just gets a random integer in range and then sets the blackboard value.
Unfortunately, the first time itโs called it goes to 0. Each time after that it is random as intended..
Hello. Is there a way to figure out if an AI character is unable to reach a location using navigation? Here's my problem. In my game, AI characters can be tossed onto platforms and buildings which are not always connected to reachable objectives or other enemies. This makes them get stuck. What I want is a way to simply make them move forward towards the objective while stuck on such locations until they fall off the platform and are able to navigate using navmesh again. How could I achieve this?
You could use AIMoveTo and then on failure do a SimpleMoveTo. Essentially AIMoveTo will attempt to path find, and has output pins for you to determine the success of that move. If it fails, you can then do a MoveTolocation/MoveToActor on the AIController directly, with use pathfinding off, and it should just walk in a straight line
the move request (move ai) returns a result when done. Within that, there are two things, the result itself (success/failure/blocked etc) and a bool that will tell you if the path was partial (as in "I couldn't calculate a path all the way to the point, only part of it).
for platforms, the best way would be to place some nav links that can only go in one direction. Smart NavLinks allow you to do that
Remind me please, what is the execution order of decorators on a BT node? is it from top to bottom, bottom to top, or random?
Top to bottom, it's an AND operation
Another question regarding AI Sense Sight.
As far as I understand, it uses the origin of the AI Actor as start for the line trace.
Is there a way to modify this and use a socket location? (an aim laser socket in my case)
iirc there's an "eye height" it uses
ah yea, thanks, I remember. but no way to set a custom socket location, right?
Anyone know how they setup the Hit Listener in the State Tree Demo? I assume itโs setup so that it jumps to the โReactionsโ node when a gameplay tag event is sent to the state tree component. But not quite sure how they went about it.
I don't remember seeing one at least, but this is something that can be implemented using IAISightTargetInterface as well albeit it might be a bit clunky if you have multiple kinds of targets as it might require implementing the logic in multiple classes if using that interface for it
If I had to guess, it's just a task which binds some events to listen to when the actor is hit and then generates state tree events from them
Ok, thanks.
I implemented the "multiple check locations" part blueprint-only for now by using a simple BP with a sphere collision and set that BP as stimuli source.
Then I attach it as child actor to my main BP and just get parent actor in AI logic. Works quite well so far.
Heh, that's a clever workaround for it :)
We can fire off events with the โSendStateTreeEventโ. But wondering how theyโre binding to that in the global task. And what functions theyโre using to jump to that specific node when the event fires off from the global task.
Right - so you would probably bind the Context actor to the task, so you can then use that directly to bind the events. In order to transition to the node, you would add a transition to your state using the "on event" transition type. This could be on the root state also if you want it to happen no matter what state you are currently in
I'm not sure if send state tree event is easily accessible in BP's so sending those events might need doing it in C++ to get access to the ST component
Sticking the event on the root is a pretty nice workaround actually.
Thank you ๐
Well it's not really a workaround, this is how it's intended to work :)
What are some use cases you think for the hit listener if they could use the root anywho
What do you mean?
If you can put an event on the root it will listen for it and transition wherever you want it to
So in the demo whatโs the point of having a hit listener that seems to be doing something similar I suppose
Well just having the event on the root does nothing, so you need something to actually send those events
You could send them from the actor owning the state tree, but a task can also be used for it as in that example
Yeah but I mean the root and the hit listener are both listening for the event regardless of how you fire it off. I guess you can use the hit listener if you donโt want to use the send state tree event function
Ah
I mean the events the hit listener listen to are probably going to be stuff like On Actor Hit
so it listens for On Actor Hit and then converts it into a State Tree Event that the tree can then handle
(or whatever logic the game uses to determine when the actor was hit)
Yah thatโs what I was thinking
But yeah you could alternatively have the conversion directly in your actor, but I guess this approach centralizes all the state tree related logic and requirements into the tree itself, so it becomes a bit more composable without needing changes in the actor where it's used in
Hello.
We're trying to optimize our AI.
We've noticed that our bot's behavior tree code often spends too much time duplicating static objects.
The calls for duplication come from Unreal's behavior tree management code. Specifically, UBehaviorTreeManager::LoadTree - ln 282 (UE 5.4.3)
Is there a way to avoid this duplication?
First stop in improving BT performance would probably be to replace blueprint based nodes with C++ based ones and avoid instanced nodes where possible... but if you've done that then can't really offer any further suggestions to that ๐ค
I don't remember running into duplication being a problem when profiling them myself
What are the objects exactly? Nodes in the BT?
Sounds like what zomg said, that you guys use Instanced nodes all over the place
I think so. At least that's what UBehaviorTreeManager::LoadTree seems to suggest.
What do you mean by instanced nodes exactly? Do you mean dedicated BTree or BTree nodes for each individual instance (a bot in this case) ?
How do I check if that's the case, and how can I revert it?
Check if your nodes have the Instanced flag set to true. I think that every tree node made in Bp's is Instanced by default (since you need to save values as class members because you can't handle the node memory in BP's)
I can't find that flag anywhere. ๐ค
Anyone know what would cause a state tree to just stop? It's working correctly except for the fact that when it reaches the final state, the task simply executes once and then the state tree stops and does not return to root
Expected behavior: ST goes back to root after "Play Sequence" task finished successfully
Observed behavior: ST simply stops after executing the "Play sequence" task, does not return to root
BtNode.h
does the State tree debugger confirm the tree is no longer running? could it be simply it's stuck in the task?
Yes the debugger ends abruptly after the Play Sequence task is reached
I don't think it's stuck in the task because if I do "break on exit" it does hit the breakpoint indicating the play sequence task finished, but then the ST simply stops instead of continuing to loop
could be a bug I suppose
thanks! I see what you're talking about now.
any chance you have a global task that is finishing? If a global task calls Finish (doesn't matter if success or failure), it will stop the ST execution. I don't see one in the tree though, but maybe you have something somewhere.
I'm not sure, but the evaluator might cause the same issue, worth checking
ah wait... you have a transition to the State itself it the state fails?
That sounds weird and risky, as in you might get trapped in an infinite loop
Have you tried setting both transitions to root, just as a test?
It was indeed like that in the screenshot however I've tried all sorts of transitions, result is the same every time, ST just ends
They are currently both set to transition to root
on success or fail
and if you set a breakpoint in both finish calls, you can see it stopping right?
If you were using code, I would suggest place a breakpoint in StopLogic within the State Tree Component, to see who's calling it
Thanks I will try that, though "Get state tree run status" always returns "running" even after the debugger stops, so I'm not sure the actual brain component is being stopped
cpp lead me to the perpetrator. Apparently if you have "lock AI logic" enabled, which is the default value, it will pause the brain component when a gameplay task is claimed. Unchecked it and the state tree continues normally ๐
where are the state tree theme color list stored ?
i cant find it in the UStateTree class
nvm its in UStateTreeEditorData, now i wonder how i can subclass UStateTreeEditorData
because its made in UStateTreeFactory::FactoryCreateNew but without editing source no solution
You can make your own factory. I do that so I have my own state trees class generated from an option within the AI menu when you create a BP in content (right click etc)
Can I claim a smart object slot with a player controller? When I attempt to i get an invalid claim. Trying to allow a player to occupy a slot
Or have some rules on if the slot can be used? Like can I disable a slot?
you could try something like this to enable/disable slots at runtime, not sure if there's an easier way
If an AI has already claimed the slot, and I then disable the slot, would it reject the claim?
No idea, Ive never had to disable slots I just know there's a bool for it, might be worth trying
Awesome thanks, it did not reject the existing claim, but listening to the OnSmartObjectEvent delegate let me get when the slot itself was disabled, and then I could free the claim and remove the claim from my state tree evaluator, and send an event to the state tree to switch states, so overall I get the effect I wanted.
Player occupies the spot of a slot, I disable the slot, AI picks something else to do, player leaves, slot is available, AI sees it and attempts to use it again.
You should be able to claim them for players also, but if the goal is to make them unclaimable while the player is "blocking" them then disabling them could make more sense ๐ค
There might be another way to disable them through the smart object subsystem, Dilly's approach looks a little weird
That seems it would modify the smart object definition, which doesn't affect the runtime state I don't think.
Ideally I want to claim the spot, since the player is using it, the alternative was disabling the slot while the player is using it
But no matter how I tried to claim it (passing the playercharacter or the playercontroller) i just had an invalid claim, but actually I wonder if it failed because it had already been claimed by the AI controller, and I needed to pass a higher priority...
Which function were you using to claim it?
MarkSmartObjectAsClaimed
Hmm yeah I think that should work ๐ค
Visual Logger has extra info on SO stuff so it might have info on why it failed
I think it does..I think it was just I needed to pass a higher priority to my claim... just tested and I get a valid claim back. Oops
Did enabling/disabling the slot work at runtime? Would be interested to know if that actually works or not
It does disable, but it didn't seem to reject the existing claim, but it would make it so the slot did not show up as available when queried for an available slot/smart object
Is there an easy way to know if a behavior tree has ended in success or failure? This is for a single run BT. I know there's an OnTreeFinished but it doesn't really tell you if nodes successfully finished or not
Has anyone else had this issue with random integers?
Iโm using a behavior tree, and calling a service that just gets a random integer in range and then sets the blackboard value.
Unfortunately, the first time itโs called it goes to 0. Each time after that it is random as intended..
Is there any way to use navmesh in vertical planes ?
When using a smartobject behavior, is there a way to get the claimed slot? I want to rotate my actor to the proper slot transform before playing an animation and completing the action. The MoveToAndUseSmartObjectWithGameplayBehavior node doesn't point them in the right direction. And If I separate it out to a MoveTo and then a UseSmartObject.., then if the AI loses the slot, I can't cancel the MoveTo. But if I get in the right location and execute the behavior I feel like changing rotation at that time is appropraite, but I can't find any way to get the claim handle from the behavior itself.
Not 100% sure whether there's some builtin way to do it, but the one way I know of is to create your own use smart object AI Task in C++, and you can pass in the slot from there. Eg. compare to how AITask_UseGameplayInteraction works although that one uses State Trees instead of Gameplay Behaviors
Ah yeah thanks, I started down the path of rolling my own task, I think I've opted to store the value on the actor (like in a blackboard, but I have my own key/value system but essentially that).
Then in the behavior, I have the Avatar, and I can load the value from there to get the handle
Not by default. It not an ez thing in unreal I have seen a project where they marked the vertical assets and use it's collision to run an A* as if it was a nav mesh
In EQS, is there a way to score points on these rocks higher than on the landscape?
I believe you can make your own tests in cpp to score things better.
But one way to do it with the default EQS tests is to do a collision check for those rocks object type
You may need to make a custom collision object type for them specifically though
The method has caveats though, as you can only have up to 18 collision object types
And collision check queries can be a little pricey if you have way too many queries (the little circles)
But it's fast and easy to do
thanks, would that be the overlap test?
Yes
i got some soft object ref in my state tree task, when compiling i get an error:
Run Activites Task 'Run AI Activities Task': Level Actor references were found: StaticMeshActor_UAID_0250F2020200044602_1339681119, StaticMeshActor_UAID_0250F2020200044602_1355787120, StaticMeshActor_UAID_0250F2020200044602_1357147121. Direct Actor references are not allowed.
i wonder whats the workflow to reference actors in a state tree
Well you obviously can't reference a level actor from a state tree asset
That's the problem
I don't know why they haven't fixed the select actor dropdowns so they don't let you pick a level actor for cases where it's invalid instead of doing a validation like this though
The correct way to reference an actor in an ST is pass the actor in from somewhere else, or use an ST task or other method to get the one you want
why ?
its just a DA
and a soft ref is a path
well thats annoying, this means i have to split my system for my designers
What is just a DA?
the ST
Right - I mean in theory you could reference a specific level actor from a DA
But if you think of it in context, does that make sense? This would make it so that the DA only ever works in that one specific level and in no other
well yeah, because in my design the AI is in one specific level, and has activities
each AI has different assigned activites
each activities refs an actor
Is the actor the activity itself that it can then do?
maybe for interactable stuff
rn its just a target location
see it like patrol points
Right... the common solution to this is using something else than specific actor refs to identify things
Gameplay Tags are usually the thing used instead
F.ex. the smart object system uses gameplay tags for "activities" which you can then query from the smart object subsystem to find concrete smart object actors supporting that activity
You can pretty easily roll your own solution for it also without needing the smart object system depending on what you're doing :)
I'm currently using SO's in my project and they do work quite well, but I have some additional requirements that currently mean I have a secondary system in "parallel" which is a bit meh
Basically I need to know when certain activities become available or become unavailable, which isn't something the SO system can tell you in a clean way
i see
in my case the behaviors/activites are highly scripted
so a very dynamic thing like the SO system would not really fit
I don't see why not... You have your SO, and you specify what kind of behavior it runs when an NPC uses it
The behavior can be as scripted as you like
But it may require a bunch of fiddling around in C++ to get most out of it so YMMV depending on how comfortable you are with C++
idc about c++
i care about how much ill spend learning somethign new compared to make my own version
if i didnt have this actor soft ref issue i wouldnt even bother SO
If you primarily need a way to find activities for your actors... it's gonna be way faster to make your own solution I think
rn im thinking of having a WSS registrating all actors with component with a tag
The SO system can be kinda complicated but it does support additional things like being able to claim slots so other actors can't use them etc.
i dont need to "find" them, i know exactly the seaquence that needs to be played
the map is a house, so its relatively small and easy to "hardcode" the activites
well I mean "find" in the sense that you need to know which actor it is without a specific ref to it
oh yeah ill use GTs
And yeah WSS + actor comp which register with it sounds like a fairly good solution
the second biggest annoying thing is that it looks like inline stuff doesnt display categories
why does the State Tree AI Move To task creates a new move request each tick ?
for a static target location
Are you sure the state isn't being re-entered every tick? Because that doesn't sound right
Yeah if you have another Task that is completing the state then it will retry, but the normal AI Move To task does not re-trigger that state, so just double check that another task isn't finishing, and that no transition/events are being fired in that state or any in the chain
yep its entered once, then hits multiple times by breakpoint in tick
anyways, idc about it because im making my own, the main issue im facing is that i dont understand how the task end from the move req result
its flooded in the context tick stuff
i only have this running
i mean, the fact that the task ticks is expected right ? since its active
what i dont understand is why epic devs made it update (without exposing a param like "do you want dynmaic target")
The task can tick, you just can't mark FinishTask as that triggers the state end,
if (InstanceData.bTrackMovingGoal && !InstanceData.TargetActor)
{
const FVector CurrentDestination = InstanceData.MoveToTask->GetMoveRequestRef().GetDestination();
if (FVector::DistSquared(CurrentDestination, InstanceData.Destination) > (InstanceData.DestinationMoveTolerance * InstanceData.DestinationMoveTolerance))
{
UE_VLOG(Context.GetOwner(), LogStateTree, Log, TEXT("FStateTreeMoveToTask destination has moved enough. Restarting task."));
return PerformMoveTask(Context, *InstanceData.AIController);
}
}
There's why it creates a new move request :P
because you have "track moving goal" and the target is a location
just turn off track moving goal and it'll stop doing that
indeed
thanks
the state tree tick is so dense
hard to find what was somewhat linked between the task state and the nav req
Usually best to just start from the obvious spot.. since it was recreating it on Tick, I looked at the Tick function of the task and there it was :)
yeah i wasnt talking about that, i was talking back on how the AI async task "finish" event is linked to the task state status
Ahh I see
and this happens somewhat in the state tree context tick
but i just realized something, what's the diff between putting vars in the instance data and on task
Yeah not sure why they do it like that. They could just bind events to it I think?
all delegate in the task have a empty invoc list
instancedata can be databound via the ST editor, things directly on task are configurable but not bindable
afail
oh indeed
i dont really see why you wont put everything on the instance data
for future "just in case"
I'm using Landscape splines for my roads, now I would like to decrease the navigation cost on the roads, so that my NPCs actually use them.
I tried editing the spline mesh of the road, by:
- Setting it a dynamic Obstacle
- Setting the Area class of the mesh
The navmesh calculates fine and the roads have less cost than the surrounding landscape.
However, when I restart the Engine, I'm getting ensure fails from the SplineMeshComponent:
ensure(!NavCollision->IsDynamicObstacle()
And when loading in the level the road navmesh cost is messed up.
Is there any way to assign a navigation cost to landscape splines?
Am I misunderstanding what the landscape spline tool is for? It feels like a such a common use case to want to decrease the navigation cost for roads.
(UE 5.5)
How do you debug a sub behavior tree? If I open it, I can't see the execution flow.
Try opening it before you hit play
It says Inactive and can't find matching actors ๐ค
Am I missing something? Is it even being called?
Does it use the same blackboard as the parent tree? If not, that's the problem. If it does, look in Visual Logger, it should log what's happening in the tree
Yea, BB is the same. Thanks for the tip with the visual logger! Haven't used that at all yet, but seems very helpful.
I guess this is the problem, it's not even executed:
LogBehaviorTree (Warning) Failed to execute tree BT_FlyToStrafeLocation: parent of active node does not allow it! (BT_Enemy_Drone::Simple Parallel[26])
The parent is a Simple Parallel, why would it not allow it?
If I set Simple Parallel to Immediate, I don't get this error in the log, but it still doesn't work.
Not 100% sure but it might be that simple parallel only allows one single task in the left part
You can't put composite nodes into the main task... so you're kind of bypassing that by running a child tree, which might result in issues like this
But not sure, I don't really use parallel nodes myself
why are almost all virtual methods of the state tree tasks const ?
it feels stupid to const_cast to this
What are you doing that requires that?
Because it's a data driven approach. You change de data passed (context data) not the task itself. Although task tick is not cost I believe, you can handle Uproperties there
running some logic
such as AI move to
i understand that, but since tasks are "tasks" i dont see why i wont want to execute stuff from there
Why is it a problem for it to be const then? The builtin MoveTo one doesn't have const_cast
I don't think you should be storing stuff in this in state tree tasks ๐ค
in the task i only have some const stuff
in the instance data i got some runtime stuff
Right, so why do you need to const cast it if you're not mutating this?
sadly lots of laura's coro stuff isnt const
๐ค
wait
nvm i forgot bout that
i think i switched to not const for something i removed
How can i disable the "auto braking" when using a move to ?
By braking i mean the deceleration thag occurs when the AI is close to the target
okay its bUseFixedBrakingDistanceForPaths
Hey guys, I need some help with setting up this behavior tree.
I want the AI to move to three different EQS locations, then finish seeking.
I'm not sure how to set up the loop, currently it just runs three times and finishes.
I'd like it to count a loop as done when IsAtLocation was reached three times. Is that possible?
Or do I need a conditional loop and increment a variable in a task or sth like that?
Yeah just add new variable on blackboard and +1 it every loop, and before every loop check if its < 3 and decide it's smaller, continue loop, if its 3 then don't let the tree work
Is the AI Controller controller rotation used for anything ?
Im asking because changing the rotation of the controller wont affect the controlled pawn
if the pawn/character is set to inherit the controller rotation, it will rotate to face that direction
I have a strange situation with my BT getting stuck.
The target is dead, but my service BTS_StopAttackingIfTargetIsDead is not being called anymore (I added a log message to see if it's running).
As the target is dead, BTD_CanSeeTarget returns false obviously, which is fine.
But why is the service in the parent node above not running anymore?
If the decorator becomes falsy then the branch would exit, and since there are no other nodes within the parent branch, it also would exit
There should be a function you can override in the bts which runs when it becomes inactive, which you could maybe use to stop the attack if the problem is it isn't doing that
@slow bobcat
Coming back to this. If I identify the blueprint nodes that are causing these, would nativizing them to C++ get rid of the duplication overhead I asked about here - #gameplay-ai message
Do you mean ReceiveDeactivationAI? That works. It runs every interval and then once more at the end. So I'd have to switch from ReceiveTickAI to this one, is that a good solution?
Or I move some other task into the parent sequence, then it also works as you explained.
Yeah I would try that. I'm not sure if Deactivation should run on every interval though, so if it does that seems a bit odd
ReceiveDeactivationAI runs every interval for me, there's also ReceiveDeactivation, but that one is not running at all
๐ค
I just checked the C++ code for it, it should only run when the BTS runs its CaseRelevant logic
If it runs on every interval for you then that would suggest that your node is actually being activated and deactivated instead of remaining active
I think so. Before you do a mmasove re-format to c++, I would have a test ai level with one AI using a simple tree with just one BP node that shows that behavior in Insights. The port that node to c++ and replace the BP node in the tree and check again. Just in case I'm wrong and you just made a massive work "for nothing"
Yeah, I thought about that. We have several BTrees using many BP nodes. Its not sensible to nativize all of them.
I am thinking of logging the names of all BP nodes that are copied and try to match their occurence with the spike in the profiler.
Hey all, packaging question relating to State Trees, do we have a fix for packaging when using State Trees in 5.5? Specifically for the crash that occurs because it loses references?
Quick EQS question to verify I'm on the right track.
I'm trying to find locations behind my attack target. I guess I have to use the Dot test to check if attack target and ai pawn are looking in the same direction.
I'm quite confused by the settings of the Dot test though.
My result looks correct, the points behind the test vehicle have higher scores (if the ai pawn is looking at the attack target, which I'd have to make sure with focus target).
Can someone verify that the settings make sense?
Hmm, nah, it doesn't work like I want.
If I move my testing pawn to the side, I also want the points in the green marked circle to have the highest scores. Is there anything else than Dot test which I can use for this?
Flip cone 180 degrees for example so the points are on the back instead forward facing? Is that possible?
@upbeat hamlet inthink the problem is this. Judging by the second image (how you set the test), you are doing a dot between the querier rotation (box+arrow in the centre) and lines between the test point and the target (being the target the T at the centre-top of the grid).
I think you want to check the rotation direction of the querier vs the line (test point - querier)
That way, if the results is <0, it means the point is behind the querier
Like that
That gave me a point behind the querier.
I changed it to this now, which works. It should be independent of where the querier is.
Thanks, your explanation helped me solve it!
Aaah you wanted behind the target, not the querier. Sorry I misunderstood
Hey it seems like the perception system only looks at an actors location for visibility. So waist high barriers obscure their vision. Is there any way to modify this? I'm not seeing any easy way to override this behavior
In cpp yeah
Without changing the engine?
I donโt believe so. Canโt rmbr where the logic is within the perception component exactly but pretty sure it traces on visibility to the capsuleโs bottom or its half-height. If you search messages in this channel you will prly find the exact thing to change as itโs been mentioned before
Alright. I am seeing something I can override on a character that implements an interface. That's probably what there is to do.
Just always feels like the perception system is surprisingly a black box
This is very true ๐
Thanks for the help. Now that I've played around a bit, I've got a more general question.
How is both position and shooting direction usually solved for AIs?
My main problems that need solving:
Should be clear that an AI sees you and it makes sense when they do (i.e. they see you from their eyes/body orientation)
AI stops to shoot somewhere that makes sense (point is chosen with a line of sight to target)
AI shoots when it makes sense (trace is possible from gun to target)
Those are pretty fundamentally different traces with different needs.
My current plan would be a small modification of the base unreal perception system to do more traces (head and torso) to avoid sight fail when the target is half covered,
Line traces from locations I might want to shoot from to approximate that a shot is possible,
And a final calculation to determine how to rotate an AI 's aim offset so that it can properly shoot at the target wherever it is seen at.
I'm sure this is largely a solved problem in the industry, so I wanted to see if anyone here had something simpler or more efficient than this.
I am using an AIPerception to handle sight and sound but I want to add the functionality of a crouch mechanic to my game. I was thinking of somehow making the detection range smaller if the player is crouched. Can anyone help me figure out how I am supposed to do this because I am relatively lost on this?
The "standard" way to do it, is to cast rays randomly to bones with perhaps a bias to the extremities. They did this back what, 15-20 years ago. Easy to do in the perception system too
Obviously the effect aggregates over frames, but in reality you don't notice any delay and it feels more accurate. Thats what I did and I can confirm that it was perceptually from a player point of view "better".
I solved it similarly in a previous game. 5 traces to head, hip, each shoulder and knee-high (a point below the hip). If 2 out of 5 hit, shoot.
The aiming was done trough animation and rotation constraints. Upper body can rotate X degrees. If the character has to turn more than that, then rotate the body. Same with up/down (arms vs crouch)
Hi everyone, I have an actor which has a NavModifierComponent I want to modify navigation on runtime, I am able to modify the navigation on runtime but after few seconds I am destroying this actor and expecting to have navigation for the modified part but for what ever reason it removes navigation tiles and do not return them back! Runtime Generation already set to Dynamic Modifiers Only, But still I have issue, Unless I set it to dynamic then I have no issue, But dynamic is too expensive as processing cost, Do you have any idea?
Do you mean that you get a hole around your character but, upon destroying it, the hole stays?
Yes @slow bobcat I have no navigation after spawning the actor and after destroying actor I still have no Navigation, I tried different NavArea classes but result was same.
Ummm so... If you set the nav area in your nav modifier to Default, when you spawn your character, you shouldn't have a hole at all. Do you have a hole in that case? (asking to go step by step)
I tried default Now, I still have same issue with NavArea_Default, Interesting, I didn't expect this!
if you see a hole in the nav using default, something else is wrong. Only Null (or any other custom nav area that sets polys with flag 0) should create a hole.
If you try to remove the nav modifier, what happens? Just to confirm that's the problem (the nav modifier in the actor)
Ok, First of all thanks @slow bobcat , I have fixed the issue, The issue was because of NavMeshResolution it most be set to None, Then everything started to working properly.
Hi, Iโm having an issue with nav links in my level. The AI correctly uses the nav link to jump down from a cliff, but when I ask it to go back up, it ignores the proper path and instead runs into the wall where the nav link is located. How can I fix this so the AI follows the correct path back up?
@slow bobcat - Could you please help me understand what the problem is?
Why do BP nodes require to be instanced for each bot? Why don't the C++ nodes need that?
I am fairly new to this concept, so any help is appreciated.
afaik it's because of how the BP nodes get handled. It can't run BP nodes from the CDO, so it needs to create an instance of it
Okay, when we say 'create an instance', am I right in assuming that the engine allocates a new memory block to store the node's data for each agent/bot?
I would assume it must be NewObject()'ing the BP based nodes somewhere
- instanced: each node use is allocated in memory. So if you have NodeA in 2 places within a tree and 3 bots are using the tree, you have 6 instances of the node in memory. Which means 6 new Object calls have happened (I think this is what you see in Insights but I'm waiting for your confirmation)
- not instanced: only one instance per node is used ever (the cdo) and it's nuances (whatever changes in the particular use) is stored in its node memory (instead of in its class members like how a BP would deal with it)
Main problem is that the memory handling (creation of custom memory struct, save and load) is only possible in c++
This is the other half of the answer
For each node usage in every tree for each tree instance.
Hi @slow bobcat , I stopped engine I tried to rebuild the game for other reasons, After rebuil I realized I have same issue, Runtime Generation set to Modifiers Only and Even though the NavAreaClass is default it removes the Navigation tiles!?
But When ever I set the Runtime Generation to Dynamic I have no issue.
Hmm, that sounds like projects with too many BP nodes in their trees might have a serious performance problem.
Either way, I haven't yet identified the culprits causing the spikes in our game.
๐ค
Could you be spawning something when they occur?
Just makes me wonder why would it be duplicating stuff if you weren't - or running new behavior trees or something
<@&213101288538374145> might be a good idea to add a regex to block [fake link](real link)
..actually that one isn't even using it, just a regular ol typo in the domain lol
yeah ill get it added
stemmcommunuty desperate :/
I am glad you asked that, because I completely ignored that case. Now that I am looking, I can see something fishy happening.
Any idea why this is happening to my AI? Some information
- At the Tree it is going only to "Move To" (targe is my character)
- The capsule and other parts are not colliding with the table
- The navmesh (in green) shows a clear path between the tables
- The agent radius is 40 everywhere and the character radius too. (the capsule is not overlapping objects)
- I tried activate/deactivate Controller Desired Rotation and Use Controller Rotation Yaw
- The AI slow down near objects.
The navmesh seems really thin in between the tables, it looks like there is a large blocker around the tables. If you lower the collision mesh of the tables down to so that the navmesh is 40 units at least between the tables does it do this?
The way the AI moves makes me suspect it is at the very least related to collision. Have you tried disabling the table collision?
I have a question. How can I get the Ai to move and attack at the same time. Iโm using 5.4 so no parallel trees which sucks. Iโm doing a simple Ai move to and looping over a Anim montage on completed. But is there a better way to doing this?
I'm clearly missing some simple checkbox or something somewhere but does anyone know why my AI won't move if I get the navmesh to be "IsWorldPartitionNavMesh" in a world paritioned level? Works fine if I don't set that but not if I do. ๐ค
Custom task, you can use the AIMoveTo node, and additionally trigger your attack. It also allows you to make sure they are in range, aiming, etc, while the AIMoveTo is continuing to work, and have more control over when that task would be considered "done"
5.5.2 hotfix was released yesterday. I think some of you had this crash
UE-231892 A crash occurs when a State Tree Parameter is set to a variable type also referenced in a STT
seems to be fixed
Hello do someoneknow how i can add a ai stimulus source to an physics object blueprint? because if i add a stimulus source to the object when i hit play it only recocgnised the first position of the object instead of updating it?
Is the component which simulates physics the root component?
without the numpad how can i access to all categories
i try to find a command but nothing found so far
its basically a blueprint with a geometry inside and i has the Ai Perception stimulus source and it has physics enabled in the mesh setting (see picture)
If the physics comp is not the root like in your BP, then the actor isn't moving when the physics comp moves. That's why you're seeing this behavior
You need to make the component the root in order to make the actor move when it does, which should make the reported position be correct also
Perfect! thank you! +100 aura haha
its working
๐
uff yeah, working without a numpad in unreal is a problem. You can either use the emulated on screen keyboard in windows or change the keys that open those categories (it's within the editor preferences I believe)
Ah project settings yeah
Iโm a little confused on what you are trying to say, is it ok to dm? I basically would like a zombie to move to a target and if within a certain range, attack and move at the same time I tried a custom task but tasks only execute once and I need to continuously check if we are in range to attack
The size of the table collision is not important in this context. A thin navmesh will happen if the meshs are near enough.
The capsule is not even near the table, and the character mesh are set as "No Collision".
Just tried to change the table collision, they only collide to PAWN (so it generate navmesh) and it still happens.
collision don't seems to be the problem, at least looking from the editor with all collision showing there is nothing even touching.
If you place the capsule center at its feet in the middle of that narrow nav passage, I think the capsule will collide against the table. Will be easier to spot if you use the top-down camera
If that's not it either, it could be that your rotation can't handle that turn. If you stop, rotate, move might work. But if you rotate while moving, the curve might be trying to take ai out of the nav in that narrow place
Wonder if that's what happens
If you think its navigation, you can use the Visual Logger to see what path the AI is making.
I still think there is something strange with collision, but I couldn't tell you exactly without more debugging
I will take a look at this, my first impression was a collision problem, but I tested removing and decreasing collisions and the issues are exacly the same. I set the capsule radius to 2 and didn't change anything.
Is your capsule radius <= to your agent radius? Otherwise that will happen.
Inwoikd definitely check Visual logger if you haven't yet
looks to be calculating the navmesh correctly. It is possible to see the pathing?
I used the visual logger and this is what I got in repeat
In one of the frames, there should be a green line showing the path.
Show only the nav category. You are showing behavior trees and what not
You can right click on Navigation - > show only this (or hide all but this, I can't recall exactly)
I was able to show the blue nav but not the green path line
@mild quiver try to turn on also pathfollowing (and maybe ainav)
In none of the lines within the VisLog time line?
ok, now I understand the visual logger a little bit more, this is what I got from AI navigation
hmm it shows under Crowd Following not AI navigation
but the path is a straight line in red
Ok, I changed the AI from Detour Crowd AIController to AI Controller and the line started to show.
And the issue stopped, basically the following from the Detour Crowd AIController is making the AI stuck
it's super weird Crowd Control shows a path outside the nav when it can only use nav movement (as in movement constrained to the nav mesh)
The solution is reparent the AI from Detour Crowd AIController to AI Controller. So it uses the pathing finding on the navmesh and not the Following from the Detour Crowd
Thanks you all.
But why is crowd control not respecting the calculated path when your AI is the only one there? Makes me think there's something off. You can not use it of course, but you are missing the avoidance completely
yeah, with multiple AI it will be a problem for sure. For now we only have 1 per game. Now I know what is the problem I can try find a solution
Is there an easy way to provide query params to EQS contexts when EQS is run by built-in BT nodes? It seems like I need to subclass those nodes (task and service) and manually add "custom query params", because by default query params are extracted from generator and tests binded params, but not from context params ๐ค
I have AI and I have an item that I want him to approach, I have 2 floors, I don't know why, when the item is on the 1st floor he goes to the 2nd floor to pick up the item that is on the 1st floor
someone can help?
If I had to guess, the random location ends up not being on the navmesh and it ends up going to the incorrect place as a result. Try using project point to navmesh and see if that helps, if not, try to use Draw Debug Sphere on the locations to find out where it is and hopefully help debug it
Visual Logger also shows more information on navigation which can help figure it out
Got a really weird issue. I have this AI that's getting stuck in this state instead of moving onto the Attack/Pursuit branch.
Here's the weird part, I tried the visual logger and its not working because PlaySound node is... failing?
Now, I could theoretically move this to a simpleparallel or something so that a failure of PlaySound doesn't stop execution proceeding correctly. But like... it IS supposed to play a sound, and I don't understand how that node can "fail" considering the cue exists
Oh INTERESTING I think this is distance-based. When I approach the AI in question it suddenly starts behaving correctly
ai sight visulization not showing?
What AI sight visualization?
I don't remember there ever being one when editing these settings
Does anyone have an idea why my pawn is clipping into walls? It has a sphere collision set to Block WorldStatic and the wall is WorldStatic, set to BlockAll.
I'm using the MoveToLocation node in the BP. It seems to ignore the collision and uses the origin instead.
Has anyone done a bot simulation on DeepShark R3?
Is there any point in trying this model or is it slow on the CPU?
make it so that the bot can live like in The Sims, like a simulation, but on neurons.
What is the most performance cheap way on having lots of npc's roaming around with routines?
the free NPC Mover plugin I'm going to release within the next few months (when I stop procrastinating on it)
with all seriousness though there's not a whole lot you can do if your npc's are characters
You can:
Limit their movement as much as possible (easy)
Clamp the amount of moving NPC's at a time (medium)
Throttle their tick rates when people are very far away (advanced)
Disable tick event, and disable all ticking components when and wherever possible, re-enable them only when necessary (advanced)
Those are pretty much your options, there's some marketplace assets that also do this stuff for you
does anyone know how to fix the move to speed issue, it seems like when the ai moves to a actor that is moving it matches its movement speed and I would not like that
Check how the Matrix project uses Mass to handle hundreds of cars and otger stuff moving around. Anything that avoids using the character movement component would help + animation instancing. You could also check the mover plugin (super experimental) that will replace the Character movement component. It's has been used in that massive colaborstive project Epic did couple months ago and people seem happy so far
turns out in the character movement the use acceleration for paths was checked
Hello.
I have found multiple such instances of BTTask_RunBehavior spending more than 1ms on the game thread,
and yet I am unable to find which particular BT node is causing this.
What can I try to find the culprit?
edit: the tiny sliver under it is BT_LoadTime. That doesn't help much either.