#gameplay-ai

1 messages · Page 63 of 1

sleek grotto
#

Okay I'll try that. I got frustrated because it was running the emerging over and over again even though it should've been running the loop (so the montage was repeating over and over)

vivid fern
#

since the navmesh represents all the places you can stand as an ai on navmesh

sleek grotto
#

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.

vivid fern
#

i mean if its going to out of combat, it probably means your target sensed stuff is wrong?

sleek grotto
#

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.

vivid fern
#

oh i guess abort self is also needed maybe your both setting was right haha

sleek grotto
#

Nope still doing the same thing..

vivid fern
sleek grotto
#

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)

vivid fern
#

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

sleek grotto
#

What is the fail case? All of the tasks I am using (that aren't core tasks) are force set to 'success'

vivid fern
#

that cool down decorator

sleek grotto
#

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

vivid fern
#

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

sleek grotto
#

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?

vivid fern
#

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

sleek grotto
#

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.

vivid fern
#

show your current tree

sleek grotto
#

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.

vivid fern
#

this is what i've got for my tiny little not fleshed out combat stuff

sleek grotto
#

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.

vivid fern
#

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

sleek grotto
#

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.

vivid fern
#

something about the loop sequence is failing then

sleek grotto
#

OH, it broke that time

#

Do sequences only do the next sequence after it receives a 'success' from the previous one?

vivid fern
#

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

sleek grotto
#

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.

vivid fern
#

one at a time in both cases

sleek grotto
#

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.

vivid fern
#

might have worked due to the layout of your tree

#

just by chance 😄

sleek grotto
#

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

vivid fern
#

i do have a non combat state, but this is a subtree of the overall tree

sleek grotto
#

err this is frustrating

vivid fern
#

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

sleek grotto
#

hmm why are some of your decorators dark blue and the rest are light blue?

vivid fern
#

cuz they're bubbled up from their sub trees

#

the subtrees have those decorators

sleek grotto
#

ah

vivid fern
#

at least iirc ahha

sleek grotto
#

hmm I can't remember how to add a sub-tree

vivid fern
#

run tree or whatever

#

youdont have to do that.. i just do it cuz organization reasons haha

sleek grotto
#

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

vivid fern
#

you can make the selector always return true

sleek grotto
#

You can?

vivid fern
#

there's a decorator that does it yeah

sleek grotto
#

Oh shoot I didn't even see that. Force Success

vivid fern
#

doesnt solve the underlying problem of why your node fails tho, just hides it.. so i would solve that tbh

sleek grotto
#

I think it's just because yeah, the cooldown on the 'ability' (or the player not being in range), is causing it to fail

vivid fern
#

yeah tbh a combat loop has the "do attack" and then "do something while i wait for my attack window again"

sleek grotto
#

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?

vivid fern
#

sure, you could also just take out the cooldown right

#

selector-> do attack -> wait

sleek grotto
#

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

vivid fern
#

you have to handle all the cases

#

if player out of range needs a fall back too

sleek grotto
#

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.

vivid fern
#

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

sleek grotto
#

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.

vivid fern
#

er yes service is what i meant haha

sleek grotto
#

I appreciate all the help you gave me.

vivid fern
#

oh haha well depends on how your characters work i suppose

#

yep yep!

sleek grotto
#

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!

vivid fern
#

np

sleek grotto
vivid fern
#

chompy chomp

sleek grotto
#

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

vivid fern
#

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

sleek grotto
#

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.

vivid fern
#

yes

#

maybe your range check is wrong

oblique ridge
#

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.

harsh storm
#

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.

oblique ridge
#

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.

vivid fern
#

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

oblique ridge
#

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.

harsh storm
#
  1. I wouldn't do it like this - wouldn't even use perception personally. But that's more of a choice.
  2. 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.
vivid fern
#

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

oblique ridge
#

.... AAAHHHhhh... I think i see what you're saying

sleek grotto
#

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

oblique ridge
#

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

harsh storm
#

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.

oblique ridge
#

Yeah, that makes sense

#

Random question, is there a way I can just "unregister/register" a pawn to be perceived by the percpetion component?

harsh storm
#

I don't think it is available in BP. I've never done it personally though.

oblique ridge
#

I thought if I had an UAIPerceptionStimuliSourceComponent, it would be pretty straight forward

#

but it doesn't seem to do anything

vivid fern
#

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

oblique ridge
#

So maybe i do this state checking in the BT instead

harsh storm
#

This is where Luthage would say to use EQS for target management.

vivid fern
#

hehe yeah

oblique ridge
#

AAAHhhh ok. So, I could just create a service that does this and call it a day.

harsh storm
#

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

oblique ridge
#

no, they def do not. Ok, will do. Thank you

sleek grotto
oblique ridge
#

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?

dense owl
#

Which is not really hard to do

north geyser
#

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

steel moat
#

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

digital sparrow
#

What would be the best way to find all the players that a pawn is able to navigate to in Unreal?

vivid fern
#

like every player or players within a certain search area?

digital sparrow
#

Well there's only like 5 players

vivid fern
#

you can probably do an eqs, or just iterate over the players and see if you can path to them

steel moat
#

eqs is not yet stable right?

vivid fern
#

why?

#

eqs has been around for literal years at this point

#

iirc

steel moat
vivid fern
#

?

#

what are you trying to do?

steel moat
#

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

vivid fern
#

yeah eqs only seems to return one point.. but why did you need several?

steel moat
#

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

vivid fern
#

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

steel moat
#

but it only returns a single point right? i wanted to make it loop and return few more

vivid fern
#

only one point yeah, but i repeat the query every iteration and go somewhere new

steel moat
vivid fern
#

yeah

#

in the behavior tree, its a number of search locations or a time out for me

steel moat
vivid fern
#

sure why not? a bb key can do that

steel moat
#

:0

#

i couldnt do it at that time so i dropped eqs

vivid fern
#

also looks pretty extendable via code, you can define new test types, query contexts etc

steel moat
#

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

vivid fern
#

valid

slow bobcat
#

My guess is that you can extract the node name from there

brave phoenix
vivid fern
#

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

sacred kiln
#

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?

uneven cloud
sleek grotto
#

Is there a node for that ?

uneven cloud
uneven cloud
steel moat
#

in 5.0?

uneven cloud
steel moat
#

:0 I had a huge misunderstanding related to EQS damn

uneven cloud
#

One of the run modes is to return all results.

#

Allora's solution is better, though

dire jungle
#

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

regal egret
#

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

🤔

#

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

sleek grotto
uneven cloud
misty wharf
#

iirc that omits Z

sleek grotto
#

Yeah I see that node now. I am not sure how to convert to a 2d vector though since they are all in 3d.

misty wharf
#

Yes that works on 3d vectors

sleek grotto
#

Oh it does it for you. A second ago it told me it couldn't do it but now it's taking it.

uneven cloud
sleek grotto
#

Yeah I found it. It wasn't showing up at first.

#

wow that is much better

#

yep works like a charm, thank you

drowsy raven
#

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?

misty wharf
#

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

drowsy raven
#

My mistake, I send it in the wrong category 🙂

#

Thanks btw

north geyser
slow bobcat
#

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

north geyser
vivid fern
sleek grotto
#

There was a conversion pin for it 😄 didn't accept it at first but after I kicked it in the patoot it worked.

mental perch
#

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

vivid fern
#

what are you actually trying to do?

mental perch
#

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.

brave phoenix
#

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

vivid fern
mental perch
vivid fern
#

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

placid storm
#

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.

vivid fern
#

the cubes cut navmesh so there's no path

placid storm
#

OH

#

So they're like...on little islands?

placid storm
vivid fern
#

nodnod

steel moat
#

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;
}
vivid fern
#

