#gameplay-ai
1 messages · Page 63 of 1
since the navmesh represents all the places you can stand as an ai on navmesh
Looks right?
Aw man it's so close.
They emerge, but then on the next cycle it goes back to out of combat
Oh, I had to add the abort back on to the 'out of combat' for when the target is not set. But now it just loops BTT_Emerge over and over again still 😦
Hmm wow something weird is going on. 'Actor' is set according to the BT preview, but it keeps going back to the out of combat state after one cycle, then never goes back.
I wonder if one of the tasks in the combat tree sequence is failing after it's emerged so it's just going straight to out of combat. I wonder how I can test that.
i mean if its going to out of combat, it probably means your target sensed stuff is wrong?
The sensed functionality just sets 'target' to the seen actor, or empty if the actor is no longer sensed. In the BT preview, in the bottom right for keys, it updates correctly when it's supposed to and before I added in the emerge and hide, it stayed in combat and attacked correctly when it was supposed to.
oh i guess abort self is also needed maybe your both setting was right haha
Nope still doing the same thing..
what does this mean? you go into the right branch in your image?
Yes. After the 'BTT_Emerge' triggers once, it starts running down the right side.
instead of going into the infinite loop selector (Even though 'Actor' is set, so it should be going back down the left)
did you put a break point to find out why it doesnt go down that branch?
i see the selector can hit a fail case
What is the fail case? All of the tasks I am using (that aren't core tasks) are force set to 'success'
that cool down decorator
(Again all of this worked before the loop and emerge task were added)
Wouldn't that fail go back up to the start, which would then go back down the left side and try again?
because that's what it did previously.
well depends on what loop does i guess
but fwiw: sequencers fail, if any of their children fail
so if this combat loop fails, the entire combat branch will fail
and it will do the right side
Right, I understand that, but when it fails, wouldn't it go back up to the 'selector', and since 'actor' is set, try to do the left side again, not the right side?
no
thats not how selectors work
selectors will try to run each of their children until one of them returns success
so if the first branch fails, then the next branch is tried
but I have a condition on the right side to check for actor being empty and it's still running it. Even with 'actor' set.
show your current tree
hm I added a breakpoint on the 'wormattack1' and it's not breaking.
hmmmm, seems like the 'emerge' is causing an issue. The cast is failing sometimes.
this is what i've got for my tiny little not fleshed out combat stuff
I have no idea why the cast would be failing. This BT and AIC is only used for the WormEnemy class
I just added this to the 'cast failed' and it's now working better but still not perfect.
Oh nevermind I'm dumb. That didn't fix it.
if you break on the cast can you see if you have the right pawn?
dont see why you wouldnt unless you run this tree on some other object
Yeah it's getting the right one, I thought it was working but it was just acting weird. For some reason it's only running btt_emerge and not going on with the rest of the sequence.
something about the loop sequence is failing then
OH, it broke that time
Do sequences only do the next sequence after it receives a 'success' from the previous one?
yeah sequences will run each child node until one fails or all children have succeeded.. it returns success when all children succeed, and fail in any other case
selectors are the opposite, they will execute their children nodes until one of them returns success, and then return succes (and stop executing)
selectors will return fail if all their children fail
Yeah I was just not sure if it runs them back to back or at the same time and stops all once one returns a fail.
one at a time in both cases
Okay it does seem to be something wrong with the 'selector' in the combat node when trying to find an ability to use.
I'm not sure why it would suddenly start failing though, it worked previously.
Yeah something weird is going on. It doesn't always trigger the breakpoint and when it does btt_emerge runs multiple times
Let me see if I can structure it a bit more like yours
Yours looks like it's set up for only combat though and doesn't have a non combat state
i do have a non combat state, but this is a subtree of the overall tree
err this is frustrating
this is the top level tree that runs that combat tree
probably worth it to ignore the last chunk ahha i tihnk i was just messing around with stuff
hmm why are some of your decorators dark blue and the rest are light blue?
ah
at least iirc ahha
hmm I can't remember how to add a sub-tree
run tree or whatever
youdont have to do that.. i just do it cuz organization reasons haha
ah yeah, there it is.
I'm just trying to get this to a reliable state so I can find out what the hell is going on with it.
okay yep it's something with my cooldowns/abilities sequences. I guess I need a 'fallback' for if none of the abilities can fire.
I wonder if I can add 'finish with result' to the end of the selector
you can make the selector always return true
You can?
there's a decorator that does it yeah
Oh shoot I didn't even see that. Force Success
doesnt solve the underlying problem of why your node fails tho, just hides it.. so i would solve that tbh
I think it's just because yeah, the cooldown on the 'ability' (or the player not being in range), is causing it to fail
yeah tbh a combat loop has the "do attack" and then "do something while i wait for my attack window again"
yeah it's that 'do something while I wait' that I am trying to do. It should just sit there idle until it can attack again.
I suppose just using a 'wait' for the duration of the cooldown, or even a bit after, would resolve that?
ah yeah, true.
but then if the player is not in attack range, it would fail and do the same thing the cooldown would do
BRO. I think I got it.
lol nope now it stays in the left side forever
Nevermind, I got it. It's not perfect but I think it's clean enough at this point that I am satisfied with it and can clean it up later.
also you can use things like the ai focus decorator which will face the given bb key for the duration of a node
rather than the rotates
hmm I don't see that in the decorators
Oh it's a service. 'Default Focus'
yeah that's weird lol. It rotates the worm while it's attacking so it looks like it's flailing all over the place.
er yes service is what i meant haha
I appreciate all the help you gave me.
Yeah he does an ability where it flings forward and slams on the ground and it takes like 4 seconds. During that time he spins around like a helicopter if you move xD
Nice everthing looks good now and I even added in some camera shake when they hit the ground. Thanks for all your help!
np
Sorry if I wasn't supposed to post this here. The end result.
chompy chomp
Hmm hopefully one last question. When using distance checks, even though the mob is directly in front of me the distance being printed between me and them is huge, like 500+ units. Is this accurate? I was thinking like 5-10 units would be right in front of you, but the prints never go that low even right next to you
consider the the player is probably what, 50 units wide?
maybe not that exactly but like there's some size right 😛
so you can never be 5-10 away from something
unless it overlaps you
Is it going from the center of the colliders?
because both of my capsules are 34 radius, which should mean approx 68ish units away would be nearly touching each other. I have to set my min distance to like 300 before it even triggers that it's far enough away when it's right in front of me.
I have a question on best practices when it comes to using Perception.
I have a pawn that changes states. I want the AI to do something different when this state is changed. So when my AI perceives this pawn using OnTargetPerceptionUpdated, it can check the state and set something in the behavior tree so it knows what do to.
The only issue is, if my AI is already perceiving this pawn, and then the pawn state changes, I can't get the AI to "reperceive" it. The only way the perception component will do this if the pawn leaves and enters the sight range again.
Sounds like you're trying to use the BT as a state machine honestly. Go for the State Tree or build your own state machine for your AI. You don't have to use the BT.
Pawn should only have how to complete an action. Shouldn't have states. The BT should be deciding what it should do.
Oh sorry I didn't explain this perfectly.
So I have a pawn that is controlled by a BT with a perception component, and another pawn that is just going to be percived. My example is with a "Fish" And "Lure"
So the "Fish" is perciving this lure, and in that event I'm checking to see if the lure is in a state that can be bitten or not. So if the lure is in the air, or is being eaten by another fish, I want the fish to ignore it. I set that in OnTargetPerceptionUpdated, where when my fish percives this lure, it checks the state of the lure before updating the fishes behavior tree. If the lure is valid, I set the fishes BT so it can start chasing the lure. If its invalid, it does nothing.
you maybe want to register for an event if the lure gets invalidated as a potential target
so lure changes state to "used" or whatever, then your ai that tracked it can know its no longer valid
How do I do that? I tried adding a "PerceptionStimuliSource" and registering/deregestering it as a stimuli but it doesn't seem to do anything.
- I wouldn't do it like this - wouldn't even use perception personally. But that's more of a choice.
- When the fish can get the lure, register the fish to an event dispatcher from the lure. When the lure changes state to not being a valid target anymore, broadcast that event.
i just mean literally making an event that fires on your state change, and when you acquire a lure as a target, register to listen to that event
no perception
duroxxigar, same page haha
.... AAAHHHhhh... I think i see what you're saying
I'm using the get distance to node with the AI pawn as one actor and the player pawn as the other, and it's returning 350 as the minimum distance standing right next to the pawn
Ok, so on valid preciving, the fish registers itself to this event dispacher.
If the lure becomes invalid, I kick an event that tells all the fish listening to that event to chill out and do something else
I think i get it
You could. But I would assume only one fish would ever really be registered to it at a time. You'd want to unregister in the callback on the fish.
Yeah, that makes sense
Random question, is there a way I can just "unregister/register" a pawn to be perceived by the percpetion component?
I don't think it is available in BP. I've never done it personally though.
I thought if I had an UAIPerceptionStimuliSourceComponent, it would be pretty straight forward
but it doesn't seem to do anything
tbh target management is probably a bit outside of the usecase of perception anyway? like perception just tells you when you sense stuff.. what you do with the sensed stuff is pretty specific to your game
So maybe i do this state checking in the BT instead
This is where Luthage would say to use EQS for target management.
hehe yeah
AAAHhhh ok. So, I could just create a service that does this and call it a day.
I'm not going to say yes or no because I haven't seen the BT specifically.
But also, don't overthink/engineer this
Just do the callback method and move on.
Fish don't have complex AI
no, they def do not. Ok, will do. Thank you
Never played another crabs treasure I take it ?! 😅
For this decorator, where does it look for this gameplay tag? Can I just make a variable on this actor of gameplay tag type, and it would pick up that one up?
Iirc you need to expose IGameplayTagInterface to bp to use that
Which is not really hard to do
Hey everyone! How can I access the actual currently running StateTree leaf data?
For example how can I get the "Idle" string when I am inside the "Idle" leaf?
Right now I am just using a Task that calls a function that sets an enumeration on the pawn. But I feel like having that middleman is unnecessary
My issue was that AI would stop moving at all instead of coming to the closest point, it was because i was only using the bool value of that function so it would try to move to the given location but as it was not reachable AI would stay there.
yea i wasnt doing this
What would be the best way to find all the players that a pawn is able to navigate to in Unreal?
like every player or players within a certain search area?
Well there's only like 5 players
you can probably do an eqs, or just iterate over the players and see if you can path to them
eqs is not yet stable right?
it doesnt have many customizable options yet...
I had this issue months ago, Whenever a noise is reported I wanted my AI to go at that location and get n number of patrol points in r radius and patrol in those location and then go back to its usual patrol.
I used EQS to get new point but i wasnt able to get a specific number of patrol points also I wanted eqs to get the point where AI cant see in the specific radius but also fetch new patrol points when theres nothing thats blocking its sight.
I discussed this here few months ago ig, it was not possible through EQS
I do wanna learn more about EQS and use it properly
yeah eqs only seems to return one point.. but why did you need several?
to make it patrol
its like
AI will search around for the target in the area where sound was heard
to make it look like searching i wanted my AI to do a small patrol
i do that wiht eqs tho? i dont build out a patrol list, but i could probably add a check to invalidate areas that have already been searched
my search behaviors basically look at out of sight areas near the disturbance (last seen/heard) location
but it only returns a single point right? i wanted to make it loop and return few more
only one point yeah, but i repeat the query every iteration and go somewhere new
can we define the number of times it should repeat?
at runtime
sure why not? a bb key can do that
also looks pretty extendable via code, you can define new test types, query contexts etc
I will use it the next time im working on AI, my current project is almost over and i dont wanna make any last minute changes....
valid
hey!
I ended up doing the same as you: run a task that asigns a g.tag to the owner so we can know at all times which State is it running.
There're are probably better ways since you can grab this two from the Execution Context
My guess is that you can extract the node name from there
you use a sequence and inside a loop. Instead of a Selector with condition. Is it more performant to work like that? because i guess the result is the same but you have to perform less instruction with that loop?
not about perf at all tbh, its that way because its the way i did it haha
and truthfully the perf cost either way is probably inconsequential
like always profile and use that to inform optimization
Hey everyone I have a few noob questions about AI navigation on arbitrary surfaces (walls, ceilings, steep slopes, overhangs)
is this already supported by the character movement component and the existing recast pathfinding? The maximum walkable slope for agents caps out at 89° and CMC caps out at 90° so I'm guessing it is not?
My first idea was to use geometry script and geodesics to build a spline from the shortest path and move the AI on that spline. But surely there's better ways of doing this? I've played around with that in the past and performance was quite a big issue with it.
is there a best practice solution to this problem? how is this usually solved?
alright I used the search function and found out that there's not really any built in existing solution. Might check this plugin out, looks promising
https://www.unrealengine.com/marketplace/en-US/product/dynamic-surface-navigation
Distance also includes height. So when you have characters of very different heights, your distance checks are going to be confusing. You can use distance 2d for just the x and y.
Is there a node for that ?
It's highly customizable. Mostly just in C++.
It can return more than one point. You can't use the built-in BT nodes and have to change the run mode.
Yes
:0 I had a huge misunderstanding related to EQS damn
I have a an environment query that runs on a behavior tree selector continuously. I was wondering if there is a way to make it run conditionally? So that if a certain condition isn't met, the selector still operates but without the environment query
In StateTrees what is the best way for a child state to communicate with a parent state?
I have an Awareness task that has SuspiciousTarget property
I have a child state GoToSuspiciousLocation which is supposed to clear SuspiciousTarget on parent when reached.
I have found something called FStateTreePropertyRef but no idea how to use it 😱
--
What I'm doing, which seems dirty and naughty:
class THE_FLAT_API UAwarenessTask : public UStateTreeTaskBlueprintBase {
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Output")
TWeakObjectPtr<UAwarenessTask> Self;
}```
class THE_FLAT_API UClearSuspicionTask : public UStateTreeTaskBlueprintBase {
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Parameter")
TWeakObjectPtr<class UAwarenessTask> AwarenessTask;
I bind those and call `AwarenessTask.Get()->ClearSuspicion()`
It works and seems to be all good in terms of memory management.
Wondering if I'm missing something
🤔
I've not really seen anyone use tasks to reference other tasks in this way, not sure if it's a good architecture... Personally I would consider having this type of logic perhaps in an actor component which is used by the tasks
However, if this approach works well for you, I can't really think of any immediate reasons to not do it either
You mentioned there's a way to get distance without the height. Do you know how to do that? I can't seem to find any nodes that let you omit one of the coords in the location vector.
Not without making your own version
Isn't there like a Distance2D or something on vectors?
iirc that omits Z
Yeah I see that node now. I am not sure how to convert to a 2d vector though since they are all in 3d.
Yes that works on 3d vectors
Oh it does it for you. A second ago it told me it couldn't do it but now it's taking it.
Distance2D, which is what I said in the message you are replying to.
Yeah I found it. It wasn't showing up at first.
wow that is much better
yep works like a charm, thank you
Http Request is not working for a plugin I use. I made changes to “HttpThread.cpp” and saved it. I want to build it.
Should I use Github and build it manually from Source?
Is there any other way?
I'm not sure how this relates to AI but yes, if you modify engine source code, you need to build the full engine from source yourself. Hard to say if there's some other way because that seems to entirely depend on what the problem with the http request is
Hey, thanks for the response. Where do you see these? I can't find them anywhere in the code.
Maybe they are not in 5.3? Are you on 5.4?
StateTreeExecutionContext.h. But yeah, I'm in 5.4, so I have the mayor update they introduced. Not sure if they are available in 5.3
Thanks. Yeah the StateTreeExecutionContext.h file doesn't have that field. It does have the TArray<FStateTreeDataView, TConcurrentLinearArrayAllocator<FDefaultBlockAllocationTag>> DataViews; but I think I should just update the editor
2d distance between 3d vectors is just the difference of the 3d vectors and zeroing out the z axis after the subtraction op, then returning length or sqr length of that vector
There was a conversion pin for it 😄 didn't accept it at first but after I kicked it in the patoot it worked.
This might be a weird question but is there a way to pass a delegate into a blackboard so I can broadcast it in the behavior tree? I have been trying to find some ways but not a lot of documentation
what are you actually trying to do?
My enemy will have an Equipment Component that I want to be able to use through the behavior tree, For cleaner code, I was trying to see if it is possible to use the delegates to avoid needing to cast in my tasks and call functions directly.
This is important as I don't know what will be listening to this delegate. It could be just the Equipment component but other components will listen to it too. Every task will get cluttered over time
This delegate is also located in my AI controller.
hello, if you create a BB and BT on a base class. What will be the impact on children if you want some elements different from the mother. Do we have to create 1 BB and BT per monster??
i'd put it in the ai controller, and just have a behavior tree task that fires it (or calls a function on the controller that fires it.. that being said, direct function calls are always faster than delegates
thank you! I will do that and thank you for the tip 🙂
in my own setup i have a task that evaluates abilities on the ai and picks one, then another task that can activate that ability
since they are all GAS abilities they all have a common base class
granted, i write most of my stuff in c++
I've been struggling with AI MoveTo and could use a hand:
I'm just trying to setup absolute basic AI movement toward my player but my enemy isn't moving at all. I've placed and checked a NavMesh on my level. And my enemies are also spawned into the world already. The AI MoveTo is returning a success. What am I missing?
Cubes represent the enemies. The player is spawned when the game starts.
the cubes cut navmesh so there's no path
Thank you! That's exactly what it was. I had to select the Cube and toggle off "Can Ever Affect Navigation"
nodnod
TestPathSync and ProjectPointToNavigation does the same thing?
Im calling both testPathSync and ProjectPointToNavigation mostly the results are same but in some scenarios the result differs
The Skylight Icon is the destination, in this scenario both function returns true and also the return value of ProjectPointToNavigation is the closest point on the navmesh
both of the functions return false in this scenario
TestPathSync returns false but ProjectPointToNavigation returns true and also the closes point on the navmesh which is not reachable by AI
so what I did was this
if (NavSys->TestPathSync(Query, EPathFindingMode::Regular))
{
bIsValid = NavSys->ProjectPointToNavigation(endLocation, NavLoc, QueryExtent, NavData);
OutLocation = NavLoc.Location;
return bIsValid;
}
project point to nav returns the closest point on navmesh, test path sync tests whether there is a path between two points
oh
but this only seems to work in 5.0 and 5.1
what does it do in later versions? ProjectPointToNavigation still works the same afaik
can you say that a different way im not sure what you are saying
i can imagine that maybe it takes into account agent radius
wait maybe its just my imagination that its not working fine...
no theres something wrong
When i call the TestPathSync function in 5.3 and the point is outside the navmesh it returns true
it doesnt happen in older versions tho
i looked about it on the forums some say it doesnt work properly and they use ProjectPointToNavigation instead but what to do when its like this?
Even if the point is outside your agent radius,
yes
idk why UNavigationSystemV1::TestPathSync(FPathFindindQuery query, EPathFindingMode::Type mode) returns true even if the destination is far away from the nav mesh
but i found an alternative
FPathFindingResult PathResult = NavSys->FindPathSync(Query, EPathFindingMode::Regular); this works fine in all the versions of UE
I have an invisible cube. It looks like the nav mesh is filling in an area underneath the cube minus a decently sized perimeter
is that normal?
In fact it seems to generate both above and beneath the cube:
nvm I guess Fill Collision Underneath for NavMesh does the opposite of what I expect
I'm still surprised that it's generating a nav mesh on top of the cube
although... it seems dumb that the nav mesh gets created when the object is above the ground vs. hovering over it
its on top of the cube probably because your volume is taller than the cube
It is, but I thought "Can't step up on" meant it wouldn't generate navigable space on top of the cube?
and I'm more annoyed by the interior of the mesh being navigable...
no iirc thats more for the player being able to step up on something
you have tha paremeter because of the nav agent size
and you need to have the fill collision underneath set properly
as you discovered
the reason that's an option is likely overhangs is my assumption
right but that only seems to apply when the nav is literally underneath it. Not when it's inside it.
so your collision is imbedded?
i mean in all liklihood its probably fine? you cant generate a nav path to points on there anyway, so destination picking should be able to deal with it
my mind goes to all the functions like "random navigable point in radius" which doesn't seem to take any particular actor's perspective
there's GetRandomReachablePointInRadius
get navigatable doesnt check if points are reachable, just that they are on a navmesh
but also, you can do the proper tests with an eqs
right but I'd much prefer to just generate the navmesh corectly and check for navigable points
No, you can have AI travel above the cube for example, it doesn’t mean that they’d make a giant step from the floor to the top of the cube, only that you have two levels. If you don’t want navmesh to generate on top of the cube, simply reduce the Z scale of the navmesh volume.
Prly means the inside of your cube is hollow. So when it’s hovering, the outside plane is actually colliding and thus prevents the navmesh from generating. When it’s touching the ground, you’re no longer colliding because your cube is empty, so the navmesh is generated
If you create a cube in the editor this is the result. Its not hollow
Iirc anyway haha I'm not at a computer to check
I haven’t checked tbh 😅
Ok but is there really no such thing as just a blocker volume that says "don't generate any nav mesh in this area"
Nav modifiers. But I’m not suggesting you should place one inside your cube (before Luthage comes firing) 😀
why not place it on the cube?
Seems hacky
How are you supposed to use AIPerceptionStimuliSourceComponent in C++? It's variables seem to be private to C++
Like auto register as source
u want to add the component to ur character?
through c++?
Yeah. Just like you add any other kind of c++ component
Or am I thinking about it wrong
hello, i am beginner to unreal and i am trying to align navmeshboundsvolume to walls and celling so that ai character can crawl on walls and celling but its not previewing green path on walls and celling can any one help me to solve this??
navmesh doesn't support that at all
is there any way rather than navmesh ??
Some custom navigation solution maybe. Perhaps EQS can be used to generate points along the walls/ceilings and you can manually move towards those
Generally you'll have to do the work yourself
I dont know of any engines that do this out of the box, even internal ones
There was a thread on the UE subreddit recently about pathfinding in this type, in particular Deep Rock Galactic was mentioned
since DRG has dynamic terrain and enemies which can traverse any surface
but I don't think there was really any insight other than "DRG does this, somehow"
What is the best way to ensure that NPCs do not clump together when moving to a location? For example my NPCs right now, when they move to the player, all stand right next to each other. I'd like them to be more 'smart' and space apart abit, being aware of other NPCs around them, so it looks more natural. Would an EQS be used for this, or is there another component/method to do this?
hmm, I just came across RVO avoidance
Avoidance helps them avoid each other while moving. But if they're all going to the destination, then they're going to clump up at the end. Use EQS to have them pick different spots close by.
yeah I just noticed that. I tried using an EQS but it doesn't seem like it's picking up the enemies (at least when testing it using the testing pawn). I used the multi actor one and used 'get all actors of class' and chose my enemybase class (which all my enemies are children of), but none of the spheres in the eqs highlight even though the pawn is directly in the middle of a bunch of enemies. Is it just because it can only run during play?
This is what it's doing. All of the points are showing Distance (0). It works if I use a 'get actor of class -> player start', but for some reason it doesn't pick up these enemies.
Sorry for all the questions. Been trying to figure this out and put it on the shelf like 3 weeks ago because I couldn't get it working.
Can someone help me with State Tree?
The actor is not moving when I use the "Move To" action
The is a navmesh volume and AI controller is set on the Actor BP
try using state tree component, not state tree ai component
Check this for starters https://zomgmoz.tv/unreal/State-Tree/Troubleshooting-State-Trees
If none of the items mentioned there are problematic in your case, start by using the visual logger or the ST debugger to see what is going on and whether your task is being activated correctly
As for the state tree ai comp vs the regular one, assuming your comp is in your AI controller, the state tree ai comp will work. If not, then you need the other one
some of my current work is like this .. but it basically requires a customized navmesh solution that can handle putting nav on all surfaces dynamically in a changing world so... very much not trivial
dont send them to the same location
they'll clump around corners, still, but that generally helps a bunch
the test pawn will work on assets in the editor scene like that yeah, so long as they're referenced properly.. granted in a real game when its running this is generally a bad idea
since lots of things tend to be spawned
Yeah, I figured it probably would since it works with 'get actor of class -> player start'. For some reason though, the context I made that (temporarily) uses 'get all actors of class' and passes in the array of enemies isn't working. Once I got it working that way I was going to adjust it to only query for enemies within range of the NPC, but wanted to get that first step working first. Perhaps I am using the context wrong.
The environment query is this:
and the context I set up is this:
did you break point your context to see if its doing what you think?
I haven't break pointed it yet no, but when I use the single actor (in the same context) with player start or with get player controller in-game it works (with eqs debugging on)
i'd break point it to see what the context is returning
but breakpoints only happen in-game don't they?
Sorry, trying to get some answers when not actually in front of my office PC. I'll take a look when I'm near it.
Breakpoints happen whenever the code is ran
^^
but also i'd say get used to testing in game too? like... this is how you will ultimately have to debug things..
No, I do debug things in game, but because the eqs didn't work I removed it and was trying to get it working in-editor first before reworking the behavior tree again to add it back in just for testing.
i mean the eqs runs at editor time, so you will still hit this breakpiont
OMG, I was making this way too hard
There already was a generator for getting actors of class.. I could've used that the whole time with a distance test
sigh
Hehe, yep it’s very useful
I think in cpp you use a timer or, even better, you use an Event-Driven approach
Or coroutines
Yeah, co-routines seem amazing. Saw a gdc talk about them in unreal, any exp. With them in ue5.4? Since they upgraded the supported c++ version I guess they work "out of the box"?
ok im missing something but is there a method to change state tree object link?
Even on init? Trying to find a way to assign dif trees on dif actors
i see some options but none to chang the default load value
This is unsupported currently afaik, you can only change subtrees dynamically
ah good to know its a limit currently. Didnt know you could do subtrees, that might be a workaround
I vaguely recall hearing that 5.5 might address it but not sure. There was some discussion here in the past about how it could possibly be done but it would require a bunch of custom logic
intresting, ill scroll to check. Option B would be much more of a pain (making dif actor types for dif state trees)
Or i supose making a bunch of default state trees and nuking all but the one you want on load
Yeah no idea why they didn't think of supporting it
seems like such an obvious thing to have
yeah 😅 its gonna be quite annoying but hey you probably saved me a few hours of forum post searching to find its not possible , cheers!
👍
Does anyone know of a way to get AI MoveTo to continuously update the pathing as the location changes without having to create an actor as a goal and move the actor?
It has an option you can pass
I'm on 5.4.2 which doesn't have a Task node for EQS yet.
I have this State Tree where STTask Get Flee Location generates a FVector that MoveTo is bound to for Destination. This works fine when the Get Flee Location task immediately generates the vector location.
However I want to move it to EQS, which requires an async callback for the data to be returned, and once I moved to that the State Tree ends up playing the Delay task twice.
I think what is happening is that on subsequent runs, GetFleeLocation fires (in OnStateEnter), then immediately MoveTo tries to move to the previous location of GetFleeLocation (since GetFleeLocation is async and hasn't updated the value) and then immediately completes (because it's reached the target), and then moves into the Delay node - so it's not waiting to pick a new location to flee to before running all the branches again.
But I can't figure out how you're supposed to wait on an async task like that. I tried adding a Finish Task to GetFleeLocation but that completes the entire Panicked task and it leaves the children.
I tried making a separate state for updating GetFleeLocation (so it could wait for that task to finish) but then I can't figure out how to pipe the output location from GetFleeLocation to the MoveTo task, as it appears you can only bind to Outputs on parent tasks, not sibling tasks
This is not an alternative. Those 3 functions do very different things.
Project point: projects the given location onto the navigation within an extent (like a radius, but a box shape.
Test Path: tests if there is a path between 2 given locations. It uses project point, because it's a cheap test to see if something is on the navigation. This function doesn't care about the cost of the path, just that it has one.
Find Path: actually builds the path and is significantly more expensive than test path, because it cares about finding the cheapest path
It's not clear what data you are testing with, but your observations and assumptions are wildly off the mark.
Floors as well. Fill collision underneath is new as of 5.0. Terrible name, but much needed functionality.
The perception stimuli source is not the same thing as the perception component. Going to assume you mean the latter. Make a pointer, create your subobject and assign it to your new pointer. The base class will handle it also being assigned to it's private pointer.
The stimuli source is just added like a normal component on the character and not the controller, where there are no private variables for it.
Protected variables are available to child classes. But I don't remember seeing any for the stimuli source.
there's no privates in the stimuli source .. so everything should be there for derived classes
There are a few ways to do it depending on how you are using Move To. Creating an actor as a goal is probably the worst option.
Hello
I have a class deriving from Character class, that heavily makes use of physical simulation. Most of the time the character is moving with completely custom physics code done on tick.
This gets me into trouble with AI, because I can not use the common and useful functions such as AIMoveTo. For now I make use of GetPathToLocation node, and manually move the character to the path points in order. This works fine for simple tasks, but for more complex state control, I want to make use of Behavior Trees, and other AI tools.
How can I achieve this? Is there a way I can extensively communicate From behavior trees To blueprint, passing things such as target locations and path points to it?
For example I would love to bind to an event, that whenever AIMoveTo is called from say Behavior Tree, it calls my custom event with all the necessary information, such as destination and path points. But the only events I can find are MoveFinished and Failed, both of which are practically useless to me.
write your own moveto behavior tree node
you're looking for BT Tasks
since your move logic is all custom, you need custom move to functionality too
which should be pretty doable imo..
but most of the stuff around path following, navigaiton, and locomotion will probably have to be extended/replaced to utilize your character's motion stuff
Hey is OnTargetPerceptionForgotten rlly not available in UE 5.1 ? or mine is buggy or something ?
if it's not rlly available how could I know when a sense has been forgotten ?
You have to turn on forget actors in the perception settings in the project settings.
ForgetStaleActors ?
I think You got me wrong, what I meant was the Delegate is missing. I know that I have to turn this on in order for the delegate to fire but I meant it's not there at all on UE 5.1.1
I think it was added to engine on 5.3...
I don't understand why or when I should be using blackboard keys.
I have logic in my behavior tree that locates a "target".
Should I store a ref to that target on the controlled pawn, the controlled pawn's AIC, or the blackboard? Does it matter?
Yes
Oh, yeah the delegate is a newer addition.
It doesn't really matter. Any of the approaches are fine. Blackboard is just a convenient place to store these types of values so things that are used by your BT don't have to affect the rest of your logic
Anyone know a good tutorial series on making NPC's with routines i.e. talk to each other, carry crates, go to sleep etc
use the blackboard when you need to move data around the behavior tree and when nodes need to share data..
Is there a level designer friendly way to make a generic spawner where you pick the class that should spawn and then it auto detects the defaults that could be changed in the "template" so that you can change the settings it the ai being spawned should spawn with?
yeah its pretty straight forward to do that.. there's already a bp node for spawning ai actors
Also DataAssets are nice to use for spawning stuff
yeah i have a data asset set up to be what a spawner consumes to create an npc
my spawners also use eqs to place AI in an area, handy to help ensure that ai are spawned in valid locations
Yeah, EQS contexts are handy
Oh, that's all super good info! What kinda stuff do you have in the DataAssets?
On my end I have a soft ref to the class to spawn, among other things like thumbnail, description, tooltip (UI drag and drop spawn mechanic)
Interesting, so how do you get the spawner to expose the starting values for that instance (I.e. these npcs should be on the red team and start with rifles)?
Well anything that is shared should be in the parent class
So then you can tick the Expose on Spawn box and thus get a pin
(Only works on the SpawnActor tho, not SpawnAI), afaik
Like Team can be an integer variable on BP_Unit
Altho now that I think of it, if your class is a wildcard you will not get the expose on spawn
But you can have a function that sets the variables on the return value (spawned unit) immediately after it is spawned
If that is a parent function, then anything shared will be accessible
You’ll need to cast to Parent since you don’t know what it is beforehand
Hopefully that all makes sense
So for context we have more or less 3 types(classes) of npcs we want to spawn and I was hoping to create a single npc spawner class that I could have my level guy place, then pick the class, and then it would show all the options for that class to spawn with... but without me having to hardcode all of those properties....
Will you have more classes than that or is that it
wasn't sure if there was some part of the reflection system that I just didn't know about that I could use for that
I was hoping to make it as generic as possible so I could use it in other projects as well, but if there isn't a "dynamic" way to do it I'll do what I have to 😕
There probably is, but maybe not built-in. Expose on Spawn only shows on the node when the class is selected beforehand
basically, I want my spawner instance to act like the "SpawnActor" node does where it refreshes and adds all the pins after you select the class you want to spawn... I should probably look at the code from that, but I have a feeling it's going to be ... fun lol
From what I gather you’re trying to make a blueprint utility for your designers
I can’t rmbr what they renamed Blutility to, but that’s prly what you’re going for
I'll look around and see what I find, thanks!^^
Not to bother you, but do you do anything differently to what NeoExcidious was doing? (Besides the EQS, which I'm going to do for sure! Great idea!)
i mean the data asset more or less holds the things i need to use to spawn what i want.. you can pretty much make it do wahtever you need
Is there a trick to expose different properties in the data asset based on a selected reference to a class in the asset?
what do you mean?
For instance, say I want the DA to start the class I want to spawn and then some of the values I want it to spawn with. I.e. Spawn Soldier, with red shirt and pistol vs with blue shirt and rifle, but then a different spawn may be a Townperson, old woman with broom.
just spawn a diff bp? i dont see what you mean
Well the idea was a spawner class that could be place or called at runtime to spawn any npc with a preset pattern of values...
I.e. Blue took this point, so now the spawner spawns blue soldiers... something like that
I was hoping there was some trick with the reflection system I could use^^;
i mean is there anything different between the team's soldiers? could the spawner just know what team owns it and then spawn guys and assign them that team
and some other system determines what coloring they get
based on like team id
then literally its just a "soldier spawner" and team id determines things at run time for soldiers spawned while its controlled by a certain team
possibly... I'm redoing our whole AI system, so I've just been trying to think through best ways to achieve our different goals...
really depends
The current use for the spawners will be for ambushers when a package gets to certain hot spots on the map, but I was thinking we could use it for a lot of other things too if I did it right...
sure, i mean most of these things are easy to expand as you need new stuff, hard to predict the future tho, so best to aim at stuff you need imo
with a mind toward extendable code
np!
How can I stop my beaviour tree here as behaviour tree is probably casing my engine to crash
Hi all,
How would i go about making an A-Life system similar to STALKER?
Thanks
Hi!
Does anyone know how are we supposed to debug State Trees in builds (no editor)?
I'm asking because I've been banging my head trying to learn how to gather the execution data of a tree so I can show it in a custom debugger while running a build, since the Debugger for trees only exists in editor.
But looking at the code, I can see FStateTreeDebugger is available in every PC config (no consoles) except for Shipping. In its Tick is where the analysis starts (when you press the record button in the tool).
I'm trying to figure out if there's another way to trigger the analysis. Seeing it's available outside the editor..
Is there a console command or some tool I missed for debugging State Trees outside the editor?
If that's the case, I can track down how do they handle the debug
Thanks
Did you try calling StopLogic on the brain component?
Hey how expensive is the ai perception systems? I'm setting up a listen server based game, with maybe 4-5 players, each of which might be close enough to trigger up to 6 enemies with the system running. Would the listen server be dying with that many ais running? or is it a relatively cheap system and I shouldn't worry?
It's likely overkill for my use case, so if it's too expensive I can build something custom, but if it's not too bad, then saves me time to use it instead
I wouldn't worry about it. Just build it in a way that your other logic doesn't directly depend on it and it'll be easy to change if needed
The sight sense does linetraces to each target within the sight radius, but even that is timesliced, so if it somehow was taking too long it will split the work across multiple frames
but with the numbers you mention it doesn't seem like it would be a problem
Sweet. Still working out how the system works, so wasn't sure how much of a pain it would be to design it in a modular way, but given your response I presume it's pretty easy
Thanks
Our AI characters are consistently aborting MoveTo requests in packaged game and I can't figure it out. Is there a way to access the Vlog from packaged game or is it editor only?
It's editor only but it's realtively ez to hack with some engine changes
You need to change the macro to allow it in whatever build config you need
Then you need to create a console variable (it's easier with a cheat) that grabs the visual logger module and starts/stops recording.
The file recorded can then be opened in the visual logger tool within the editor.
I'm not at home but tomorrow I can show you the code if you haven't figured it out by then
Super useful to have it in builds
you arent going to get a useful answer i think... break your problem down into smaller parts and solve the smaller parts
Your question is very broad and can be approached in a dozen different ways which all depend on how your game works in general
Hence it's not very easy to answer it
the answer is evaluate your problem, break it down into doable work. no one can do this for you
and zomg is right: this is an incredibly broad question which basically sounds like "make my game for me"
You need to ask better questions lol
The answer to your current question is basically "make something that lets the AI put cards into the arena" because that's as much as it can be answered because there's zero detail in there that's needed to give a more precise answer
honestly it sounds like you need to visit the basics before you can tackle this problem
Well you need to come up with some kind of rules for it to decide when it needs to act in what way
I don't know how the cards function specifically, but in general, you would have the AI look at what cards the other player has put on the table and f.ex. calculate their attack power or such
Then it can make a choice based on this and perhaps some other factors like random chance
its not that no one will help, its that your question doesnt really have an answer.. part of making games is research and experimentation. You have to build things up and connect them together for your game, because someone else's solution will never be a perfect fit for your needs.. so you have to do some of your own problem solving
anyway like i said, break down the feature you want into smaller and smaller understandable chunks.. like what do you as a person do when you want to think about a card and then place them in particular places?
what are the rules you follow as a player when you do that?
do you look at your hand? how do you pick cards from your hand? what do the placement locations mean? what kinds of cards would i want to place in certain spots?.. your ai has to know how to do every one of these steps, the steps you as a human can just infer
so, break the problem down into smaller and smaller chunks and then solve them
This depends entirely on how the game works, I can't really say. I'm assuming there's something that lets the game know there's a card in a particular spot when a player places a card, so I guess you would need to do something that allows this to work for the AI
depends on your game rules and what you are wanting
you can search for them, you can tag them, you can hand add them manually to the ai's data.. loads of ways and the way that works probably depends on your needs
you can have a system manage them, etc etc
@lyric flint note that this community is made entirely of your peers, other devs trying to figure out how to achieve their own goals, and people may not necessarily have the time or know-how to approach the idea your imagination has come up with, as everyone's experience is different and things that make sense to some may seem very complex to others. You are not entitled to any answer here, and if you ask broad/vague questions, especially preceded by something like "what is the best way", you are unlikely to get an answer.
In the event you are fortunate enough that the right people are around and are able to give you some broadstrokes, you will still need to figure out the details of how to write that logic, mostly through trial and error, like Allora said. Having been here for 5 years, you should be well aware of this by now, but just in case.
i can say in basically every studio i've worked at for the past 17 years none of us know how to solve the problems put forth for our games entirely.. the way we solve it is: define the goals, break down the problems and experimentation... we develop a solution for the feature over the course of the project.. we hit road blocks and mistakes we made along the way, and we correct for them.
Basically we invent our own solutions, and its a very iterative process
problem solving is a huge component of building games, and its probably a skill everyone involved with them should invest in because often times you are going down paths few or no one has gone down so there's no information to really help you.
like if you are modelling your game after the card placement mechanics of another, go watch their GDC talks or other conference talks about how they approached their solutions and why they are good or bad
look at other games that do card mehcanics, how does its AI handle it? what looks good? what looks bad? like.. this is the research im talking about heh
good, makes me feel better about my approach to problems which is basically iterate and make small adjustments until I find the solution 😅
So I'm making an AI task from CPP and I am facing the instancing issue where all the enemy instances behaviour tree task somehow syncs up
you need to use node memory or the blackboard and not store data on the behavior task itself
at least data you dont want shared to all node instances
What could be the reason that FindPathSync (C++) finds a non-optimal (not straight) path in backward direction ?
Hi mates
I want to make an AI that goes from point A to point B ,and this one i think is simple.But how can i make him choose random x y point in range of the line that he must follow and go there instead,but remember that he must go to point B?
Like a declination from the path or smth
Probably related to how the navmesh looks like, in one direction the center of the mesh is in straight line of sight and in the other its behind the obstacle. (This is what I guess is happening). You can still manually clean up paths though.
Looks like this, indeed! I made navmesh tile size smaller and the issue is gone for this particular blockout.
Still can't rely on such pathfinding in general 😦 so yes.. need to clean up resulted paths or some other solution.
Kinda strange it's still a default pathfinding behaviour in UE5 with all these Nanite and Lumen things...
I think it just works as intended, it finds a path, but maybe not the cleanest, but further would be slower, and may be unnecessary for many cases.
Possibly look into NavCorridor
For now I just check if direct path is possible (as the most obvious problem) and if it's possible I just remove all other path points except start and end.
if (pPath->GetPathPoints().Num() > 2)
{
FVector HitLocaton;
bool bDirectPathBlocked = NavSys->NavigationRaycast(Controller, AgentNavLocation, GoalLocation, HitLocaton);
if (!bDirectPathBlocked)
{
TArray<FNavPathPoint>& PathPoints = pPath->GetPathPoints();
while (PathPoints.Num() > 2)
PathPoints.RemoveAt(1);
}
}
NavCorridor basically does that in a proper way, but its still an experimental module, it's definitely still worth checking out though.
Has anybody here used a good flying AI 3d navigation plugin for UE5 that they'd recommend? I found a couple paid ones but I don't want to buy the wrong one. I need something relatively performant so I can spawn around 10-30 drone enemies at a time without dropping too many frames. Any suggestions would be appreciated, thanks!
What is the difference between the two notify observers in BTs? When the BB key value changes the condition will also change. So what is the point of OnResultChange?
I mean you posted the answer, so what are you not understanding? 😀
So there is no point in using OnResultChange?
For the first one to abort the BB key itself does not have to change
To a diff bb key or nullptr that is
There is, but maybe not for your use case
So I should iterate the FNavCorridor with FindNearestLocationOnPath / AdvancePathLocation / ConstrainVisibility trio and add returned points to new path ?
did u see the screenshots I sent before? idk why but for some reason Test Path was giving wrong result. Maybe not an alternative but the result is what i wanted and Thanks for giving the proper definations of those functions
Let's say you have a bool that initially is false
Result change will only trigger when changed to true
Value change will trigger anytime time you change the value, even if it's the same one it already has (false)
what's the point of the redundancy between GetActorEyesViewPoint and GetPawnViewLocation? I was stuck on a bug for several hours before I finally realized that SetFocus uses the latter, not the former. But the former directly calls the latter anyways...
No, you constantly call that to move toward the constrained location. You may not need to update the constrain location if you are still on track towards the current point though.
hey guys
i have this setup:
First subtree AI chooses a random location and goes there and waits an amount of time.
Second subtree AI move to a specofic location.
i want to set this up: So he moves to a random location and then he moves to boss location for 3-5 seconds,then he moves to random location and then he moves to the boss location ,and so on,how can i achieve this?
I did manage to get a new path with NavCorridor.
The old path is red, the new is white.
While it does improve a lot in green area, it kinda seems a bit less optimal in red area. 🙂
It's too bad we don't get access to the string pulling logic in unreal. That damn PImplRecastNavMesh hides lots of useful stuff that could be overridden to achieve different logic
Like the one you just did there
FNavCorridor does the string pulling logic
Seems a lot better, the area in red doesnt seem bad either? possibly just some more spacing due to settings that keep it away from the wall? 🤷♂️
Perhaps I AdvancePathLocation() too much in red area, so it kicks the left wall of the corridor.
But I try to get a path with as few points as possible, so basically I call AdvancePathLocation for a maximum value and then clamp the result with ConstrainVisibility() in a loop until I am in the End Point.
I guess if I just move a character with Tick(dt) the path would be even better,
but I have yet to figure how to clean up such path fast enough (get all path points while moving on corridor with very small delta and then remove redundant points that are on straight lines).
oh nice. Didn't know about NavCorridor. That wasn't there when I had to deal with all this.
Super nice to know.
@glossy swan how/where are you using it?
do you build one from the path given to you by the engine?
Also, general question: how does people debug State Trees in builds?
Yes, I build it from path like this:
FPathFindingResult Result = NavSys->FindPathSync(Query, EPathFindingMode::Regular);
...
FNavCorridor Corridor;
FNavCorridorParams CorridorParams;
CorridorParams.SetFromWidth(400); // default width 200 did not make all paths straight in my case
Corridor.BuildFromPath(*Result.Path, Query.QueryFilter, CorridorParams);
Do you mean standalone builds ? not PIE ?
I print a current StateTree state for now, it helps a lot in most situations, but some awkward transitions can only be understood step-by-stepping StateTree Debugger window 😉
how to stop move to location or actor movement??
has anyone used IAISightTargetInterface::CanBeSeenFrom() in an async fashion by calling the FOnPendingVisibilityQueryProcessedDelegate delegate it passes to the function?
Yeah, standalone builds.
When you mention "step-by-step ping St debugger" you mean as in "run the game PIE, repro the bug and use the in-editor tool" right? Or is there a way to run the St debugger as standalone connected to a build?
Asking because I'm trying to build a visual tool we can use to debug in standalone builds and, the more I look into it, the weirder it's for me there's nothing, considering half of the debug (gathering info) goes through an Analysis Trace system and the State Tree Debugger class, both available in builds (except for shipping builds).
But it's proving hard to harness all the info
Hi, how do I correctly put the AI into a stunned state? The script looks like when taking damage, it needs to play the reaction animation and then play the stunned animation. Should the stunned animation be a montage or part of the animation blueprint?
you could force it to a priority state in your BT (top left branch) with a play montage task and see from there. you will probably end up with a sequence of steps before playing the montage where you pause some other things to interrupt whatever it was doing. Depends a lot in the game/implementatio
Well, that is, if I initialize an attack through BT, then I should also cancel it when reacting to the attack through the same BT, right? Otherwise, there will be a mismatch of states.
if your Stunned branch uses a decorator that cancels the rest of the tree, you could handle that in the Task End of the Attack task (canceled) and so on. There's no good answer, it's gonna depend a lot on how your game is being made
How would you do it? I'm just starting development so I'm quite flexible in my approach
I would start by interrupting the attack like you mentioned and move from there. Generally speaking, interrupting things and resuming them after doing something is one of the biggest PITA in AI
Yes, I meant reproducing the bug in PIE. We are still far from testing standalone builds, but we'll also have to serialize State Tree (and everything else) as our game is Commandos/Desperados-like,
so we have to support save/load the whole game state using F5/F8 at any time.
So maybe this future serialization work will allow us to debug StateTree as well if required.
that sounds super nice
Its really easy if you use GAS
Once you have GAS up and running and using it with your bt's... Kinda XD. I had mixed esperiences
Try switching for STs, you can trigger events with payloads etc
tbh, i wouldnt model stunned states in the BT itself? At best aborting the current branch in the tree, but i probably wouldnt process the tree at all during a stunned state.. but i'd basically let an ability or something deal with it
FNavCorridor does not help in this case (red path) 😦
that seems like a rather odd path
what does the navmesh look like if you turn it on?
I see, I just played around with it a bit, and it doesnt properly do shortcuts, it cleans up the path, but it sticks to the path it finds
Guess you'll have to combine your old method with the new method
Just making sure everyone knows but you can run state trees inside behavior trees. This is really powerful.
I don't know how adequate this option is - I've made one root BT for now, where the logic for a particular state will be described, for example, to pursue a player or to attack a player. Separately for each state, I made abilities that contain specific logic, for example, in the Idle state, when receiving damage, you need to go into a Stagger state, and in the stagger state, you need to play an animation and upon completion of this animation, you will be in the Idle state, but if damage is received before the animation is completed, you need to cancel it and start it again. And the state itself is determined by the tag that is currently present on the character.
GameplayEvents would help, my guess
in what context?
IMO this kind of stuff shouldn't be handled by ai. Do it with gas and just let ai wait until the body is available again. Makes no sense to model hit reacts and body stuff in the ai
in any case, you need to interact with the AI in some way, otherwise it will try to attack without paying attention to the fact that it is already reacting to the attack at that moment
i mean i've shipped a ton of games with out having to worry about it 😛 I never have hit states in my ai
but like i said, just aborting the tree and waiting for the body to be available again is basically the jist of it
like the hit states on the body shouldnt be allowing other movement or any of that either .. they should be in full control, and its not like an ai with a properly built tree is just gonna run off and process a bunch of random stuff.
Would be better if we could see also tiles and polys. Check also this from Mieszko.
I am using some BTs (only for small sequences of actions) in my AI and I store / retrieve a lot of World State info in a custom component that I add to all my agents.
I think that all those variables could be set in the Controller, but It was more practical for me this way because I can set some AI parameters for my AI Pawns easily in the viewport thanks to it.
I realize that because of this component, I do not use the Blackboard, except for two variables selecting Behaviors/Plans and Goals/Objectives...
Will I ... die 😅 ?
The only advantage of using the Blackboard I see is that I could share some variables across all the Blackboad instances easily but I do not need this (at least at the moment).
Anything else useful I am missing ? Maybe it is more efficient to retrieve stuff from the Blackboard than from an actor component ?
I am cleaning up / rewriting the AI so I am looking for best practices!
I'll check his solution, thanks!
How is it possible that this node returns path information when there is no way to get to the location? The only way I've been able to get the location to fail is to encase the goal actor within a navmesh_null modifier, which is not what I want to do.
Hello . Here is a simple move to part of the BT of the AI.
This "move to" node always fails. There are another "move to" at the left side ( it is not seen) , it works perfectly.
BTT_FindDelieverTarget stores the correct vector data as target location. and at the breakpoint i double check if the target location is right, and yes . Move to has the right vector but somehow it fails. It never jumps to the next node , it simply fails.
What i did for understanding the issue ?
I make a 0,0,0 as a blackboard key for "target location" and it worked.
So i think the issue the location of the target actor is blocked and the AI fails to go there.
What should the actor collision settings be to solve this issue ?
if the move to fails it likely cant generate a path
I found 😦 totally my mistake, I have got a nav mesh blocker on the target actor but it was too high. now my AI can deliever the good thank you
Does anyone know how to fix the error of Blackboard keys getting reset to SelfActor when the editor is relaunched? I have three Behavior Tree Tasks, and while one of them keeps it's Key set, the others don't and I need to manually set them every time I launch
@zinc maple check the status of the path info returned. Also get the path from it and check if there are points etc. It might be that it fails or it's partial
?
aha ok
I'm trying to get my Pawn to move to a chest in the World. However the AIMoveTo always fails, because it is unable to calculate a path. (even with a high acceptance radius 325).
I think this is because my chest is a static object and blocks the navmesh. So the AI can't move there.
What would be the standard procedure to handle this issue?
I have tried adding a large NoCollision Box to the Actor to the Actor in an attempt to solve this, but the path still cannot be calculated.
Use project point to navigation on the chest's location assuming that's where you're trying to navigate to
This should give you a point on the navmesh
Thank you so much! Works perfectly. I feel like the AI stuff could be a bit better documented 😅
the issue is that your chest is probably not in reachable navmesh
(it likely cuts navmesh)
so you have to find a point on navmesh in order to get there
basically it gets the closest point on navmesh within the bounds of the extents you give it
hey guys i have a question i am making a game for mobile using bp and a problem that i got into is how can i get reference of ai pawn i tried get ai controller node and out of its return value i used get controlled pawn but it gave me runtime error cannot get reference i need to use soft reference not hard reference in my game
i used interface for communicating between ai and player character but cannot use this thing for custom bp
really need help ????
What do y'all think the best way to handle AI that gets knocked off of a navmesh is?
what do you mean get out of nav mesh
so if you have a nav mesh in an area and props around cut into, and then the player punches the AI on to the props so that they aren't on the nav mesh anymore
u mean when your player character punches your ai it get onto prop somehow and underneath props there is no nav mesh
.
Exactly, so not the AI can't move unless you punch it back onto the nav mesh
go into bp of ur prop and un check can affect navigation
this will solve ur problem
.
Well, I don't want the AI to wonder onto the props
that's why we had the props blocking it
can i see one of the prop
Kind of a tricky question. It depends on your game and various factors, but in general you would need to figure out some way for the AI to return to the navmesh
This could be done with something as simple as having the AI literally jump to the closest navmesh point
i've been writing this exact system for work ahha
but yeah use a project point to navigation to find nearest point, and use althernate movement methods to move there
(like applying move velocities to the cmc yourself)
And then just use traces to keep them on the ground… good stuff thanks y’all!
you can actually apply direct move directions to the cmc. so if you have a move vector you can apply it this way
I am using the perception component on a zombie enemy, I have the character set to rotate slowly because I am using a root motion stagger walk. But if I enable GDT and debug perception, when I walk into the enemy's line of sight, I can't walk out of it because the sense rotates to follow me all around the character, even though it has a relatively low FOV
It'll auto-adjust to the ground that way?
iirc? dont quote me on it but the cmc handles groundedness
I'll can give it a try anyways! Thanks again^^
Need some help... Getting these errors regarding setting booleans on my blackboard from my ai controller.
If I add a validated get the errors are removed. I feel like this is a bandaid of some sort and has an actual issue to be fixed. Even when it gives the error, the actions that are set through the behavior tree behind these booleans are activating as expected. I also tried hooking up a print string on the is not valid but nothing was coming through there.
This code is run through my AI controllers Ai perception components "on target perception updated" event.
This is one of the instances that is giving the error. I've used every variation of "blackboard" nodes I have seen here and they all function identically
This suggests that you have no blackboard. Are you using behavior trees with this?
The error specifically is referring to CallFunc_GetBlackboard_ReturnValue, which means the GetBlackboard node, and its Return Value pin. Accessed None means the value of the thing it's referring to is nullptr/none.
Yes, I have a set behavior tree and once this popped up I even manually set the blackboard.
All of the bools are actively being set/unset as they should despite the errors.
🤔
That's rather bizarre, it's almost as if you actually have two controllers, one which is doing the thing correctly, and a second which isn't
because if it works correctly, then you shouldn't be getting those errors
Isn't that impossible?
It is weird. But if the double controller thing is possible it's equally confusing as to how it's happening but I may know where to look now.
Well if your code somehow ends up spawning two controllers it could happen
Easy enough to check, they should show up in the world outliner when you play in editor
Never thought to check that cause I honestly didn't know that could happen.
I'll take a look at that when I can get to my pc.
Thank you for the help so far!
The one case I could see where it might happen is if you have configured your pawn to "auto possess AI" with the "spawned and placed" setting, and then manually spawn a controller for it. Not sure what else would cause it.
Either way, if you are getting those errors, it definitely shouldn't be setting the bool values correctly, so something wacky is happening :)
The way I have it set now
Is in the children pawns I made for the ai specifically is set to auto posses on spawn or placed.
In the gm when the game actually starts (not begin play), the gm spawns the bots, then pulls the ai controller from that spawn actor to set a few variables in the controller. I don't believe I have a possession node set in there but I'll double check that now.
I'll be able to post more ss later if I can't figure it out based on this convo
Yeah lol it's kind of blowing my mind a little.
I'm still looking for the cause. But I haven't found anything to suggest a second controller. When I spawn solo, only 7 AI controllers are spawned into the outliner with mine. I'm just beyond confused still lol.
Here's the set up for spawning my AI above:
IN game mode, upon the match starting it loops through all non assigned player spawns, picks a random AI pawn class, spawns it, then has the AI controller spawn it's wizard with it (no controllers on them, they're only there for aesthetics).
Going into the Spawned pawn it's possession settings are shown above. Disabled player possession, enabled placed in world or spawned possession for ai. Selected which controller to spawn.
Now the pawn and controller are spawned, the code I run in my ai controller class is above which just delays their start, checks for pawn, sets pawn, then runs the behavior tree. I also added the use blackboard node but it made no differences so it's likely just a redundancy since my behavior tree uses that blackboard.
Then there's all the spaghetti with running code off the "on target perception updated" event where I'm getting the errors saying it can't set the blackboard values. (but it is)
The vortex/tornado looking thing in the last SS wouldn't be possible if the bool wasn't set.
It's possible that you're getting this error if you're trying to set the BB value before you've called Run Behavior Tree or Use Blackboard
If the perception triggers during your 3.5 second delay, this could cause it
The blackboard component is created by the Run Behavior Tree node so it doesn't exist at all until then
That was it
I'm assuming your delay is there because the pawn isn't immediately available on Begin Play?
Tyvm for the help.
The delay was there because I haven't gotten around to a proper setup to stop the ai from starting before the play command is sent to all players. Player pawns have their input disabled for a few seconds at the beginning. However, even though this code is run on the ai pawn, the input isn't disabled, So I delayed the behavior tree until I could come back to make a real solution. Which I will do now
Ah
Yeah just thought it was because of the pawn stuff since there's that cast with the delay for next tick
There's an On Possessed or something like that which you can override, that will trigger when the controller actually possesses something so it will be immediately available there
That is just to set the variable for it's controlled pawn so I can call certain pawn bound events throughout the code
I'll take a look at that
So idk if it's the best way, but at least for now I'm just setting the perception to default as disabled, then enable it after the delay lol.
No errors
Hey there, I m actually making a combat game and I want to have a team of enemies so If one get's alerted everyone else in that team get's alerted if I sneak up to an enemy and secrely back stab it that notifies everyone else in the team so how can I do that?
Something easy to implement would be:
- create an ai/enemies manager/director where all your enemies register on begin play and unregister when dead and end play. Register means "add them to an array". That way you have a collection of all the AI's quick to check things like distances to a point etc (very useful when using EQS's)
- you should think about rules that define what a sneak attack is (ie: when attacked from behind + using melee weapon + crouching)
- when an enemy is attacked, call a function in the AI director called Under Attack that takes in the character being attacked and the type of attack.
- in said function the AI director will check the attack type and, if not sneaking (regular attack) will gather all the AI's within X meters and call a function Alert on them. Alert retrieves the location where they need to go.
That would be a good start
If you use the concept of Damage in the engine, you can use that to propagate what you want
If you use GAS you probably have different abilities for regular and sneak attacks, so that part would be solved in a different way
While im a big fan of directors, id personally probably just do a sphere trace centered on the attacked actor, invoking the same logic that way (inform nearby in range about the attack)
Perhaps this could be done by the director tho... 😅
Id always imagined the Ai director... directing .. assisting the ai in attack formations etc
To avoid to much clumping/collision etc
Never actually implemented anything like it tho, so it might just be illogical doing it that way
it depends on the goals, a simple subsystem that tracks active ai and activates them all if one is attacked is an easy way to do that.. as range wouldnt hit them all
It wasnt ment to hit or notify them all in the described scenario, just nearby ones
yes it was
so If one get's alerted everyone else in that team get's alerted
no mention of ranges or other coordinating factors
manager will work better in that case because there's no range limit, and you dont have to cast
I like to avoid the physics based approach (sphere) because either you have a very well defined physics pipeline (channels and profiles) or you will end up with an overhead where you loop all actors overlapped, check if they are AI etc. Depending on how crowded your scene is with actors, it might be too much for the cpu to run every time there's a hit on an enemy. With the director (a subsystem as pointed above) you can simply check square distances and discard anything above/below certain Z distance (the sphere approach will grab enemies in floors above and below within a building for example). If a physics based approach is preferred, I suggest implementing a Is Within Cylinder test (you can copy the one from Nvidia) to avoid the "different floors" problem
(and ultimately you'll make some central place to coordinate ai anyyway)
i agree i dont really like the cast either
if you need a range clamp just use a sqr distance check (or a flattened square distance)
plus you can always use a distance filter + line trace to specific actors if you need los checks or something...
and then in steps EQS haha
Id think whatever small and specific loop you get from a trace + team filter would outperform the distance check on all ai in a relatively larger list, without any backing data
Different floors would have a hundred solutions to handle
Go with what feels right for you tho. Can ofcourse do without the physics approach if you want
My mistake, I apparently didnt read far enough back
traces (lines or sphere) are slower than distance checks.
1 to 1, sure
The other thing with the subsystem is that you can curate it, have different collections for alive or dead enemies for example. Then you can remove the ones that are too far into another collection that will act as your pool. Quick checks like "give me all enemies within range that have more than X health" are super fast, without the need of fetching them though traces every time
is the conversation still about group enemy AI?
My point is that it leads to a quick way of querying them
you'd have to get to some pretty dense populations before that made a big difference imo, as always prfoile.
Yeah
I still have to read the texts gimme a min
In order of expensivness less to more
- 2d sq distance
- 2d distance
- 3d sq distance
- 3d distance/line traces / sphere / AABB checks that do not care about physics (I would add here capsules and cylinders too)
- non AA BB
- traces that filter physics channels
- shape sweeps
- custom shapes that are not spheres, boxes, capsules and cylinders
And this greatly varies depending on your physics configuration. If you add dynamic objects into the equation it adds complexity
in the majority of cases, esp in shooters, you dont need much more than 2d sqr dist checks
Fastest in the book: curated collections that you loop and filter theigh sq 2d distances in this case
The apply LOS, tags for runtime context etc
yep yep
Btw, another advantage of centralizing checks through a system is that you can queue your queries and make sure you don't spend more than Xms per frame chekckong stuff (like the Perception system does) and wait for the next frame to continue. You can also save the info and, of anybody asks for the same query within X frames form a very similar location, return your cached info
yeah there's a lot of good reason to use a subsystem and you can definitely start small and grow to cover what you need in your project
Yep. Can't agree more
Are state trees considered useable now?
I still can't quite grasp and understand the behavior tree system
did not use State trees yet, but it looks like a mix between Hierarchical FSM and Behavior Tree so I guess you might have more difficulties to use them than vanilla Behavior trees.
In my case I wanted to switch to them because I am using a mix of FSM for high level decisions and BT for simple sequences of actions already so it might be better to go to State Trees.
But I did not find them usable in my case for 2 reasons that might not be valid anymore (Anyone ?) :
- You cannot see live in which State the State Tree is in (like in BT where the branch you are in is highlighted) and lack of debugging tools in general
- No simple way to add utility scoring on top of State Trees
There is a ST debugger at least since 5.2 or 5.3 which lets you see it live, it also logs live into visual logger
I'm using them heavily and... Not ready for some things.
No cooldowns for states, no direct access for a BB (in case you want to combine them with Bt's), non debugable in builds, lack of documentation and comments in code. They also have some weirdness on how they work (more of that in this article https://jeanpaulsoftware.com/2024/08/13/state-tree-hell/)
That said, nothing you can't solve with code here and there
Utility scoring seems to be coming in 5.5 I think
And yeah in general I'd say they are usable but they have a few rough edges so you probably need to try it yourself to see if you can make it work for your usecase
One issue several people have highlighted is that you can't assign the ST asset at runtime which can make it a bit clunky when reusing the same actor with the ST component in it
I did inherited from the state tree component and I'm running several trees in "parallel" and I can assign and remove them at runtime. Basically I tick what they call "state tree reference" (the one you set in the component itself) and then I have an array of other trees I run. Alongside an array of data instances for them + new functions to tick, start, stop etc (basically copys of the original ones but using my array and skipping some logic)
But out of the box, quite limited. It's one of those unreal features that are very good idea but very lacking of "common" functionality in games
I'm currently using it in one of my projects for sort of task selection and management, where the individual task is then executed using a task-specific BT
Also I'd note for BB's, you can do those via custom tasks but yeah it's less "integrated" than in BT's
I do something similar: we have a main state tree that defines if the AI should idle, patrol, attack and so on. When decided, we push a bt that runs in single run mode. When done, we finish the"push bt" task and the tree reevaluates.
For BB's I have a condition that uses an instanced class that inherits from the Blackboard interface that allows you to interact with it. In the condition we can select which BB we want to read and it loads all the keys in it. Then we have some more logic to do the usual operations a decorator would do. That way designers can use everything in their toolbox.
The other state trees we run depend on the main state (idle, attack etc) and they are there to check things the AI can react to while in said state. If one passes all conditions and runs a state, we check if we can interrupt the current bt and we push whatever bt the reaction needs
But the biggest time consumer has been (and still is) to build a visual tool like the State Tree Debugger we can use while running a standalone build. I finally figured out how the State tree debugger class worked (for real... That thing is not straight forward). Now that I finally have all the means to get all the info form the running trees the same way the editor does, I'm in a crusade checking ImGui widgets/plugins to have something similar to the St debugger but that can show all the trees execution at once, with a frame timeline like Visual logger. Not far from having it now
So to summarise: ready for production for simple stuff, get ready to get dirty in c++ for anything advanced
great!
double great!
Yeah I'm looking at it and I mean, it does make sense. I suppose for the cool down, you could just have a task that is a delay, no?
Like it sorta makes sense. I need to understand how the child and sibling hierarchy makes sense and see how it would work with like patrol routes and POIs
Like I suppose you could in theory make a finite state machine
And like GOAP just seems like a FSM on crack
And I suppose I could code around the black board to bypass it entirely
If you don't plan on having bt's or a BB at all, you use a mix of what your evamuator would do, the context and the params handled by the tree states
For us the cooldown is solved through GAS, we assign a gameplay tag for each active cooldown to the character, and we have a condition that checks if the cooldown tag in question is present in the owner AI
Yeah I still need to research what Parameters are in context of STs
I have some homework to do
Just wanted to see if it's viable to use now so I didn't just waste time but knowledge is knowledge
I making small game with trading at sale table.
Before trade mini-game, NPC buyers stand in a "queue line" in front of the table
NPC AI checks free place in this "queue line", register self on free place, and move to it
"Queue line" have references to each NPC on specific place in queue
🔹 Then the first NPC in line gets the goods, leaves, and frees up the first place
at this moment, all waiting NPCs should move in queue (queue shift)
Logically, there is no need for AI to constantly check queue line state
so all AI can be notified at "queue shift event" But
How i supposed to do it with Behavior Tree❔
I have something similar in my game - I have a BT task which manages the queuing process. Essentially it first enters the NPC into the queue, and then listens and acts upon the queuing related events, until the NPC is the first one in the queue. At that point it finishes and lets the BT resume
tbh sometimes you dont need to do everything in BTs 😛 like if you have a thing that manages the line, then just suspend the behavior tree until the ai is done being managed by the line management stuff
literally could be a single node that just waits for an event before it succeeds
Yeah that's pretty much what mine does
also like a big thing in game ai.. people go down the rabbit hole of trying to simulate everythign, when they can just not, and take shortcuts, and have less stress doing so ahha
its very much an optimization game: will your time sink into some subtle feature add value to the player's interaction with the ai? ime players totally miss almost any subtlety haha
No access to BB may be because it is an entirely different braincomponent. From implementing my own integration of AI I found that a ton of the AIModule is tightly coupling BB and BT and the BT brain component.
It really isn't. BT related code in the AIC auto-creates the BB comp, but you can drop a BB comp on an AIC without using a BT no problem. The only thing that's lacking in the ST editor at that stage is the ability to use blackboard key selectors in a nice way so you'd have to resort to using Name values instead of you wanted to specify BB keys dynamically
So it's slightly more error prone in terms of typos but that's about it
Anyone know how to extend the age of an AI sight stimuli?
Thanks for the clarification.
Iirc you can get the stimuli source and set its age
Idk if it works after it’s been sighted (during) tho
what are you actually tring to do
Where I can do that? I'm working mostly in BP, only did c++ when I was a noob so my knowledge is a bit rusty. I couldn't tell where the age is set in the AI sense config or AI sense sight classes
Should be in bp drag the component into your graph
The AI perception component? The only stimuli function I can drag of that is request stimuli Listener update
Never mind It was a behavior tree issue, a task was calling the stop chase method too early and it just so happened to match up at the same of time that the AI sight expired.
Hate those annoying coincidences
Hi! I've made a simple AI, but sometimes the AI move to fails. And I don't know why...
Use the visual logger to find out
I want to spawn EQS points in the location of my character but in the rotation of my controller, so I tried something like this but when you provide single location, it does not accept provide single actor.
I think of creating a scene component on the root component of my character and when I give the context, I set it's rotation to my controller's rotation. I wonder if there is a better solution than this 
You need to provide context by using UEnvQueryItemType_Direction via C++, I didn't use it via BP, But you can use it via C++.
Thanks for the answer, I will search how to do it 🫡
you can also provide a context via bp for what its worth
oh i see you did start with that
I think of creating a scene component on the root component of my character
Bad idea, adds extra movement overhead to the CPU and pollutes the character class
I set it's rotation to my controller's rotation. I wonder if there is a better solution than this
Why providinglocation + forward vector * distancedoesnt work?
guys i have run into some weird problem with my EQS and i cant seem to find a solution
i have set up a simple grid around querier, and made a query context to assign a score based on the distance to a certain actor type
it seems to work fine in the EQS tester
but when i launch the game, it seems to completely ignore the specified actors
my query context looks like this
the query looks like this
apparently the issue simply fixed itself...
Hello there! Can anyone tell me why "BreakingFrictionFactor" does not affect my NPC when it stops after walking/running?
I've set the value to 0.3 and even tested 0.0 without any results...
Using "BreakingFrictionFactor" in the Player's Blueprint works fine, only the NPCs have problems with the friction factor.
The Animation-BP of my NPCs use an 8Way-Blendspace and use a direction- and speed-float which are both processed through the Character-Velocity. The same setup the BP_Player uses.
Hope anyone here knows how to use "BreakingFrictionFactor" for NPCs
i think the braking friction wont apply when ur AI is trying to move
ah, yes, normally not when using the default "MoveTo"-Taks in the BehaviorTree.
But I am using a custom Task which uses the "AddMovementInput"-Function of the NPS's Character (seen in the pictures). That's why I think "it should work" but that's just a guess.
Am I wrong?
nope that still uses the CMC afaik
So what I understand from what you are telling me is that an AI-Possessed Character is not affected by the Fraction-Values?
ok actually looks like thats built into the pawn class itself
I also tried "AddMovementInput"-Function on the NPC's "Pawn", no effect yet
Hmm... ok, so, what about other ways to accomplish what i want? Is there a "Best Practice"-Way of accomplishing my goal?
I only want the NPC to smoothly fade into the Idle-State after the walking has finished. Are there other ways to do it maybe?
i am confused now, do you have a pawn or a character?
that should be done in blendspace or animation blueprint afair
I tried character first and after your response i tried pawn without success
well the friction thing is only in the cmc, but i guess thats not the actual issue here
Here are two further pictures from the Animation-States in each AnimBP of the Player and NPC.
When observing the "ForwardVelocity" and "GroundSpeed" variables of both AnimBPs when running the game, I found out that only "ForwardVelocity" decreases it's value over time whilst "GroundSpeed" decreases almost instantly...
Is that a hint to some setup/settings I missed to set in my NPCs BP/AnimBP? Or maybe an AI uses it's CMC differently due to it's architecture???
Edit:
- First pic is from Player's AnimBP, using "ForwardVelocity"-Variable which derives from CMC's Velocity and represents the FowardVelocity only
- Seconde pic is from NPC's AnimBP, using "GroundSpeed"-Variable which derives from CMC's Velocity and represents the 2D Movement-Velocity (forward, right)
it kinda looks like a weird way to set up character movement btw
why isnt all this stuff in the character bp?
SOOO yeah i think i figured out my issue... i changed the "MovementSpeed" (see picture) and now it works.
Seems like the initial speed (150) was to less to show an effect of the Friciton. Now that i set it up higher, the NPC smooths out into the idle-State!
yeah 150 is kinda slow unless ure making a turtle lol
also, i think there is some sort of global friction setting
it was very annoying when i made space ship controls lol
haha, yeah, the NPC is mainly "walking" which is why i need a slower speed.
do you mean this?
no it was somewhere in project settings afair
That project sounds cool!
it caused friction even when everything in the CMC was set to 0
oh man, "project settings"... 😱
it was just a test to see if i can make zero gravity movement xD
well anyway, thank you for your help!
you welcome 👋
I found these (I don't usually use visual logger), but I can't get any useful information out from here that can help sadly.
Really? You don’t get any useful info from “Aborting move because path is invalid” ?
while the logger is running you will also see the projected path/end goal on the navmesh (or outside of it) so you can see exactly where the issue is
you can also run this node right after the moveTo (make it at least 50 or so radius for it to be visible)
Okay
Okay, I had this error, and I've found that I had a static mesh component on my player, which has "Can Ever Affect Navigation" on, and when I turned it off, it seemed to be working, but I'm not 100% sure yet.
Thanks for the help!
is ther a way of sending an event to a StateTree running on a BT?
Do you have use acceleration for paths turned on?
You shouldn't directly send an event to the state tree. You should use the AI controller or pawn as the go between.
You can't provide multiple types for a context, so you need to pick one. What is it that you are actually trying to do? The problem you are trying to solve instead of how you are trying to solve it.
You should never use begin play to set up the AI controller. Certainly not with a delay. Use On Possess.
Yeah, I realized that while trying to figure out how can I do it. Turned out I can't
. I am trying to run an EQS at my character location while direction should be towards the camera. I think of using creating a SceneComp in my character location and set the rotation to my character's control rotation if I apply this design. The design may change, so the implementation will too.
Creating a scene component is a really bad idea. You aren't answering the question of what are you actually trying to do?
I thought of using the SceneComp as my querier but it is an experimental approach 🙂 I am open to better implementation suggestions.
The reason why i try to do is my EQS shape going to be a cone and the problem is the points being generated always at the querier's forward vector.
I want the customize the direction of the spawn point.
On possession in my case would still require a delay. The pawns being possessed are specifically made to spawn as ai.
I do plan to learn more and create a better set up, so with that I must ask for my understanding:
What exactly is wrong with this method other than the delay being crude and why?
Can you tell me what is different behind the scenes of calling possession as opposed to auto possession?
It needs an actor. A scene component is not an actor. You can provide a direction.
Oh wait, thats right 
How can I provide a direction, when I try to provide a direction, it overrides my actor for context. I tried to find a way but I couldn't 😦
You should be using the auto possession functionality instead of spawn as an AI, because you have a guaranteed execution flow.
What do you mean it overrides your actor for context? Direction has a location and rotation, if I remember correctly. You don't need to have an actor as well.
I only called the rotation version 
So I can call them separately and they both work since they call different SetValue functions 
I am sorry but that would not work. I use the player character as querier and if i change the rotation of the actor, it will cause unwanted behavior.
what are you trying to do?
Something heretical as it seems 
mostly atm it seems like an xy problem
Hey, my pawn is teleport to random location when using SimpleMoveToLocation to unreachable location.
The pawn is using FloatingPawnMovementComponent. It's working alright when move to valid navigation path.
Is there a way to prevent AI root motion montages from pushing a pawn outside of a navmesh? I have an npc that can do an attack that pushes him forward using root motion, however if this is done at the edge of a navmesh, it will push him beyond its boundaries
There's the nav movement mode, that doesn't allow movement outisde nav. It's what Crowd control uses. I think there's a place in the movement component where it can be detected (the same way it detects if the pawn is on floor)
do you remember what the movement component setting was? I cant find it
Not from top of my head, but look in the movement component for the Movement modes
You will find the usual for flying, walking and another for nav only
Are we to know what you're even talking about? (Person I was responding to deleted their post. It was just a video and they had a comment that said there was a problem)
Did you explain what you're trying to do somewhere?
That is just a video with zero context
How is anyone supposed to provide any kind of help?
Just don't do whatever you're currently doing. Do the thing that works.
Hey, to clarify: I'm talking about c++, im the code of the component. There's an enum that defines the different modes available. It's definitely sewhre in the editor, but until I'm on my pc, can't give you anything more accurate
hey AI bros. Im constucting chasing. My prevoius project with those same settings was successfull. Now im struggling with abortion from my npc and constant forward vecotr length of 1
thanks for the clarification! i was looking for a magic button through the details panel of the component hence why i couldnt find anything on the topic. This stirs me in the right direction 🙂 still not there yet, so if you remember what it was when you are on your pc again that would be a big help
these two should give you a good starting point
It would be great if StateTree transitions also had task(s) property where we could choose tasks to execute during the transition. This would probably be not real tasks, but rather simple tasks with only
EnterState always returning Succeeded would be enough. (No Tick or ExitState).
For example I have "MoveAndSearch " subtree that I want to reuse in many situations, so I can transition to it from different othet subtreees like Patrolling, Attacking, Noise etc.
And I want MoveAndSearch to behave differently depending what other subtree (state) it's called from (like run, crouch, use weapon, apply different FOV rotation, etc).
With current StateTrees I can setup this in ExitState or EnterState checking FStateTreeTransitionResult but it's cumbersome and error-prone and breaks the idea that most tasks are modular and can be used elsehwere.
I can also make additional subtrees in the Root that duplicate required logic instead of direct transitions. For example [Patrol_To_MoveAndSearch] block would do the required logic and then transition to -> MoveAndSearch. But this worsens StateTree readability as it grows.
Interesting idea... although I'm not sure if putting such logic into the transition would improve it either, because you would have to keep duplicating the transition's configuration to all the places where you need to share that same transitional logic
Adding them into the tree into the root as their own subtasks would be my solution as well and that seems like the best solution if you want them to be reusable 🤔
You can do this by outputting links to Evaluator or whatever they're called using reference. I did this for an old project.
Those seem deprected now:
Evaluator - These have largely been phased out in favor of using Global Tasks. Global Tasks handle the same uses as Evaluators.
thanks a lot!
Thank you.
why Repath is calculated not from the current AI position, but from the starting point from where FindPathToActorSynchronously was called?
if (UNavigationSystemV1* NavigationSystemV1 = UNavigationSystemV1::GetNavigationSystem(World))
{
if (UNavigationPath* NavPath = NavigationSystemV1->FindPathToActorSynchronously(World, GetActorLocation(), Actor, 50.f, this))
{
NavPath ->PathUpdatedNotifier.AddDynamic(this, &AXAIActor::OnNavigationPathUpdated);
}
}
void AXAIActor::OnNavigationPathUpdated(UNavigationPath* AffectedPath, TEnumAsByte<ENavPathEvent::Type> PathEvent)
{
}
Anyone have any suggestions on how to get ai to wait in line, and move to the position in front of them when it’s free? I don’t need exacts just trying to brainstorm some approaches
I first though about using smart objects but was having issues with the gameplay behavior ending, then the object being marked as released
In my game I have a "queue manager". When the AI enters a queue, they register with the queue manager. The queue manager tracks who's in which position, and whenever the queue updates, it sends out events which the AI's listen for. When they receive the event, they ask the queue manager for what location they should be in and move into it
(each possible queue has its own queue manager)
Thank you! That’s somewhat along the lines of what i was thinking, good to know I’m on the right track.
I'm trying to get an enemy to move forward while arcing towards their target even if it means moving away from their goal for a bit until they come around. I thought maybe I could do it with EQS, finding a navigable point forward and to the side and moving towards it until the target character was in front of them again and normal navigation could take over, but just doing a sequence of the query and move to was pausing at each point.
I'm pretty ignorant of BTs and EQS still, is this something I could solve easily, something that I could solve but it'll be tricky, or is even a relatively light environmental query not quick enough for that kind of thing?
Is there any way to run EQS queries synchronously?
out of curiosity why do you need synchronously?
generally speaking its pretty ok to let AI be pretty slow at processing things
“Slow”
seriously often i let 15-30 frames go by without doing an individual ai's updates
and ai just not doing something for like half a second is pretty ok ahha
players have pretty slow reaction times so you have plenty of time to wait on a decision imo
so yeah something taking a frame or two? no biggie
note tho i dont mean their bodies not updating, just the brain
you dont need to make decisions that often
^^^IE every Batman/Spider-Man game where enemies will very patiently wait till it’s their turn
You could just have each AI path-following to the one in front like conga-line style
Game AI pro might help. I recall this article explaining something similar with an ATM
https://www.gameaipro.com/GameAIPro2/GameAIPro2_Chapter11_Smart_Zones_to_Create_the_Ambience_of_Life.pdf
But... can't you use a smart object and have different slots for it? Not too familiar with SO's, but we use them for similar things
And here i was making sure i could tick all my ai brains every tick lol
Players likely wouldnt know even if it was 10 frames behind
You should totally do everything synchronously, I’m sure your plan will work without a hitch ||/s||
Hey I'm messing with state tree. And from what I see if my tree finishes a move to state and it's next state is the same move to (with an updated position) then it reuses the task's instance data and the next move to auto completes despite having a new position to move to. Is this known?
Do you mean you call the same task in a different state or you call the same state (somehow setting a transition to itself)?
Hi mates,i would appreciate if someone could help
i want to make a simple mage AI that looks for the target location and if its too close ,the mage must move in the player opposite direction,and when the mage is at lets say 500 units away from the target it must shoot at the target and abrupt the task when player is too far or too close
i just made this logic and it either has errors or it not working at all
So here is what i have at the moment
1)move away task
2)Service that updates target position
3)Selector where i set the variables
4)Controller where i set the target as blackboard key
and if i remove this part here i encounter this error when i exit PIE settion
but the AI moves and this is not how i planned
behavior trees already have a move to task.. so i wouldnt be calling ai move to in a bp task .. and the behavior tree move to, can update the move if the destination changes, so really you just need the service to update the destination and the behavior tree move to node that moves to the destination the service sets
I need the AI to move from the player when that is close,not to the player.Thats why i created a custom task
Move to default one moves only to the player
right, you dont need a custom task for that tho?
like i said, the behavior move to can go to any destination you assign in your bb
actor or location
the move to behavior task literally accepts a blackboard key
so really all you need is a task or service that assigns a location or target actor to a blackboard key
Of course the other extra part of this is, your tree needs to handle more cases.. sure you can move out to where you need to be, but what happens when you get there? do they shoot? do they reposition to somewhere else? once that move to completes you need to have other branches in the tree to "do stuff" .. and at the moment the first sequence and selector in your tree are more or less pointless
First selector is for other ai types their logic is on the right and left,they are not in the screen.
Second now is pointless i know,cuz yeah, i dont have other logic there
And what about the error?of access none trying to read property...
It means that the key target actor is not set ,but why its not set ,if i set it on AI controller
why do you have a delay?
i'd step through your code that assigns the target
see what it actually does
I heard that if there is this error of access none,it means the game started but didnt found the character for ex,cuz he spawns after the ai possesses,so thats why i tried also delay
i mean the delay is on your task tho.. why do you need that?
With and without delay,the same issue
sure but the delay doesnt make sense so why is it there
it isnt the issue but it doesnt make sense 😛
anyway i'd put a breakpoint on your nodes that assign the target and see what they do
step through that and see what gets assigned
could be anything right? get closest target could be returning none, could be the event never happens, etc
break points and stepping through it will help illuminate whts going on
also like, a delay on begin play just isnt a good solution. usually your targeting functions should probably regularly evaluate potential targets and pick one.. so it shouldnt even really be part of begin play
evaluating targets should be on some regular event
actually the delay in the bttask might cause issue now that i think a bit? why is there a delay in the task?
it def should check if the target is valid (and fail the task accordingly), but you dont need the delay... and honestly you should be checking if your target is valid in the behavior tree via a decorator so you can abort the branch if you lose the target
i deleted the valid and delay part thx
so the problem i think is in the timeline ,it runs each half a second
so the first half a second AI does not know where the target actor is
am i right?
one more thing,if i run refresh target code on tick there is no error,but its not good for performance
If your RefreshTarget function is what updates the AI so it knows where the target is, then yes in this particular graph it looks like it won't get called until 0.5 seconds later
There is a very easy solution to it though: Just call it manually after you set the timer
i just added this ,so this works
because the witcher is already in the scene and i set him the target and then every half a sec i update the target
Hi all, anyone have experience injecting dynamic tasks into a behavior tree? Essentially I'd like to create something like this:
UCLASS()
class UBTTask_DeferToSubTask : public UBTTaskNode
{
GENERATED_UCLASS_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Task)
TSubclassOf<UBTTask_BlueprintBase> SubTaskDefinedInBlueprint;
// This should initialize and defer exection to whatever the defined subtask above is
virtual EBTNodeResult::Type
ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory) override;
};
So basically a custom UBTaskNode that can defer execution to another task (defined in a Blueprint). My hunch is I'm going to need to manually manage the execution stack of the Behavior Tree, but I haven't quite figured out how to do that yet.
Is this a fool's errand to go down this path? I have had some success in having a custom node that dynamically sets a behavior tree (using gameplay tags) but that isn't as flexible as I'd like it to be.
You can call custom AI Task in your BT Task. This way you do not need to solve problem with lifecysle of BT Task and encapsulate multiple behaviors inside AI Tasks.
Oh interesting! I'm actually not familiar with the AITask construct. So rather than creating a BTTask subtask that executes my action I'd create an AITask instead and run that?
You create BT task that delegates it work to AI Task through abstract interface. And then you define what AI tasks it uses wherever you need. AI Task is very similar to AbilityTask, if you are familiar with that
Heh, I haven't gotten that far yet but that makes sense intuitively. The interface in this case would be something custom that I'd include on all of my AITask subtasks, yeah?
I'm also noticing that the default UE5 AITask is not blueprintable - which would be ideal for me. I assume there's no problem with inheriting from AITask and creating my own interface/type around that so I can define the actual task behavior in a blueprint?
Interesting idea, I would have suggested a similar solution with just a custom UObject-based thingy, but AI tasks seem like a potentially good choice for it
AITasks are generally used to expose latent AI actions to blueprints, eg. maybe you've seen the AIMoveTo node
Mates can someone help pls
here i have the whole logic of the mage enemy
so he must follow the target and when he is at the distance less than 400 he must shoot
and also if the target is too close,he must move from target
the tasks by themselves work ok
but when they are in a group like this ,they do something and then the mage just stops and does nothing
every of them has abort self
on value change
By abstract interface I mean functions of AITask itself, not concrete implementation. I never used them your way, but you should be able to inherit it and make it Blueprintable. If not, then custom implementation from UObject will do the trick, like @misty wharf suggests
you're saying move towards the enemy while you're at least 600 units away; and shoot while you're at most 400 units away; and then assuming you've failed to shoot run away while you're at most 300 units away
yeah i dont even get this logic
How should i do it?
You will both never reach the shooting condition because you're going to stop at 600 units, and then never reach the run away condition because the shooting will always succeed
Can you help me setup the distances ,observers and aborts please?🙏🏻
i am making this the 3rd day
just wanna finish it
well at a minimum make the first decorator 400, and add a second decorator to the 2nd node saying distance > 300
he just goes to the target ,and then backwards,he never shoots 😦
also what are the aborts,self to all of them?
Ah perfect, I was wondering how this worked. That's a great example.
Thank you both! Will give this a shot.
here it is,but when the AI reaches the player he instantly goes to the 3rd task
the second is ignored
and only if i am the target,and i go after the mage,he then shoots
and sadly mage does not update its closest target if he chose the AI(witcher) he will follow him until he reaches him
Try watching it in debug but my hunch is shoot isn’t allowed to run because of the distance check having to be >300 which it won’t be if the moveto makes it to 200.
Ive solved it by changing the values.It looks so good.Also the service was on receive activate ai
I changed it on tick
And its a lot better
👍 great
Hello guys, it is possible to have one way direction collision using Perception Component from unreal on AI ? Basically, I'm using bushes, and I would like AI to not be able to see what's inside, but when inside the bush, be able to see what's in the bush, and outside of the bush
I would consider approaching it by making the bushes conceal what's in it, and checking this in your perception logic
Eg. the bush has a sphere and on overlap, it would apply a gameplay tag to the actor like Actor.Status.Hidden or whatever... This would make it rather easy in your perception code to test for it and ignore the ones that have this tag
OK, so it would solve not perceived actor inside, but how to handle the other part ?
When the AI stands in the bush, and tries to perceive the world around, including other actors in the bush + the one outside of the bush
oh yeah ok, so no more collision set to block on the trace channel of the perception right ?
Yep, that way you would see in and out of the bush, but you just filter out the ones that are concealed
If you want to get fancy, you can also use the IAISightTargetInterface (C++ only) and have it report a lower sight strength when the actor is concealed :)
Hi everyone, I am using a AI perception component on my enemy to spot my player while in a certain state. However, As the AI perception doesn't go to my players head level but rather shoots straight out from the enemy it is attached to, as soon as I place my enemy in a location higher than that of me player, it will never detect it. Is there a good fix or workaround for that?
I think you need to change that in C++ : https://youtu.be/anEUhgOTKBY?list=PLJKs3BdrCfuLBiAx1fruY90cle6OjtfM_
Alternatively if you need to stick to BP, you could maybe attach an invisible actor to the player at the head position and detect this instead of the player ?
This is a UE4 C++ tutorial video that shows you how to setup the "AIPerceptionComponent" in C++ and how to change the Sight Targets / View Targets for the perception system at runtime.
#UE4 AI #AI Perception
I need to handle camouflage in my game and was thinking of it in two steps:
- Use vanilla AI perception to detect who sees who if no camouflage (bush in your case)
- Add some filter on top when receiving a new perceived actor to check if he is camouflaged (in a bush in your case)
Not sure if I will do this or directly modify the perception system though
Thats why your tree needs a decorator that ensures that the target key is valid before doing behaviors related to the target.
does RunBehavior not work for you use? it allows you to place other beheavior trees in your current tree
I don't think so - iirc RunBehavior requires that you provide the tree you want to run up front in the behavior tree - since the tasks I want to run are dynamic in nature I don't always know what they are until runtime
RunBehaviorDynamic sort of works b/c that lets me swap between different behavior trees dynamically, but it requires I build out a different tree for each task I want to execute, which is a lot of overhead
Is it possible that the peripheral half vision angle setting of AI perception also increases the vertical angle?
In this example, if i decrease the value to under 55 degrees, he would not notice me from this angle. But if it is higher, he does notice me
Am working on an AI, I have an EQS query where I need to compare something with the player character, the thing is its online and there are multiple character, in this case the AI would select one person and thats stored in a variable called "TargetActor" and there is a blackboard key with the same name. Now I don't know how to set this TargetActor to the Query Context Blueprint, there doesn't seem to be a way of getting it
I tried this but I didn't think it would work either way and it didn't.
I don't know if there is a way to pass the variable or even better the blackboard key to the query blueprint context as thats the actor I need
Hey can someone help me with an AI issue
i have an AI controller and one parent enemy class from which i created 3 types of enemies
the base enemy has the settings that he can be spawned or placed in the world
i have an actor that i want to spawn enemies
so here is the logic of the Spawner ,get a valid point on the nav mesh and spawn there an enemy
and the error i encounter is that the TargetActor is not set ,because it does not exist in that moment ig
so how can i fix it?
The last screen is enemy controller
solved it by removing the part that i underlined
Greetings, my BT has a simple MoveTo task with an EQS query service which computes a vector location the MoveTo task moves to, however even though the query runs every 0.3s, it doesn't seem like the previous location gets invalidated: the AI still moves to the previous location before moving on to the next.
How do I make it so it always moves to the updated location?
so i was trying to set the value when there was no enemy
The moveto task has a check box to update the move for changes to the destination
By default its disabled, so it would behave as you describe
to reiterate what i noted earlier, your targeting system should not be doing things on begin play, it should be evaluating and picking targets at regular intervals, and your behaviors should be divided into having a target and not having a target so they dont get into these types of situations
regular intervals you mean tick?
doesnt have to be
It's "observe BB value", right? Thank you 🙂
ai in unreal uses a* by defaulr right?
If you're referring to the navigation system, probably. The navmesh system is pretty complex so not 100% sure, regardless of what it does it's a solid system that works
theres some a* files in the engine tho
I have a guy walking between points on a fairly fine grained spline. It works, but the guy briefly pauses at the end of every step.
Do BTs take a frame to pass through each node or something?
I can tell that the unit is stopping but I would have thought it would go throught the BT chain to get to the next move step smoothly
State back to itself. Basically when the move to completes it might want to move again right after. The way state trees work is that even if I go back to root after completing my move to state it can find it's way back to the move to state if the conditions are still valid. And the instance data of that move to state are still there.
Hello, the pedestrian is supposed to run away when a gunshot is fired, but currently he runs away at every sound. I wanted to control this via a report noise event with the tag Gushot but unfortunately the sound is not filtered - any ideas?
Have you tried using EQS to filter the sounds like I said?
Hey, unfortunately I'm not at all familiar with the EQS🙈
Pinned video here on BTs covers EQS as well
Yeah, the instance data doesn't reset on every tree evaluation. You will have to reset it somehow OnEnter
Does anyone know about how to get a Pawn to pick the correct navmesh? I have two Supported Agents setup in my project settings: a default navmesh agent with radius=35, and a LargeRadius with radius=200.
I'd like to have a tank that uses the pink navmesh (while soldiers use the green one). On BeginPlay, the tank tries to draw points that it'd use to get to the goal marked in yellow...
what is the pathfinding context in your case?
@radiant path Tbh I just noticed that my Actor/Pawn (a child of WheeledVehiclePawn) came with a Get Pathfinding Context, so I plugged it in. I had also tried this with nothing plugged in there at all and had the same issue. I'm not sure what should go there
The pathfinding context is where it gets the NavData\NavAgent from
This is ugly, but it seems to work.
I'm trying to see if there's better way to pick the correct NavMesh other than string comparison 😅
input self into the Pathfinding Context, then edit the agent settings in the MovementComponent
oh you actually may not need to update it, since it defaults to updating from the collision size
so just inputting self into pathfinding context should be enough
Heya o/ Anyone happens to know how Behavior Tree Task execution behaves in relation to tick? My understanding was that in a single frame the free executes from root as far as it can go, as long as the tasks immediately return success/failed and not InProgress. I'm facing a strange behavior where it seems like nodes in Sequence take a tick EACH to execute? They all (apart from the Move one) return success instantly, and have very little logic, mostly single line of cpp, yet logging inside their ExecuteTask shows up to ~30ms gaps between them.
I've found another way to check the times directly in the BT and the logs match this time difference. The MoveTo took same time as the next node, which only has single line of code internally and returns Success. Am I perhaps missing some general BT setting that makes it behave this way?
One per tick is more than enough. And move to nodes will take a lot longer than a tick to complete, for obvious reasons. Your AI’s behaviour doesn’t need to execute in one frame. If you need stuff to happen in one frame, put it in a function.
One node per frame is not nearly enough. The MoveTo node finishes instantly if the target is already in the range, hence why it takes ~13ms for me, same as the next Node which only does 1 line of code, so that isn't the issue in this case either. I'm aware I could just ditch the BT entirely and write my own thing in tick, but since BT is a thing already, I was trying to leverage it. From what I've found it seems the BT should execute as much as it can until it hits a latent task, however perhaps this isn't correct - I've found a mention of the BT's behavior changing around UE 4 or so.