project point to nav returns the closest point on navmesh, test path sync tests whether there is a path between two points

steel moat
vivid fern
#

what does it do in later versions? ProjectPointToNavigation still works the same afaik

steel moat
#

TestPathSync returns true

#

im trying to debug in which cases it returns true

vivid fern
#

i'd assume that none of the images above return true

#

for test path sync

steel moat
#

it returns true in the first pic

#

that is of version 5.0 tho

#

all three of the pics

vivid fern
#

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

steel moat
#

wait maybe its just my imagination that its not working fine...

#

no theres something wrong

steel moat
#

it doesnt happen in older versions tho

steel moat
vivid fern
steel moat
#

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

vivid drift
#

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

vivid fern
#

its on top of the cube probably because your volume is taller than the cube

vivid drift
#

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

vivid fern
#

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

vivid drift
#

right but that only seems to apply when the nav is literally underneath it. Not when it's inside it.

vivid fern
#

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

vivid drift
#

my mind goes to all the functions like "random navigable point in radius" which doesn't seem to take any particular actor's perspective

vivid fern
#

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

vivid drift
#

right but I'd much prefer to just generate the navmesh corectly and check for navigable points

dense owl
dense owl
vivid fern
vivid fern
#

Iirc anyway haha I'm not at a computer to check

dense owl
#

I haven’t checked tbh 😅

vivid drift
#

Ok but is there really no such thing as just a blocker volume that says "don't generate any nav mesh in this area"

dense owl
vivid drift
#

why not place it on the cube?

dense owl
#

Seems hacky

vivid fern
#

why does it matter?

#

you cant reach that navmesh

dense owl
#

That too

#

Unless you put a nav link there no one can hop over into the cube

digital sparrow
#

How are you supposed to use AIPerceptionStimuliSourceComponent in C++? It's variables seem to be private to C++

#

Like auto register as source

steel moat
#

through c++?

digital sparrow
#

Or am I thinking about it wrong

steel moat
#

I thought i added it through c++ but no

#

sorry

mild walrus
#

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

misty wharf
#

navmesh doesn't support that at all

mild walrus
misty wharf
#

Some custom navigation solution maybe. Perhaps EQS can be used to generate points along the walls/ceilings and you can manually move towards those

vivid fern
#

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

misty wharf
#

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"

sleek grotto
#

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

harsh storm
#

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.

sleek grotto
#

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.

mystic root
gaunt shard
misty wharf
#

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

vivid fern
vivid fern
#

they'll clump around corners, still, but that generally helps a bunch

vivid fern
#

since lots of things tend to be spawned

sleek grotto
#

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:

vivid fern
#

did you break point your context to see if its doing what you think?

sleek grotto
#

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)

vivid fern
#

i'd break point it to see what the context is returning

sleek grotto
#

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.

misty wharf
#

Breakpoints happen whenever the code is ran

vivid fern
#

^^

#

but also i'd say get used to testing in game too? like... this is how you will ultimately have to debug things..

sleek grotto
#

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.

vivid fern
#

i mean the eqs runs at editor time, so you will still hit this breakpiont

sleek grotto
#

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

granite mesa
#

Hello

#

Does any one have idea how to use delay function in cpp?

slow bobcat
#

I think in cpp you use a timer or, even better, you use an Event-Driven approach

dense owl
#

Or coroutines

slow bobcat
#

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

dense owl
spare lintel
#

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

misty wharf
spare lintel
misty wharf
#

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

spare lintel
#

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

misty wharf
#

Yeah no idea why they didn't think of supporting it

#

seems like such an obvious thing to have

spare lintel
#

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!

misty wharf
#

👍

shadow sierra
#

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?

vivid fern
#

It has an option you can pass

narrow onyx
#

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

uneven cloud
# steel moat but i found an alternative

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.

uneven cloud
vivid fern
#

ahh

#

makes sense

#

and yeah sounds like it would be needed heh

uneven cloud
digital sparrow
#

I mean the former

#

I need to stop my player being a stimuli source on death

uneven cloud
digital sparrow
#

There's protected variables

#

And yeah, it goes on the pawn

uneven cloud
#

Protected variables are available to child classes. But I don't remember seeing any for the stimuli source.

vivid fern
#

there's no privates in the stimuli source .. so everything should be there for derived classes

uneven cloud
wild parcel
#

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.

vivid fern
#

write your own moveto behavior tree node

mint terrace
#

you're looking for BT Tasks

vivid fern
#

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

spring jetty
#

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 ?

uneven cloud
spring jetty
#

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

bright girder
#

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?

uneven cloud
uneven cloud
misty wharf
worthy lagoon
#

Anyone know a good tutorial series on making NPC's with routines i.e. talk to each other, carry crates, go to sleep etc

vivid fern
trim bone
#

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?

vivid fern
#

yeah its pretty straight forward to do that.. there's already a bp node for spawning ai actors

dense owl
#

Also DataAssets are nice to use for spawning stuff

vivid fern
#

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

dense owl
#

Yeah, EQS contexts are handy

trim bone
#

Oh, that's all super good info! What kinda stuff do you have in the DataAssets?

dense owl
#

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)

trim bone
#

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

dense owl
#

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

trim bone
#

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

dense owl
trim bone
#

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

trim bone
dense owl
#

There probably is, but maybe not built-in. Expose on Spawn only shows on the node when the class is selected beforehand

trim bone
#

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

dense owl
#

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

trim bone
#

I'll look around and see what I find, thanks!^^

trim bone
vivid fern
#

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

trim bone
#

Is there a trick to expose different properties in the data asset based on a selected reference to a class in the asset?

vivid fern
#

what do you mean?

trim bone
#

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.

vivid fern
#

DA?

#

data asset?

trim bone
#

data asset

#

yes^^

#

sorry, I start abbreviating randomly ^^;

vivid fern
#

just spawn a diff bp? i dont see what you mean

trim bone
#

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^^;

vivid fern
#

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

trim bone
#

possibly... I'm redoing our whole AI system, so I've just been trying to think through best ways to achieve our different goals...

vivid fern
#

really depends

trim bone
#

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

vivid fern
#

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

trim bone
#

fair point^^

#

thank you for talking it through with me!^^

vivid fern
#

np!

opal cosmos
#

How can I stop my beaviour tree here as behaviour tree is probably casing my engine to crash

lyric flint
#

Hi all,
How would i go about making an A-Life system similar to STALKER?
Thanks

slow bobcat
#

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

sour thistle
hardy sable
#

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

misty wharf
#

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

hardy sable
#

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

shadow sierra
#

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?

slow bobcat
# shadow sierra Our AI characters are consistently aborting MoveTo requests in packaged game and...

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

vivid fern
#

you arent going to get a useful answer i think... break your problem down into smaller parts and solve the smaller parts

misty wharf
#

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

vivid fern
#

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"

misty wharf
#

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

vivid fern
#

honestly it sounds like you need to visit the basics before you can tackle this problem

misty wharf
#

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

vivid fern
#

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

misty wharf
#

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

vivid fern
#

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

dense owl
#

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

vivid fern
#

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

dense owl
#

good, makes me feel better about my approach to problems which is basically iterate and make small adjustments until I find the solution 😅

opal cosmos
#

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

vivid fern
#

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

glossy swan
#

What could be the reason that FindPathSync (C++) finds a non-optimal (not straight) path in backward direction ?

near flame
#

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

radiant path
glossy swan
radiant path
#

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.

radiant path
#

Possibly look into NavCorridor

glossy swan
# radiant path 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);
                }
            }
radiant path
main lark
#

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!

analog mural
#

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?

dense owl
analog mural
dense owl
#

For the first one to abort the BB key itself does not have to change

#

To a diff bb key or nullptr that is

dense owl
glossy swan
steel moat
slow bobcat
sick quartz
#

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

radiant path
near flame
#

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?

glossy swan
slow bobcat
#

Like the one you just did there

radiant path
radiant path
glossy swan
# radiant path Seems a lot better, the area in red doesnt seem bad either? possibly just some m...

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

slow bobcat
#

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?

glossy swan
glossy swan
rapid birch
#

how to stop move to location or actor movement??

river storm
#

has anyone used IAISightTargetInterface::CanBeSeenFrom() in an async fashion by calling the FOnPendingVisibilityQueryProcessedDelegate delegate it passes to the function?

slow bobcat
# glossy swan Do you mean standalone builds ? not PIE ? I print a current StateTree state for ...

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

feral bluff
#

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?

slow bobcat
feral bluff
slow bobcat
#

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

feral bluff
slow bobcat
#

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

glossy swan
signal island
slow bobcat
signal island
vivid fern
#

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

glossy swan
radiant path
#

that seems like a rather odd path

#

what does the navmesh look like if you turn it on?

glossy swan
radiant path
#

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

signal island
#

Just making sure everyone knows but you can run state trees inside behavior trees. This is really powerful.

feral bluff
#

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.

signal island
feral bluff
vivid fern
#

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

feral bluff
vivid fern
#

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.

haughty coral
keen palm
#

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!

glossy swan
zinc maple
#

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.

rugged tree
#

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 ?

vivid fern
#

if the move to fails it likely cant generate a path

rugged tree
small moat
#

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

slow bobcat
vivid fern
#

?

slow bobcat
#

Sorry no idea wtf happened with the tag there

#

Fixed

vivid fern
#

aha ok

thick walrus
#

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.

misty wharf
#

This should give you a point on the navmesh

thick walrus
#

Thank you so much! Works perfectly. I feel like the AI stuff could be a bit better documented 😅

vivid fern
#

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

vivid fern
stone walrus
#

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

trim bone
#

What do y'all think the best way to handle AI that gets knocked off of a navmesh is?

stone walrus
trim bone
#

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

stone walrus
#

u mean when your player character punches your ai it get onto prop somehow and underneath props there is no nav mesh

trim bone
stone walrus
#

go into bp of ur prop and un check can affect navigation

#

this will solve ur problem

trim bone
#

Well, I don't want the AI to wonder onto the props

#

that's why we had the props blocking it

stone walrus
misty wharf
#

This could be done with something as simple as having the AI literally jump to the closest navmesh point

vivid fern
#

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)

trim bone
#

And then just use traces to keep them on the ground… good stuff thanks y’all!

vivid fern
#

you can actually apply direct move directions to the cmc. so if you have a move vector you can apply it this way

muted copper
#

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

trim bone
vivid fern
#

iirc? dont quote me on it but the cmc handles groundedness

trim bone
digital pasture
#

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

misty wharf
#

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.

digital pasture
misty wharf
#

🤔

#

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

digital pasture
misty wharf
#

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

digital pasture
misty wharf
#

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

digital pasture
# misty wharf The one case I could see where it might happen is if you have configured your pa...

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

digital pasture
digital pasture
# misty wharf The one case I could see where it might happen is if you have configured your pa...

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.

misty wharf
#

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

digital pasture
#

That was it

misty wharf
#

I'm assuming your delay is there because the pawn isn't immediately available on Begin Play?

digital pasture
#

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

misty wharf
#

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

digital pasture
#

That is just to set the variable for it's controlled pawn so I can call certain pawn bound events throughout the code

digital pasture
#

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

opal cosmos
#

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?

slow bobcat
# opal cosmos Hey there, I m actually making a combat game and I want to have a team of enemie...

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

misty gale
#

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

vivid fern
#

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

misty gale
#

It wasnt ment to hit or notify them all in the described scenario, just nearby ones

vivid fern
#

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

slow bobcat
# misty gale While im a big fan of directors, id personally probably just do a sphere trace c...

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

vivid fern
#

(and ultimately you'll make some central place to coordinate ai anyyway)

vivid fern
#

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

misty gale
#

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

misty gale
vivid fern
#

traces (lines or sphere) are slower than distance checks.

misty gale
#

1 to 1, sure

slow bobcat
#

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

opal cosmos
#

is the conversation still about group enemy AI?

slow bobcat
#

My point is that it leads to a quick way of querying them

vivid fern
# misty gale 1 to 1, sure

you'd have to get to some pretty dense populations before that made a big difference imo, as always prfoile.

slow bobcat
#

Yeah

opal cosmos
#

I still have to read the texts gimme a min

slow bobcat
#

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

vivid fern
#

in the majority of cases, esp in shooters, you dont need much more than 2d sqr dist checks

slow bobcat
#

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

vivid fern
#

yep yep

slow bobcat
#

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

vivid fern
#

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

misty gale
#

Very good points for sure

#

Curation with teamid is a good start

slow bobcat
#

Yep. Can't agree more

flat dome
#

Are state trees considered useable now?

#

I still can't quite grasp and understand the behavior tree system

keen palm
#

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

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

slow bobcat
misty wharf
#

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

slow bobcat
#

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

misty wharf
#

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

slow bobcat
#

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

keen palm
flat dome
#

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

slow bobcat
#

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

flat dome
#

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

grand copper
#

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❔

misty wharf
vivid fern
#

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

misty wharf
#

Yeah that's pretty much what mine does

vivid fern
#

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

fallow gust
misty wharf
#

So it's slightly more error prone in terms of typos but that's about it

red wyvern
#

Anyone know how to extend the age of an AI sight stimuli?

dense owl
#

Idk if it works after it’s been sighted (during) tho

vivid fern
#

what are you actually tring to do

red wyvern
dense owl
red wyvern
#

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

burnt kestrel
crude sequoia
#

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 monkaHmm

cursive ibex
crude sequoia
vivid fern
#

you can also provide a context via bp for what its worth

#

oh i see you did start with that

celest python
wooden echo
#

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

wooden echo
#

apparently the issue simply fixed itself...

cloud stream
#

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

wooden echo
cloud stream
wooden echo
cloud stream
wooden echo
cloud stream
#

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?

wooden echo
#

i am confused now, do you have a pawn or a character?

wooden echo
cloud stream
wooden echo
cloud stream
# wooden echo well the friction thing is only in the cmc, but i guess thats not the actual iss...

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)
wooden echo
#

why isnt all this stuff in the character bp?

cloud stream
#

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!

wooden echo
#

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

cloud stream
cloud stream
wooden echo
#

no it was somewhere in project settings afair

cloud stream
wooden echo
#

it caused friction even when everything in the CMC was set to 0

cloud stream
#

oh man, "project settings"... 😱

wooden echo
cloud stream
#

well anyway, thank you for your help!

wooden echo
#

you welcome 👋

burnt kestrel
dense owl
#

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)

burnt kestrel
#

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!

signal island
#

is ther a way of sending an event to a StateTree running on a BT?

uneven cloud
uneven cloud
uneven cloud
uneven cloud
crude sequoia
uneven cloud
crude sequoia
#

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.

digital pasture
# uneven cloud You should never use begin play to set up the AI controller. Certainly not with...

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?

uneven cloud
crude sequoia
#

Oh wait, thats right FailFish

crude sequoia
uneven cloud
uneven cloud
crude sequoia
#

So I can call them separately and they both work since they call different SetValue functions monkaHmm

#

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.

vivid fern
#

what are you trying to do?

crude sequoia
vivid fern
#

mostly atm it seems like an xy problem

tawny plume
#

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.

dire jungle
#

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

slow bobcat
dire jungle
slow bobcat
#

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

harsh storm
#

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.

slow bobcat
pliant vine
#

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

dire jungle
pliant vine
slow bobcat
glossy swan
#

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.

misty wharf
#

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 🤔

raven nacelle
#

You can do this by outputting links to Evaluator or whatever they're called using reference. I did this for an old project.

glossy swan
#

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.

dire jungle
odd tide
#

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)
{
}
honest wasp
#

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

honest wasp
misty wharf
#

(each possible queue has its own queue manager)

honest wasp
#

Thank you! That’s somewhat along the lines of what i was thinking, good to know I’m on the right track.

rancid mural
#

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?

cosmic stag
#

Is there any way to run EQS queries synchronously?

vivid fern
#

out of curiosity why do you need synchronously?

#

generally speaking its pretty ok to let AI be pretty slow at processing things

dense owl
#

“Slow”

vivid fern
#

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

random jay
random jay
slow bobcat
#

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

misty gale
#

Players likely wouldnt know even if it was 10 frames behind

dense owl
#

You should totally do everything synchronously, I’m sure your plan will work without a hitch ||/s||

solid spire
#

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?

slow bobcat
near flame
#

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

vivid fern
#

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

near flame
#

Move to default one moves only to the player

vivid fern
#

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

vivid fern
#

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

near flame
#

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

vivid fern
#

why do you have a delay?

#

i'd step through your code that assigns the target

#

see what it actually does

near flame
#

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

vivid fern
#

i mean the delay is on your task tho.. why do you need that?

near flame
#

With and without delay,the same issue

vivid fern
#

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

vivid fern
#

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

near flame
#

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

misty wharf
#

There is a very easy solution to it though: Just call it manually after you set the timer

near flame
#

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

fathom salmon
#

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.

open yacht
fathom salmon
open yacht
#

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

fathom salmon
#

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?

misty wharf
#

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

misty wharf
near flame
#

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

open yacht
vivid drift
near flame
#

yeah i dont even get this logic
How should i do it?

vivid drift
#

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

near flame
#

i am making this the 3rd day

#

just wanna finish it

vivid drift
#

well at a minimum make the first decorator 400, and add a second decorator to the 2nd node saying distance > 300

near flame
#

he just goes to the target ,and then backwards,he never shoots 😦

#

also what are the aborts,self to all of them?

fathom salmon
#

Thank you both! Will give this a shot.

near flame
#

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

nova cargo
near flame
#

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

nova cargo
#

👍 great

tidal seal
#

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

misty wharf
#

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

tidal seal
#

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 ?

misty wharf
#

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

slim sonnet
#

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?

keen palm
# slim sonnet Hi everyone, I am using a AI perception component on my enemy to spot my player ...

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

▶ Play video
keen palm
vivid fern
vivid fern
fathom salmon
# vivid fern does RunBehavior not work for you use? it allows you to place other beheavior tr...

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

slim sonnet
#

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

sleek lynx
#

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

near flame
#

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

quick fractal
#

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?

near flame
#

so i was trying to set the value when there was no enemy

vivid fern
#

By default its disabled, so it would behave as you describe

vivid fern
# near flame solved it by removing the part that i underlined

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

near flame
#

regular intervals you mean tick?

vivid fern
#

doesnt have to be

quick fractal
vivid fern
#

yeah

#

basically it registers for a delegate on bb value change

waxen portal
#

ai in unreal uses a* by defaulr right?

misty wharf
#

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

waxen portal
#

theres some a* files in the engine tho

vivid drift
#

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

solid spire
robust pumice
#

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?

dense owl
#

Have you tried using EQS to filter the sounds like I said?

robust pumice
dense owl
slow bobcat
short mulch
#

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

radiant path
#

what is the pathfinding context in your case?

short mulch
#

@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

radiant path
#

The pathfinding context is where it gets the NavData\NavAgent from

short mulch
#

I'm trying to see if there's better way to pick the correct NavMesh other than string comparison 😅

radiant path
#

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

dim elbow
#

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.

dim elbow
#

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?

dense owl
dim elbow
#

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.