#gameplay-ai

1 messages Β· Page 137 of 1

opal bolt
#

I am not sure. I currently thing I do not want that.
So. In the end your are right, totaly. In the end, I want ANavigationData.
But ... EQS as I see, is using filter for this. Or I missunderstand the concept.
I think it works like that:

#

one moment

#

^^something I can select in this box. And as I understand, these are filters.

pine steeple
#

right but like i said, filter does not have a concept of NavigationData

opal bolt
#

So, you think it's not possible?

pine steeple
#

i can see its not possible using just a filter

opal bolt
#

hmm, ok, I still wondering but I know you have big knowledge. I have to think abou it.

pine steeple
#

what is running this EQS?

#

the pawn with the different navmesh?

opal bolt
#

Normaly I make much use of EQS Test pawns which are built in in ue4 to make the EQS ready. Then yes, it will run by and agent which is an AI pawn character.

#

Or... one moment. Perhaos I thought the wrong way around, and when the AI pawn is executing the EQS, then it simply use the NavMesh which fits to the supported agent by default...

#

of man, perhaps I simply have do do nothing right?

pine steeple
#

^

#

it should pull the correct navdata for that pawn

opal bolt
#

oh, f**k, hours for nothing. Just a misconception in my mind perhaps. Yes, UE4 could have built in to take the appropriate nav mesh when executing EQS with AI pawn. You are right. I am not sure, but I have to test.

Sadly, I can not test it with EQS Testing pawns then. But that's not so important.

pine steeple
#

yes you can

#

adjust the agent props for it

#

to match your bigger AI

#

and it should use the correct data (can breakpoint the function in the generator)

opal bolt
#

Did you every used a custom Recast Mesh for a supported agent?

#

Or do you also use the default ones?

#

I aks because I think, if I understand how to use this, this is also somethig I could use to determine on which navmesh EQS is running. Because in EQS Testing pawn I can select the same as in "Supported agent" configuration. But I did not find any good documentation and examples about this "custom recast" navmeshes and when/how to use

fresh remnant
#

any tips on optimizing behavior tree ticks when idle? The ticking is costing about 3-4ms of my frame time with 600 characters.

#

ideally I would want that down to 0

#

all its doing is waiting for an order/blackboard order set, but it's taking so much time

ocean delta
#

is there a way to get the AI to keep chasing the player even if losing sight of the player?

#

i'm looking at prediction sense but i'm unsure if that's what it is

feral marsh
#

Hey guys, how are you all doing today? I have a question and I don't know if that's the right place or not, I have an Ai that moves randomly and the animation plays normally but when added a statement to the move to it doesn't play the animation like for example its T-posing hovering to exact location, Now I don't know if that's a problem with the animation or not, thanks in advance | TLDR: Ai's animation plays normally but bugs out when added statement | Update: I tried this fix: https://answers.unrealengine.com/questions/821053/how-to-use-paragon-assets-for-ai-character.html but nothing... I do think its something wrong with the BT but I am not sure

ocean delta
lyric flint
#

Most likely the rotation works correctly, but your RotationRate is too high, so when applying the Delta, it appears to snap. I may be wrong.
As for chasing after losing sight, most likely you would need to fiddle with OnTargetPerceptionUpdated, and if the Stimulus.IsActive() is false, add some code to randomize some frantic patrolling on random points around the location when it lost sight

ocean delta
#

okay, so i was able to get it to stop losing threat when it loses sight. my next problem is just the rotation rate but i guess i can tackle that at another time

#

Use controller rotation yaw was enabled πŸ™„

#

it's all fixed, thanks @lyric flint

brittle coyote
#

Hello guys! I'm trying to simulate the bee behavior and I want to increase a variable from the Blackboard of the behavior tree each time that a bee (getting the index value of the actor of the class array) hits a flower! I thought I've done it properly but still I get an error! This is the screen of the Blueprint. Does anyone know how to fix this?

brittle coyote
#

nobody knows?

pine steeple
#

Please be patient when asking questions.

brittle coyote
dawn crystal
#

What is needed to create a Nav Mesh Bounds volume? I have a Cartoon Water Shader and I would like to make a Nav Mesh on the water

#

but the water doesnt have any collision by default

dawn crystal
#

or in other words, Is it possible to create a Nav Mesh Bound Volume at surface which doesnt have a collision???

lament linden
brittle coyote
lament linden
#

Ooh, nice ahahah

#

Looks like the blackboard is not initialized when you are trying to do the update

#

Can you print the blackboards first to see if this is the case?

brittle coyote
brittle coyote
dawn crystal
brittle coyote
dawn crystal
#

great

brittle coyote
#

oh sorry nope! I've though about nav mesh volume

dawn crystal
#

yes

#

I have currently a nav mesh bounds volume

#

and I would like to make a Ai for ship with using a Cartoon Water Shader

brittle coyote
dawn crystal
#

the "water/ocean' doesnt have a collision

#

and my Nav Mesh cannot be created

#

thats why I am asking

lament linden
dawn crystal
#

Is there a possibility to make a something like nav mesh, which can allow the Ai to move to location within the Nav Mesh

brittle coyote
dawn crystal
#

I cannot have a collision set up at Water shader

#

Water actor etc.

brittle coyote
dawn crystal
#

hmm

#

ehhh, so I am gonna to test a kind of cases

brittle coyote
dawn crystal
#

maybe something will works

lament linden
#

Hmm. Why do you increase the blackboard value for all bee's when one bee hits a flower?

brittle coyote
#

but I want to update only the specific index of the bee who's hitting not all of them

mighty mesa
#

Hello. I can use the blackboard and the behavior trhee using a pawn and not the character?😬

earnest kelp
#

I'm trying to get the ai to predict where to shoot the player so I've implemented this code but it doesn't seem to work. The code is fired straight from the behaviour tree, it fires but it doesn't see to predict where the player is. Thanks!

pearl flint
#

So i have a auto generating map but my ai cant go till the and and stucks at the second room and cant go more but i did nav mesh bounds at the whole map so why is this happening?

#

not moving more than this

#

this is the bp of the ai

misty wharf
#

Check if your navmesh is generated on the new areas of the level

pearl flint
#

@misty wharf it generates the level map when i touch to a trigger box so idk if it updates to that place or not

#

but i did nav mesh to the whole map

misty wharf
#

Okay, you can detach while you are in play mode, then click the "Show" button on top left of the window

#

choose Navigation from the Show menu and you should see an overlay where the navmesh is generated

pearl flint
#

lemme check

#

nope it isnt generating for the new levels

misty wharf
#

If you haven't enabled it, change the navigation mesh Runtime Generation option to Dynamic in your project settings, that should probably fix it

pearl flint
#

lemme check

#

@misty wharf is this alright?

misty wharf
#

Yeah, Dynamic should make it regenerate it at runtime when geometry changes

pearl flint
#

it works tysm :)

pine steeple
#

glad you sorted it :), be wary that adding new navmesh tiles can cost a bit, so tweak your tile size and cell sizes to get the biggest values that still allow for good pathing

#

to reduce the generation time

misty wharf
#

Does that get worse with overall size of navmesh, or is it primarily affected by size/complexity of the newly generated areas?

pine steeple
#

generating navmesh costs game thread time

#

so if you generate a lot of areas, you will get hitches

pearl flint
#

owhh

#

sorry im new at this but i will take your advice thx :)

pine steeple
#

yes, the quicker your navmesh generates, the smoother for players

misty wharf
#

Sounds like it's maybe more constrained by size of the changed areas πŸ€”

#

My game will have to do a whole bunch of regeneration since the player can build and move things about, so far it really isn't noticeable at all :D

clever skiff
#

anyone able to take a look at my ai. i have it set to play an animation if it at a certain distance. the behavior tree fires the branch where the montage is set to play but the montage does not play. do i need to set up the montage in the animation blueprint where i have the walk and run state.

#

i cant seem to find a solution

misty wharf
#

Not really an expert on animations, but maybe try disabling the other animations so there's no animations whatsoever, and see if the montage plays then

#

If the montage plays when the rest of the animations aren't ran, then it seems to suggest that the other animations are taking priority over the montage and you might need to do something about it

#

If it doesn't play, then it seems that your BT task most likely isn't actually triggering the montage correctly

pine steeple
#

@misty wharf on my pc the navmesh generates fast, but on older pc's they will feel the hitch

#

which is why we have testers with different spec pc's

misty wharf
#

Okay, good thing some of our testers aren't running the fastest PC's so we can ask them to see if they notice anything :D

pine steeple
#

yeah best way

misty wharf
#

It probably shouldn't be too bad even if it hitches a bit, since it would be only done when you place something down, so you're kind of completing an action and it probably hides it a bit if so

pearl flint
pine steeple
#

8gb ram is pretty low for UE4 development

pearl flint
pine steeple
#

my pc runs at 20-32gb ram use majority of the time πŸ˜„

pearl flint
pine steeple
#

ah, time for an upgrade? πŸ˜„

pearl flint
#

yea :D

pine steeple
#

@clever skiff your animation BP, has to have a slot node

#

montages play through this slot node

misty wharf
#

My PC's 4-5 years old at this point, but it was pretty high spec when I built it so it's still fine :P

clever skiff
#

ok uk. i believe that the only part i miss was setting up the slot for it.

#

ill try to do that now and see where it get me.

lyric flint
#

can you add actors to rvo avoidance?

#

ive got actors I want my ai to move to but theyr blocking themself with the navmesh

#

see chair barrel and trees

fresh remnant
#

@lyric flint you can add blockers with crowd avoidance. What do you mean they are blocking themselves? Are they set to generate navmesh obstacles?

lyric flint
#

they are yes

#

of I dont my ai will just walk into it

#

do i just turn off navmesh gen and use blockers?

fresh remnant
#

what do you mean blocking themselves though. Which ones are set to blocking, the trees or the people?

#

you should do navmesh gen on the trees, RVO isn't enough to block fully. But on the people, you should turn off nav mesh gen if you have them on

lyric flint
#

stuff like chairs

#

it cant move to the location cause its outside the navmesh

#

crude way is to add 100 to the Y Location so the location is inside the nav mesh

fresh remnant
#

you can add that as a blocker for RVO still

#

as well as navmesh gen

lyric flint
#

how do i add it as a blocker?

#

is there a node?

fresh remnant
#

I think they also need to be nav agents

#

but kind of forgetting

#

yeah if I'm remembering correctly, you need it to be a nav agent and set its flags to obstacle only

#

I'm not sure if there's a node for that, I set it in the crowd following override of an object. These are the states: enum class ECrowdSimulationState : uint8 { Enabled, ObstacleOnly UMETA(DisplayName="Disabled, avoided by others"), Disabled UMETA(DisplayName="Disabled, ignored by others"), };

#

void UNovaCrowdComponentOverride::RegisterCrowdAgent()
{
    UNovaCrowdManager* CrowdManager = UNovaCrowdManager::GetCurrent(GetWorld());
    if (CrowdManager)
    {
                SetCrowdSimulationState(ECrowdSimulationState::Disabled); <-- Set Simulation State here
...
lyric flint
#

oh

keen crystal
#

I feel like I already set the relevant collision flags

#

alternatively I can set the agent step height lower but I get other problems

fresh remnant
#

@keen crystal make it a navmesh occluder

lyric flint
#

@fresh remnant youre good with AI I guess? πŸ˜›

fresh remnant
#

no I just happen to have dove deep into this navmesh stuff

lyric flint
#

aah

keen crystal
#

thanks, I gave that a try and it didn't work, I ended up solving it by reducing the granularity of navigation

fresh remnant
#

I don't think that's a great way to approach it, that means if you have a bigger object, it's still going to do that. You definitely will need nav modifier volumes working in the long run

keen crystal
#

well, it's weird, I added a navmesh modifier and tried null, obstruct, etc, none of it did anything

fresh remnant
#

you may have to rebuild ur navmesh, depends if you have dynamic navmesh generation on

keen crystal
#

yeah I've been rebuilding navmesh after trying every option

fresh remnant
#

What are you using as the collider @keen crystal , maybe you can also move it closer to the navmesh (Z coordinate wise)

#

@lyric flint that's typical of RVO, rvo doesn't care about nav mesh bounds

#

@lyric flint are you using regular CMC?

#

crowd avoidance

#

but sometimes, physics will do it too

#

yeah, by default it doesn't do well in a lot of these cases..so if you override the CMC and make your own, you can constrain it to the nav mesh

#

you can just inherit off default CMC though

#

and just rewrite part of the PhysWalking or NavWalking function

#

here's the code to constrain:

#

hmm sec..more code than I expected

#
You're about to move to AdjustedDest:
// Constrain it
RecastNavMesh = const_cast<ARecastNavMesh*>(Cast<ARecastNavMesh>(GetNavData()));

DestNavLocation.NodeRef = RecastNavMesh->FindNearestPoly(AdjustedDest, Extent, nullptr, this);
if (DestNavLocation.NodeRef != INVALID_NAVNODEREF)
{
    if (RecastNavMesh->GetClosestPointOnPoly(DestNavLocation.NodeRef, AdjustedDest, DestNavLocation.Location))
    {
        AdjustedDest = ConstrainedDest;
#

that's the basic part of it, so there's one problem here that I had to fix, find nearest poly doesn't always find the nearest poly with the closest point

#

so if u just do this, sometimes it gets stuck on poly borders

#

because it finds the wrong closest poly and constrains it to that poly

#

so you have to iterate through neighboring polys IF your constrained dest does not match your adjusted dest(constraining happened)

#

Here's the code for that:

#
                float Dsq = FVector::DistSquared2D(AdjustedDest, DestNavLocation.Location);
                if (Dsq > 1.f)
                {
                    TArray<NavNodeRef> Neighbors;
                    RecastNavMesh->GetPolyNeighbors(DestNavLocation.NodeRef, Neighbors);
                    float smallestConstraint = Dsq;
                    FVector ConstrainedDest = DestNavLocation.Location;
                    // Find least constrained but still constrained
                    for (auto& PolyRef : Neighbors)
                    {
                        FVector ConstrainedPoint;
                        if (RecastNavMesh->GetClosestPointOnPoly(PolyRef, AdjustedDest, ConstrainedPoint))
                        {
                            float Dist = FVector::DistSquared2D(AdjustedDest, ConstrainedPoint);
                            if (Dist < smallestConstraint)
                            {
                                smallestConstraint = Dist;
                                ConstrainedDest = ConstrainedPoint;
                            }
                        }
                    }
                    AdjustedDest = ConstrainedDest;
#

also, neighboring polys in my case are gauranteed to be "crossable"

#

actually can combine those two code blocks, it wouldn't let me paste the whole thing

#

yeah took me a while to figure this out

#

And lastly I think, u may or may not want to use the Z value of that adjusted dest, because navmesh Z is different

mighty mesa
#

For fly ai I need to set the ai controller mode to fly? I have try with behavior trhee and set the ai pawn to can fly but the ai pawn go down and after move on plane.. I don't understud why can't fly πŸ€”

rigid portal
#

If I have 2 guards, and I want 1 to patrol a path, and the other to be on a guard tower, do I need 2 AI controllers? 2 Blackboard and 2 Behavior Trees? Or can I have 1 do both behaviors of the guards

feral marsh
#

Hey guys ,how are you all doing today?, I am having a problem with my behavior tree and the AI which doesn't play animation on "MOVE TO" node : https://forums.unrealengine.com/development-discussion/animation/1862538-animation-doesn-t-work-on-paragon-characters-how-can-i-fix-it

#

@rigid portal I will suggest you making a blackboard variable which will be true or false if he is a tower or patrol and the AI behavior tree will act by these statements

rigid portal
#

Oh, ok. So maybe tag an agent

feral marsh
#

Sure try it

rigid portal
#

Ok, will do. Thx

warm dagger
feral marsh
#

The attack animation is a AnimMontage

#

It doesn't have a transition or any boolean just a play montage node

warm dagger
#

I do notice one thing you may want to edit though. One state is distance <= 300 and the other is distance >= 300. Only one should have the = with it. So <= and > or vice versa.

feral marsh
#

May I ask why is that?

pine steeple
#

i dislike animbp playing montages

#

Montages should be played at the callsite

#

not in the animbp

warm dagger
#

I'd assum his task is calling the montage, I mentioned the animBP, hehe.

pine steeple
#

breaking encapsulation

feral marsh
#

Yeah the Task is calling the montage,

pine steeple
#

the task is calling AnimBP->PlayAttack

#

which then plays the montage there

#

right?

feral marsh
#

hold on i will double check

pine steeple
#

maybe show some more relevant information

warm dagger
#

Yeah, seeing inside them tasks would help.

feral marsh
#

Sure thing

#

2 min

warm dagger
#

Usually when the animations stop playing on movement it is because the animBP is confused, hehe.

#

Which is why I defaulted to asking about transition boolean not being reset correctly.

#

Does your code ever pause animations or montages?

feral marsh
#

Nope

#

The attack task ^

#

Is it ok? or is there a problem in the code?

rigid portal
#

When I tested this sometime ago, the animbp stopped because if was interrupted by the PlayAnimation

warm dagger
# feral marsh

You are using play animation which changes your animation mode.

feral marsh
#

ohhhh ok

warm dagger
#

You will need to switch your animation mode back to use animation blueprint after the attack plays.

rigid portal
#

Ahhh ok

feral marsh
#

Thank you for the explanation

warm dagger
#

Or use an actual play montage node and make sure to add the slot to your animBP.

feral marsh
#

Will do, much thx @warm dagger

pine steeple
#

^

warm dagger
pine steeple
#

montages are meant for this type of thing

warm dagger
#

You can also use notifys to trigger that spawn projectile instead of relying on hard-coded delay timings.

pine steeple
#

tho you have to be careful with that, sometimes have the spawn time separate can guarantee it spawns. Depends how well your montages are setup and if you use branching point.

warm dagger
feral marsh
#

@pine steeple Noted ty . @warm dagger I will look forward to it, much thx for the explanation πŸ™‚

rigid portal
#

I created a array with Agent ID. I have 3 characters, set with id 1, 2, 3

#

i want agent 1 & 2 to do the task while 3 just stands around.

#

With this setup, only the first item in the array, ID 1, does the task. the other 2 stand around

#

How would I get agent 1 and 2 to do the task?

#

If there is a better way, ping me please! I'd love to learn

ocean delta
#

this is probably a dumb question, but is it possible to create cpp tasks and decorators instead of blueprint tasks and decorators?

lyric flint
#

Absolutely! but why? anyways, take a look at Developer\AITestSuite\ In your engine source for more info

ocean delta
lyric flint
#

I agree, but it doesn't hurt you to visually see the flow of your AI either πŸ˜„

#

that's why, at least during development, it's not a bad idea to use the visual BT

ocean delta
#

so the only thing i'd be putting in cpp would be the decorator itself, not so much the BT

#

i'd use that cpp decorator inside of the BT

lyric flint
#

but of course, you can do everything in C++, I've done it before as well

ocean delta
#

i definitely do NOT want to put the BT into CPP

#

that sounds like a nightmare

lyric flint
#

you can mix and match as your heart desires πŸ˜„

#

well, sort of.. πŸ˜„

#

Kaos is a strong advocate of the balance between C++ and blueprints. I tend to be more C++ey than average, but he's also not wrong, as unreal engine was designed for these blending and balance. But if you are an indie lonely dev, then whatever works for you!

ocean delta
#

if i get this right, i won't be an indie lonely dev forever πŸ˜…

orchid agate
#

why when i use the move to node and the ai's path is blocked by a door/wall does instead of the movement failing it succeed instead and move on with the behaviour tree instead of going back up the tree?

manic karma
#

Perhaps the blocking is hooked up to return success

#

you could try creating a derivative and overriding a block to return failure/abort

orchid agate
#

thanks ill have a look into it πŸ™‚

fair zealotBOT
#

:triangular_flag_on_post: Aditya Raj#0050 received strike 1. As a result, they were muted for 10 minutes.

unborn jungle
#

Is there anything happening in the default AIController / Character code that would override the velocity of LaunchCharacter() ? I have an enemy that launches which works fine most of the time but occasionally the launch will only have velocity in Z as if the X and Y components were cleared by something else like the AI controller. Debugging the vectors going into the launch function, there's definitely plenty of velocity in X and Y in these cases. This "override" sometimes happens mid launch so it starts off fine but then suddenly loses the velocity. I have triple checked that no move to functions or anything similar are being run at the time of the override

#

Could SetFocus or anything like that be interfering with velocity?

pine steeple
#

no

#

velocity is all done in the CMC

#

not sure why it would not work on occasions

deft sedge
#

@ocean crystal @pine steeple had to go all the way back to 2018 to see any examples of run behavior dynamic. Do you still use this method? What are the draw backs? Do you have an example somewhere I can look at?

pine steeple
#

that could be possible

#

tho they are normally accumulated (the launches)

deft sedge
#

oh look at that, you're still active lol

pine steeple
#

Dynamic BT's with tags?

deft sedge
#

yes

pine steeple
#

one issue i had with them is if the BT restarts, it will loose its dynamic assigned BT

#

other than that i use them a lot

ocean crystal
pine steeple
#

but you normally just call SetDynamicBehaviour on the behaviour tree component

#

with the tag, and the BT to run

deft sedge
pine steeple
#

nested BT?

#

like this?

deft sedge
pine steeple
#

i keep that for non dynamic stuff

#

but i only inject dynamic stuff into specific nodes

#

as they have a slight cost penalty

deft sedge
#

maybe I'm not understanding somthing. What is the "dynamic" aspect of these?

pine steeple
#

you can change them in code

#

or in bp

deft sedge
#

change them how?

pine steeple
#

say i had this node

#

and that tag

glossy spire
#

@deft sedge just to butt in, I use dynamic BTs for enemy combat skills

#

so that they can choose from several

pine steeple
#

i can do this and switch what BT is in use

deft sedge
#

is the point of this that you can start the behavior somewhere in the middle of the tree already and skip the top layer of checks or something?

ocean crystal
#

I would drive this injection through data (tables/asset)

pine steeple
#

^ that is what i do

ocean crystal
#

the point being that you sort of have a meta-behavior archetype

#

and then your specific AI will do a different sequence (maybe)

#

So this is a silly example, but you make a BT for passive mobs, neutral mobs, and hostile mobs... then you can spawn a hostile mob or passive from the same AI data but maybe the passive BT only ever runs the patrol or idle path

#

and then any given creature can have a defined attack sequence (or a set of them) but it would only be used if you didn't have a passive instance of that creature

#

SpawnMetaAI(UHostileBTSource::Get(), RandomMobFromRegion)

#

what do you use this for, @pine steeple, since you actually use it?

deft sedge
#

I'm not sure I see a difference between that and having a tag check in a decorator

ocean crystal
#

it would mostly be an organisational difference

#

you can have a massive BT and tag check a lot

glossy spire
#

it keeps your trees from becoming insane

pine steeple
#

i have a generic BT which runs behaviours injected in, which are pulled from the monster so if i need to do specific things per monster type, i can

#

well from the monsters data table

ocean crystal
#

designers like a BT field for, say, MobPatrolBehavior instead of a gamplay tag container which can have that tag

pine steeple
#

makes changes also easier, as i don't hardcode a lot of stuff into BT's rather pull it from DT row, meaning i can alter behaviour without altering a ton of BT's

#

considering we have 30 different monster types

#

it would become unwieldy doing it the traditional way

deft sedge
#

wouldn't the regular run behavior tree be the way around that?

#

oh wait

pine steeple
#

thing is, a lot of things can be hardcoded (like ranges, wait times, etc)

#

i pull stuff out and made custom nodes that pull from the monsters behaviour DT row

glossy spire
#

lets say you had potentially 40+ types of attacks, depending on the monster. You dont want a bunch of decorators deciding which tree to use

pine steeple
#

^

#

monster knows what attack its doing

#

injects the correct attack bt

#

and runs it

deft sedge
#

so you're likely grabbing a montage or something to play then from that data table?

pine steeple
#

no we use abilities for that

deft sedge
#

mmm, abilities, my old nemesis

glossy spire
#

since its a whole BT, it can be moving, targeting, montages, or whatever

deft sedge
#

if I try and put this in the scope of a splinter cell game (mixing between stealth and full on assault style game play) this sounds like it could make my life easier, but I'm still not exactly sure how this works.

I'm using ai perception to check for sight and hearing ( currently in the controller, but probably should do a service ) and that sets a handful of BB variables and some tags on the character itself.

@pine steeple I see in you snip above that most of your nodes end in regular run behavior tree, not behavior tree dynamic.

If I get to the end of a branch where I want my guy to attack, I end that branch with a behavior tree dynamic, which is meant to contain my variations yes? I call that set dynamic subtree in a task? from within the character? I don't really understand the flow here.

ocean crystal
#

I don't know that you would want to use it to change between alert states, that would be built into some common BT

pine steeple
#

this is a specific to that monster, that bt was injected in

#

i don't inject everything, just what is required

deft sedge
#

some of my variation could come from the character type, but also the weapons they are holding

#

wouldn't I want to use dynamic behavior if the environment has changed or something like that?

glossy spire
#

What I do is use one top level tree for all enemies. This tree decides if they should patrol, attack, investigate, etc. Then, after they know what KIND of thing to do, they run a task that selects the variation. That's the dynamic tree.

#

So I have a dynamic patrol, dynamic attack, etc

deft sedge
#

yeah I think it just clicked how it works as you sent that

#

so I essentially "replace" that slot. The tag on defines where the slot is then

pine steeple
#

Yes

deft sedge
ocean crystal
lyric flint
#

@pine steeple quick question if you dont mind

#

how the fuck do decorators work? lmao

#

😭

#

What I would recommend, is for you to solve a real-life situation mimicking a behavior tree. This is a very good exercise for you to understand the proper flow. So when you have some time take a paper notepad and every once in a while ask yourself one question: am I hungry? this is your service.
If the answer is false, meaning you are not hungry, don't do anything. If the answer is true, meaning you are hungry, trying to solve the problem

#

For example: condition Stage: are you in your room, are you in the kitchen, are you out and about. These are decorators

#

If you are in your room, what is the sequence of Tasks (actions) associated with this particular decorator being true

#

tasks: stand up, face the door, opened the door, head downstairs

#

and so on

#

after you do this exercise in real life while taking accurate notes in your paper notepad, it should become clearer and easier with some practice

#

and of course, have fun learning

#

and yes, I know I'm not Kaos, but I hope you would consider my suggestion πŸ˜„

deft sedge
pine steeple
#

probably not noticable for 10-20 ai, but when your running 100 AI, i noticed a slight cost increase of around .2ms

ocean crystal
#

Kaos can be more specific

pine steeple
#

as it does some additional stuff to get the dynamic BT

#

but yeah, i optimize my AI highly, so the more i can save the better

#

which is why i use dynamic only in certain places, and use static if makes sense

deft sedge
#

ok so in this case that's fine. In my horde I probably wouldn't then

pine steeple
#

i can support 150 AI at around 3ms game time (my budget for AI)

#

that is when they are crowded around a player and moving

#

if they are away from player (not visible) they run at about 1.2ms for 150

#

very rare you will get 150AI bunched into players

#

that is total cost, including BT, Movement, pathing, etc

patent hornet
#

either the AI die quick, or players die very quick scenario

#

unless Kaos uses them cheats πŸ˜„

pine steeple
#

yeah πŸ˜„

#

thing is as soon as they die, i turn off nearly every system

#

so they cost nothing when dead

deft sedge
#

I can render 500 without a problem, just want to make sure i don't have cpu becoming the bottleneck

pine steeple
#

500 AI moving with CMC?

deft sedge
#

yep

pine steeple
#

πŸ€”

#

average CMC tick (non optimized is 0.03ms per AI)

#

that would be 15ms game time

patent hornet
#

believes starkium is doomed there

pine steeple
#

and that is on my spec pc

patent hornet
#

which means 40 on potato gaming laptop

pine steeple
#

even if you got lucky and it was only 0.01ms per AI that is still 5ms

#

then you have BT, Perception (if you use it), character class tick, controller tick

deft sedge
#

shipping build is like 4-8 ms total depending on the scene

pine steeple
#

yeah you loose a lot of flexibility tho

deft sedge
#

yes

#

but that wasn't the question

pine steeple
#

we have 30 different monsters

#

also multiplayer game not sure if yours it

#

is*

deft sedge
#

right, like I said, I can use it for the stealth game scenario, but not a zombie survival scenario. Two different projects

pine steeple
#

yeah well if it works, its good

#

tho 500 ai at a time in game, is a bit overkill

deft sedge
#

for the zombie scenario there's not a lot of variation so hard coded is fine

pine steeple
#

look at CoD zombies

deft sedge
#

can go higher if I switch to pawns

pine steeple
#

they have a max of 50is at a time

deft sedge
#

do I need to? not at all. doesn't increase immersion at all

#

but I wanted enough numbers to make an open world map feel full

pine steeple
#

but you can do other tricks

#

like spawn them when the players gets in a certain range

#

kinda thing

deft sedge
#

sure, they are pooled too

pine steeple
#

we don't pool our AI

#

we just destroy and create new

deft sedge
#

that has an impact on low end hardware

#

I'm developing for oculus quest

pine steeple
#

depends how heavy your classes are

#

ah yeah makes sense

#

we are targeting desktop

deft sedge
#

yep, so I fight for every little thing

#

shipping build is way lower

patent hornet
#

should just fake those with niagara

#

until player starts interacting

fresh remnant
#

CMC if you use nav walking really helps. I also disable tick when idle

#

thing that hurts CMC the most after regular phys walking is overlap checks during movement, from what I've seen, so if you say, do ur collisions mostly with crowd avoidance and nav mesh, u can almost turn it off

#

this monotick looks interesting, is it just one object ticking for others..?

wary ivy
#

I guess it's inspired by the sea of thieves tick optimization presentation?

#

if someone makes an optimized character and character movement component that behaves mostly the same (acceptable if it only walks on navmesh too) I'd be willing to pay for it πŸ˜›

static crater
#

Hi hello, im trying to spawn navmesh bound volumes using c++, anyone knows how to visualize the bounds? (so i can check they are well placed)

#

command 'show bounds' does not make my navmesh bounds in editor visible

manic karma
#

you're trying to visualize them in-play?

static crater
#

yep

manic karma
#

I'm sure there's a command to show the navmesh in PIE

#

not sure about seeing the actual bounds

static crater
#

its show navigation but that actually visualizes the navmesh itself

#

however so i noticed my spawned navmesh bounds are not properly setup anyway

manic karma
#

I guess you're looking for something more fine tuned than just the navmesh being correct

static crater
manic karma
#

ah

#

well.

static crater
manic karma
#

set the brush in C++ code then

static crater
#

Right, ill have to dive into brushes than, never created one

manic karma
#

it will just be a struct containing the information in the second picture

#

the navmesh bounds volume will have a function like SetBrushSettings or something

static crater
#

hhm, got any point to some example code?

manic karma
#

ANavMeshBoundsVolume inherits from ABrush

#

so you can access public/protected code

static crater
#

yeah

#

so basically i dont see any real possible way to like set the brush

#

it only has like GetBrushComponent()

#

however so it seems the brush is already created? should i swap it with a created brush in some way?

#

or i should setup the brush?

manic karma
#

you just need to set the brush settings

celest python
#

In gameplay debugger it looks like my Run Behaviour node is executing but my breakpoints inside of that BT doesnt execute, why this is happening?

manic karma
static crater
#

Yeah so it looks a little weird.. e.g. there's no such setter for Brush Type

#

its not even possible to select 'Brush Type Box' inside the editor

#

but well, first gonna see how brush works at all πŸ˜‰ thanks for some advise

manic karma
#

I guarantee, if you can find where it is stored, you can figure out how to change it

static crater
#

well i actually see some posts from people trying to change the navmesh bounds at runtime using c++ or blueprint but they kinda struggle

#

and so, yeah i do add navmesh at runtime

manic karma
#

well are their struggles related to understanding the c++, or with the results of changing the values?

static crater
#

hhm, lol okay

lyric flint
#

@lyric flint thanks bro! saw it later cause I went to sleep! thats really helpfull πŸ™‚

static crater
manic karma
#

can't be the case

#

surely

#

you can force a rebuild of the navmesh at any time, so changing the size at runtime can't be a problem

static crater
#

actually yes, rebuilding navmesh works, but that does not tell anything about the NavmeshBoundsVolume

manic karma
#

tellin you it's gotta be in the brush somewhere

torpid juniper
#

How do blackboards work with subtrees a la Run Behavior Dynamic nodes?

Is it correct to assume there is no shared state between the parent and child, and that if this is something you need to do you could pass it back and forth via calls to the controller?

misty wharf
#

iirc subtrees use the parent's BB and that's it

torpid juniper
#

How does that work if the subtree is set up with a different blackboard with decorators expecting different values

celest python
#

Is it makes sense to run AI Move To in BTTask? Because its always failing with "aborted" flag

torpid juniper
#

it will fail with aborted if the task is aborted due to decorator logic in the tree

#

i think it will also abort if the location you're asking to go is not navigable

celest python
#

First posibbility makes sense then, I should keep digging into BT

#

Thanks

torpid juniper
#

You can look at the behavior tree during runtime to see where its at in the tree

celest python
#

I am watching the tree via gameplay debugger, it stuck on the same BTTask

#

Since Finish Execute is not getting called after Fail node of AI Move To

torpid juniper
#

Probably unable to navigate then. Try placing a cube where you're telling it to go and verify its actually on the navmesh

celest python
#

πŸ‘ Thanks, just realized I was trying to get a world location of a component that doesnt exists in the level

#

Its happening because of its not navigable

torpid juniper
#

πŸ‘

pine steeple
#

@torpid juniper you can create a parent BB for your normal BT, then your subtrees can use a child version of the BB

#

though this works, i have found issues, which is why i no longer do it.

misty wharf
#

It feels a bit tricky to make good use of the BB... at least to me it rapidly starts feeling like "a random assortment of values" :P

#

so instead I have a bunch of tasks which just query stuff from the pawn directly

torpid juniper
#

@pine steeple What do you mean a child version? Like an actual extension of the original BB? At a glance it does not look like the editor provides a way to extend BB classes. Are you also saying that the child instance would auto populate with the data of the parent?

I think I'm fine if they just don't share bb data at all, I was just curious. In general I feel like I'm struggling to grasp what data to put in a blackboard vs. keep in the controller. It feels like the answer is increasingly only things that directly driver the decorators. Anything else becomes quite cumbersome to setup the keys when I could just make a function call to the controller in the task directly.

torpid juniper
misty wharf
#

Yeah it kinda depends on what you're doing

#

Most of my tasks don't look up values but some do, I also have a number of decorators which can check values directly on the pawn for conditional execution and such purposes

torpid juniper
#

hmm... for some reason I never thought to write a decorator. I've got services that just update bb state and affect the decorator based on that. Custom decorators probably make more sense if that logic is only relevant for that BT state...

misty wharf
#

No idea but at least it works for my use :D

torpid juniper
#

ugh, ai feels like the biggest slog in unreal.

misty wharf
#

I dunno, I find it pretty good

#

Try writing AI behaviors in C# in Unity no thx :P

torpid juniper
#

I started out in unity c#, but I never bothered to properly learn the tooling so it was all from scratch. Wasn't the best of times.

deft sedge
#

weird question, can a behavior tree service be event driven instead of on Tick?

The answer is yes, but what I'm more interested in is disabling ticking on the service.

glossy spire
#

you can change the interval

#

not sure if you can make it zero, but make it 100 or something should be good enough

torpid juniper
#

is ticking at all a concern if there's no implementation for the tick event...?

glossy spire
#

i dont think so

deft sedge
#

well that's fine then

#

I made a bind to ai perception so it will only fire when stuff moves in and out of that

simple crest
#

an empty blueprint tick is expensive as shit if you have a lot of them

deft sedge
#

hmm that's what I thought

torpid juniper
#

define a lot

simple crest
#

"results vary based on everything" but if you look around and crunch some math I think you'll conclude an empty BP tick node costs somewhere around 0.5 microseconds. remember the budget for 60 FPS is 16666 microseconds

pine steeple
#

i removed an empty BP tick node on actors (we had 1000 of them in the level) and it was costing .5ms of game time!

#

this is hardware dependant also

#

maybe 1ms on on someone elses spec PC

#

BPImplementableEvents will not be called if the node does not exist

deft sedge
pine steeple
#

yeah but won't enter the VM iirc

#

and is cheaper

lyric flint
#

howd you set up a system where you can take control of the ai?

#

i have my AI set up to do basic tasks like gather food etc

patent hornet
#

you have all logic on how to perform actions in the pawn

#

you have all logic deciding which action to perform in the controller

#

that makes the PlayerController and AIController interchangeable

#

its just player input vs. behavior tree then

#

and you simply possess and AI

lyric flint
#

I mean, force them to do another task in the bht

fresh remnant
#

That BP Tick node was what I was trying to figure out trying to remove the other day..I don't even know how I ended up removing it...but eventually after a bunch of recompiling blueprints it dissappeared.

lyric flint
#

you wanna cast inside a bbtask?

lyric flint
#

do event recieve execute ai then?

#

oh wait

#

i always get casting confused πŸ˜›

#

you can cast to a bb

#

like this @lyric flint

torpid juniper
# simple crest "results vary based on everything" but if you look around and crunch some math I...

I've seen grace hopper's lecture many times on the importance of microseconds but honestly never found a case where it felt like it affected me. Guess that's changed.

For anyone who hasn't seen this wonderful bit of comp sci history https://www.youtube.com/watch?v=9eyFDBPk4Yw

Admiral Grace Hopper was one of the first programmers of the Harvard Mark I computer. She developed the first compiler for a computer programming language. Here she explains a nanosecond to a room of learners.

Transcript:

They started talking about circuits that acted in nanoseconds. Billionths of a second. Well, I didn't know what a billi...

β–Ά Play video
latent creek
#

I think need to put all logic related to AI into services or tasks, changing variables of blackboard from other bluprints will not work (in my project it doest work).

clever skiff
#

to any people who have issue using paragon as an AI all you have to do is activate use acceleration in the character bp. that took me so long to find lol

#

that issue fix animation not playing correctly

timber mortar
#

i want to know something really basic. how do I add a 'function' or service to a behaviour tree that just checks if(boolKey == true)? so that it knows to continue the sequence?

misty wharf
#

There's a builtin decorator for it that you can use, blackboard condition or whatever it was called

timber mortar
#

now i'm trying to find out how i can set the blackboard value targetActor to a non-player actor that i have in the world outliner?

timber mortar
#

should i use a service, decorator, task, or some other means?

glossy spire
#

@timber mortar use a decorator

storm zephyr
#

hello, i have a nav mesh and i use level streaming to load levels that affect that nav mesh during gameplay. In the editor to get the navmesh correct i need to make sure all levels are visible in design time, if i don't then the navmesh won't work. The same thing happens in the packaged version but since i dont have design time then the nav mesh doesn't get created properly. any way to counter this and make sure the nav mesh is updated regardless?

glossy spire
#

I think you have to build the nav mesh while all the levels are visible in editor

#

then dont rebuild later

fresh remnant
#

@storm zephyr set your navmesh to Runtime Generation: dynamic

fresh remnant
#

Is the most efficient way to handle cooldown with behavior trees a simple wait node once a weapon fires? Decorators that check if cooldown down seem to get hit every tick otherwise and seems very inefficient.

storm zephyr
#

@fresh remnant does it have to be dynamic? right now i have dynamic with modifiers

static crater
#

Hi, is there any limit in size for the navmesh bounds volume?

#

(using nav invokers)

#

i created a nav mesh bounds volume of 8192x8192 meters, but nav invokers wont generate the navmesh anymore..

static crater
#

i managed to get it to work by changing 'Cell Height' to 20, any idea why it works then?

timber mortar
#

probably because you're making the lengths of each cube dimension less disproportionate to eachother so it can scale better

#

maybe shapes dimensions can only be so disproportionate

#

for some reason i cannot set the Marja variable here to the object shown in the dropdown, it's always None, any clues why?

misty wharf
#

because this is an asset and those are objects that will be spawned in the level

#

although they "exist" in the level in editor, they don't actually exist at all until the game starts and hence it's not possible to assign them into other assets

#

you will have to add some logic to assign it into the BB at runtime such as on Begin Play or some other event

timber mortar
#

thank you man

uncut python
#

hi everyoen i have a quick question, my AI was working perfectly fine the other day, even with crouds (IM using crowd controller). Suddenly today I open my project and the zombies dont respond at all, and my BT keeps stuttering like in the video. What could cause that?

#

i dont understand how it couldve suddenly stopped working

#

i didnt extend my nav mesh 😫 and i moved all my nodes around

misty wharf
#

the moveto doing that suggests that it's immediately failing

#

check if your navmesh is actually generated, I've had some cases where it just randomly disappears and requires you to manually rebuild it from the build menu

uncut python
#

Yes thank you

#

I made the noob mistake of assuming the AI work anywhere

#

but now all is well

#

I appreciuate it

pallid atlas
#

I suppose, duh... how else would it be present before PIE

fresh remnant
#

navmesh can be set to dynamically generate/regenerate during runtime, but creating the actor itself is done on build. You actually have to delete your navmesh actor from the level, and press build again if you modified navmesh settings through editor->properties because old data lingers sometimes, and can cause problems/bugs and even crashes

fair zealotBOT
#

:triangular_flag_on_post: Aditya Raj#0050 received strike 2. As a result, they were muted for 1 hour.

swift bolt
#

2:26 It's like having a human actor to direct in your game

ocean delta
#

anyone know of a BTDecorator in the UE source that's easy to understand? trying to create BTDecorator and having some challenge

#

actually the CheckGameplayTagsOnActor one is not half bad at all

ocean delta
#

is there a way to run something only when the BTService first starts?

#

i was missing bNotifyBecomeRelevant ResidentSleeper

#

so i'm trying to set a Vector in my blackboard but the value is always (Invalid). i'm doing it through CPP and i'm not really seeing why this is a problem

#
BlackboardComponent->SetValue<UBlackboardKeyType_Vector>(
                InitialLocationKey.GetSelectedKeyID(), EnemyUnit->GetActorLocation());
ocean delta
#

lol it's not getting set at all

#

sigh... the following block of code was missing from the service

void UBasicEnemyCombatBTService::InitializeFromAsset(UBehaviorTree& Asset)
{
    Super::InitializeFromAsset(Asset);

    UBlackboardData* BBAsset = GetBlackboardAsset();
    if (ensure(BBAsset))
    {
        InitialLocationKey.ResolveSelectedKey(*BBAsset);
    }
}
lyric flint
#

@swift bolt gpt3 is massively slow (needs to run on a cluster slow) and it only generates random texts that makes semi-sense

#

it doesn't have any overarching context

#

doesn't have any connection to the world etc

#

gpt3 is a language model by design.

wet ether
#

Does any of you know how to move higher the SIght AI Perception point? I want the enemy to see the head

pine steeple
#

@wet ether only doable in C++

wet ether
#

I assumed this option, but what exactly should I do? I have no even a single idea

pine steeple
#

you need to implement the IAISightTargetInterface interface on your players C++ class

#

and override virtual bool CanBeSeenFrom(const FVector& ObserverLocation, FVector& OutSeenLocation, int32& NumberOfLoSChecksPerformed, float& OutSightStrength, const AActor* IgnoreActor = nullptr, const bool* bWasVisible = nullptr, int32* UserData = nullptr) const

wet ether
#

wait. In my player? Im so dumb, i did that exact same thing in the AI character. Let me try that in my character and see if that works

pine steeple
#

right its on the player

#

Observer will be the AI

#

so you do like a trace from ObserverLocation to say Head, if it hits, then OutSeenLocation will be players head, and you return true

#

you can trace for all different body parts

wet ether
#

So, i've made a C++ Character class with overrided function and set it as a parent class of my player character. But the question is what is the body of the function?

pine steeple
#

so you do traces from ObserverLocation to parts of your player

#

and return true and the location of the hit part

#
bool AMyCharacter::CanBeSeenFrom(constFVector& ObserverLocation, FVector& OutSeenLocation, int32& NumberOfLoSChecksPerformed, float& OutSightStrength, constAActor* IgnoreActor) const
{
      const bool bHit = GetWorld()->LineTraceSingleByObjectType(HitResult, ObserverLocation, GetActorLocation()
        , FCollisionObjectQueryParams(ECC_TO_BITFIELD(ECC_WorldStatic) | ECC_TO_BITFIELD(ECC_WorldDynamic))
        , FCollisionQueryParams(NAME_AILineOfSight, true, IgnoreActor));
    
NumberOfLoSChecksPerformed++;

    if (bHit == false || (HitResult.Actor.IsValid() && HitResult.Actor.Get() == this))
    {
        OutSeenLocation = GetActorLocation();
        OutSightStrength = 1;
        return true;
    }

    const bool bHitSocket = GetWorld()->LineTraceSingleByObjectType(HitResult, ObserverLocation, GetMesh()->GetSocketLocation("head")
            , FCollisionObjectQueryParams(ECC_TO_BITFIELD(ECC_WorldStatic) | ECC_TO_BITFIELD(ECC_WorldDynamic))
            , FCollisionQueryParams(NAME_AILineOfSight, true, IgnoreActor));
       
 NumberOfLoSChecksPerformed++;


        if (bHitSocket == false || (HitResult.Actor.IsValid() && HitResult.Actor.Get == this)) 
      {
            OutSeenLocation = GetMesh()->GetSocketLocation("head");
            OutSightStrength = 1;
            return true;
        }

    OutSightStrength = 0;
    return false;
}```
#

@wet ether ^ something like this

wet ether
#

Thank you so much, i really hope that'll do the work

#

Seems like it doesn't recognize NAME_AILineOfSight and HitResult. What could be wrong?

#

I have just tested it and nothing has changed. Completely no difference. I am definitely doing something wrong

pine steeple
#

did you fix the code

wet ether
#

I've added this and the errors were gone

#

static const FName NAME_AILineOfSight = FName(TEXT("TestPawnLineOfSight"));

FHitResult HitResult;
pine steeple
#

thats correct

#

the first test will aim for the body

#

so if the pawn is not behind an obstacle

#

it will show the result in the center (like it was in your screenshot)

#

the second test will check for the head

#

so put your player behind a wall with just head exposed

#

and you will see it will be on the head

wet ether
#

Yea, i tried that, but here is what i got

pine steeple
#

do you have a head socket?

#

on that mesh?

#

ooh tell you what you could do if not,

wet ether
#

Any socket? Any special name?

pine steeple
#
  const FName NAME_AILineOfSight = FName(TEXT("TestPawnLineOfSight"));

    FHitResult HitResult;

    const bool bHit = GetWorld()->LineTraceSingleByObjectType(HitResult, ObserverLocation, GetPawnViewLocation()
        , FCollisionObjectQueryParams(ECC_TO_BITFIELD(ECC_WorldStatic) | ECC_TO_BITFIELD(ECC_WorldDynamic))
        , FCollisionQueryParams(NAME_AILineOfSight, true, IgnoreActor));
    
NumberOfLoSChecksPerformed++;

    if (bHit == false || (HitResult.Actor.IsValid() && HitResult.Actor.Get() == this))
    {
        OutSeenLocation = GetActorLocation();
        OutSightStrength = 1;
        return true;
    }

    OutSightStrength = 0;
    return false;
}```
#

do this

#

then you can modify /** Base eye height above collision center. */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Camera) float BaseEyeHeight;

#

on your character

#

to adjust the trace position

wet ether
#

So i rewrote the function and now this guy aims exactly at the character's head. And now everything works perfectly

#

Thank you so much for this. But why do i need to modify BaseEyeHeight?

pine steeple
#

did you use what i had up there ^

#

?

wet ether
pine steeple
#

the BaseEyeHeight is the position up from the capsule but if everything is working fine then leave it

#

but you can adjust that value to adjust the eye location

wet ether
#

i think i'll let it be

#

And yes. One more AI issue to fix

#

how to make an AI look at the same direction he is moving?

wary ivy
#

there's the orient rotation to movement setting in characters

pine steeple
#

well either that or control rotation

#

both work

#

Pathfinding will set the control rotation, and allows for Focus to be used (which you can't do with Orient to Movement)

toxic obsidian
#

Is there a way to make a decision tree option based on if a player's targeting reticle is aiming at (a la enderman being looked at)?

#

I want to make it so that if the enemy is targeted, it moves left or right to avoid the reticle

lyric flint
#

Absolutely! Use a line trace from the player, and broadcast to the target If the target matches whatever criteria. This way the target knows and act accordingly πŸ™‚ You can also use TActorRange of your enemy type, to clear them if they are not the target anymore, so they don't have to run in circles like headless chicken πŸ˜„

wet ether
#

So i have a BT of my enemy character that shoots and focuses at a target

#

And now i want him to move to it's target while shooting and focusing so i did this

#

And now i want to add a delay to the Move To task so it will start shooting and then start moving in a few seconds later

#

So the question is how to do that?

patent hornet
#

funny thing about that, its stuck in that MoveTo until the move is completed

#

can't do anything else

wet ether
#

I thought that part of a tree would be enough. I have a movement interrupting task in another place

pine steeple
#

why you nesting simple paralleles?

coral spire
#

Hi, anyone knows why sense configuration is not inherited and recognized as change by each parameter but only as config itself?

#

Issue is that I have a kind of bigger hierarchy where I would like just change few parameters and still be able to change some others in the parent for all childs in hierarchy

lyric flint
#

Not sure, maybe I misunderstood your problem, but perhaps you should consider running RequestStimuliListenerUpdate on any component that changes parameters?

coral spire
#

This is a configuration issue, not runtime

#

when I change one value in child config, then it exist as separate config and wont inherit any new changes from parent in other values which I didnt touch in child

vocal spindle
#

Hello! Quick one,
for multiplayer, how can I cast a controller AI from its widget in BP without failing since it happens on server.
Or, at least, a way to read a variable that exists in the AI controller.
Thanks!

#

so this works standalone, but fails on server

#

or at least, to read a variable that lives in the controller

torpid juniper
#

Are you sure its the server where the problem is? That should be ok on the server. but the controllers dont exist on clients

steel moon
#

Hello. The trick question, is there an object that moves on the map, artificial intelligence needs to move inside this object while it is moving, is it adequate to use the dynamic nav mesh, or can you somehow bind the nav mesh to the actor so that there is no endless rebuild

torpid juniper
#

You don't want the navmesh to only contain the area around the followed object. You want the navmesh to cover the entire area, and then use logic on the ai controller to make it stay within the bounds of the followed object.

wet ether
# pine steeple why you nesting simple paralleles?

The Shoot + Focus Parallel is required because i also have reloading logic in the Shoot task, and it takes some time to reload, and while reloading the enemy does not focus at his target so that's why there's a parallel

#

And MoveTo + Parallel is required because i want him to walk and shoot in one moment

#

This all works good enough but this way i can't add a delay to the MoveTo task

cyan sigil
#

Hello. I have two behavior trees, one where the AI will patrol and one where it will attack a stored target (set via Senses). What is the proper way to make a parent Behavior Tree that can swap between these two?

rigid portal
#

Is creating multiple behavior trees not best practice for the same enemy character ? Like a patrol enemy and a lookout enemy.

patent hornet
#

you have to create multiple BTs to have any complexity in AI behavior

#

there is a task RunBehaviorTree

#

so you compose the behavior from multiple BTs

rigid portal
#

Gotcha, thanks!

pallid trout
pallid trout
rigid portal
#

For multiple that do different things, I use multiple bt

pallid trout
#

How many different things do you have

rigid portal
#

2-3

#

One guard patrolling, one in a guard tower, one drinking coffee

pallid trout
#

Thats pretty simple

rigid portal
#

When they see the player, they will chase till they loose sight, then go back to doing whatever they are assigned

#

I can assign an ID and have one BT do everything, but is the norm to do multiple Bt?

rigid portal
#

I see. I'm not sure what the line is lol

#

What would be considered complex?

#

like taking cover during a firefight?

pallid trout
rigid portal
#

I see. πŸ˜‚ to me that seems complex

#

you wouldn't happen to have a vid of that would you?

pallid trout
rigid portal
#

When you say complex... do you mean computation complx?

pallid trout
#

No

#

Complex like spaghetti

rigid portal
#

where there a multiple options for an agent to do

#

or should I say, multiple decisions

pallid trout
rigid portal
#

Ahh true πŸ˜‚

#

Thanks for the info, I really appreciate it.

pallid trout
rigid portal
#

I can't have multiple blackboards?

#

Does the blackboard exist per instance of an agent?

pallid trout
#

I think no. Maybe if they're inherited

rigid portal
#

Ok cool

#

I'm watching the unreal Ai livestream....

#

It's god awful

#

Basic

misty wharf
#

Meh, I had the brilliant idea of using gameplay tags as results from my interaction menus, but of course blackboards don't support gameplay tag values... I guess it's back to using a regular old enum which is going to bloat like crazy with all the possible results :P

patent hornet
#

@misty wharf "blackboards don't support gameplay tag values" - try again πŸ˜„

#

and don't let @pine steeple hear you

#

(blackboards support names just fine, and tag is just a fancy FName)

lyric flint
#

Is anyone here good at making ai?

patent hornet
#

i would hope someone is

lyric flint
#

I am like horrible making ai with blueprints

patent hornet
#

@misty wharf you can also just casually toss an object with IGameplayTagAssetInterface into a BB

misty wharf
#

Interesting

#

I had a feeling the gameplay tags would be possible to translate into an FName or something

patent hornet
#

they are names

misty wharf
#

but it seemed less compatible than just having the gameplay tag option for the type

patent hornet
#

with a lot of fancy ontop

misty wharf
#

Right, good to know

patent hornet
#

FGameplayTag has one member and its an FName

#

so FGameplayTag::RequestGameplayTag(MyName) gives you a tag from name, and MyTag.GetTagName() does the reverse

#

both can also be done from BP, altho with slightly different syntax

misty wharf
#

Yeah looks like there's a Get Tag Name but I'm not seeing the reverse

#

I guess wrapping RequestGameplayTag would be pretty trivial though

patent hornet
#

yeah, we wrapped it πŸ˜„

static crater
#

So still trying to fix my navmesh for my procedural map

#

i wanted to see this setting works

#

however rebuilding navmesh at runtime does nothing

misty wharf
#

Looks like FGameplayTag::RequestGameplayTag is actually deprecated, should use UGameplayTagsManager::Get().RequestGameplayTag instead

patent hornet
#

locked on 4.25 so not for me

pine steeple
#

does not look deprecated for me in 4.26 either

#

its just a nice static wrapper for

{
    return UGameplayTagsManager::Get().RequestGameplayTag(TagName, ErrorIfNotFound);
}```
misty wharf
#

Wait which file is that in

void stump
#

any resource to look up for handleing lots of ai ~800+ repeating tasks like in age of empires chopping tree -> find station -> find nearest tree from last tree position and chop it

misty wharf
#

I think I was looking in the wrong file :P nevermind the deprecation

#

GameplayTagsModule::RequestGameplayTag was the one I was looking at

low crow
#

Hello!
I'm using behavior trees and I wonder if there is a way of passing variables as parameters value of tasks?

#

Example I want to modify the Acceptable Radius here and I wonder if there is a way instead of just duplicating this behavior tree

misty wharf
#

Afaik no, you have to build the BT tasks in such a way that they would accept parameters

#

You can make your own BT task for parametrized move which shouldn't be too hard to do

low crow
#

Okok I see πŸ™‚

#

THanks!

torpid juniper
#

@void stump Nothing especially unique about what you're describing. A general look into how behavior trees should be fine for what you want.

void stump
#

are there no performance limitations ?

#

maybe some good workarounds?

#

what about flowfields and collision avoidance between ai workers

pallid trout
void stump
#

if 4 players each get 200 ai and ~100 are workers its possible that 400 but even 600+ be on the screen at once

#

and even if they are not visible it still needs to process it depending on the range between sawmill and tree time of transports differs and makes a diffrence

vast relic
pallid trout
#

Recent Ue livestream on crowd optimization with niagara could be exactly what you want

torpid juniper
#

Everything has a cost, but I don't think 800 ai should be impossible to handle so long as your setup makes sense. When I imagine the AoE II AI, it feels very intuitive. Avoiding evaluating something every frame is probably not a difficult barrier to overcome.

default crowd avoidance pathing should be fine.

pine steeple
#

@void stump what you can do is the ai offscreen, you reduce there tickrates of CMC, Skeletal Mesh, etc

#

we managed to bring 200 AI from around 3ms down to about .75ms by doing so

#

plus other optimizations (disabling overlap checks, etc)

#

so 600-800 is doable with some extreme optimizing, but on screen at one time, will be quite tough

#

but maybe the further the camera is away from them, they can just start reducing there tick times/skeletal updates?

#

so they look ok from far

cerulean coyote
#

hey guys im trying to have my enemy choose from a set of attacks. Each one should have a % to choose from, any idea how i could implement that?
for example the enemy would have a 35% chance to do attack 1, 15% chance to do attack 2, etc.

misty wharf
#

Generate number between 0.0 and 1.0, if number is <= .35, attack 1, else if number is <= .50 attack 2, elseif etc.

#

at least if the total % is 100 that'd work

#

there's probably some other ways to choose for example given an array that has a weight and value for each item, you can do some algo to pick based on that

#

google for "weighted random from array" or something like that and you'll probably find the relevant formulas

cerulean coyote
#

very helpful thanks @misty wharf

sick locust
#

just a quick question. is there anyway I can get this pawn to move specifically only on the X axis? it seems even when I do this it still rotates off into another axis..

sick locust
#

:D I fixed it don't mind me I have the iq of a crustacean

torpid juniper
#

Luckily I can think of no better animal to embody than a crab if your goal is to move along a single axis.

lone cloud
#

Hey there guys, could anybody help with this thing I have?

#

If you've every played Hitman or Assassin's Creed or anything, your probably familiar with the neutral/searching/hostile mechanic where it updates your HUD accordingly. I managed to create it myself, however not in the most efficient way.

#

Does anyone know the most efficient way that I could update it? I already fixed it and stuff so the code is working, just when and how should I do the code so it's efficient and doesn't eat away at performance

#

What I have is whenever the ai goes into a new branch in behaviour tree (hostile/searching/patrolling) it loops through all the other ai to see their states and then it chooses the final outcome (if one AI is hostile and one AI is patrolling, I wanna make the HUD show hostile)

#

The problem with this is that EVERY AI loops through EVERY AI and that's just way too much on performance

#

I have some ideas for fix, but I wanted to ask and see if anyone knew the optimal way to do this!

patent hornet
#

AIManager

#

that is statically accessible (1 actor on the level or 1 component on a "singleton" actor)

#

that keeps that info ready for the AI to access

#

everything that is of interest to AIManager registers with it on BeginPlay, and unregisters when it does @lone cloud

#

as it knows the position of everything of interest at all times, you no longer need to do overlaps or similar expensive checks, just disaancesquared

lone cloud
#

Oh that's cool

#

I've never used an AIManager before

#

@patent hornet , the way I did it was with a function on the game instance that searches for actors of that class and loops through them

#

So this is all unnecessary you mean?

patent hornet
#

All Ai register with AIManager

#

no need to loop through every actor on the level to find AI

#

they are already sitting in an array there

lone cloud
#

How can I find it?

pallid trout
pallid trout
#

Instead of getting all AIs you would be getting the player from all AIs individually

lone cloud
#

If the player is hostile, it should overlap anything else

pallid trout
#

Then storing their references in an array is the best bet

#

Im curious how this can be done with "ai manager". maybe its c++ only

patent hornet
#

@pallid trout the AIManager is just a practical way to call the custom class

#

in practice it combines the elements of singleton, observer and mediator patterns as needed for your game

lone cloud
lone cloud
pallid trout
#

could work for all states with a bit of implementation

lone cloud
#

Hmm

#

As I said, I already have the system working but it's not efficient, that's it.

#

Do you think doing it every tick would be more efficient?

pallid trout
#

Its not using get all actors of class

pallid trout
lone cloud
#

So it's get all actors of class that's really expensive I get?

pallid trout
#

Yes

#

Do it once and store all in an array, use ai manager or use the workaround i said above. Theres tons of ways

lone cloud
#

Hmm

#

I see

#

But what would happen if I did it at the beginning but then after the AI dies and the controller is destroyed, would it become a nullptr

pallid trout
#

Yes

lone cloud
#

Thats what I was afraid

pallid trout
#

A simple is valid check will fix that

lone cloud
#

Hmm

#

I'll have to check on it tomorrow, rn I'm on my phone

#

Thnx for the advice

sick locust
#

anyone able to shoot me in the right direction for making fairly basic ai for a 2D platformer? I can't seem to get mine to work even with a navmesh

lyric flint
#

YouTube πŸ™‚

#

In this part we will create an advanced enemy AI that will fight and track our player! Leave anything you'd like to see in the comments below so I can work them in as I go!
UE4 Download: https://www.unrealengine.com/en-US/what-is-unreal-engine-4
Assets used: https://www.gameart2d.com/free-platformer-game-tileset.html
https://craftpix.net/freebi...

β–Ά Play video
lone cloud
#

I haven't done that before, but I'm sure it would have more variety and taste when you split each BTs that way different enemies act differently.

#

Also you might be handcuffed if you stick to using only one (i.e. if you decide you want the ranged attack enemy to run away when the player gets close, it will be more difficult when it's mixed with other enemy code)

pallid trout
#

definitely separate bt's and controllers. separate bb's, might as well

lyric flint
#

Separate blackboard is not needed, because it is conceptually the same regardless of attack type, and the AI gets its own instance, done properly. Separate behavior trees, no problem, I guess, at least for keeping it clear and clean πŸ˜„

lyric flint
#

Question: What does the near clipping radius do?

unborn jungle
#

Do AI Controllers automatically get destroyed when the pawn that they are posessing does?

#

I don't see any destroy calls happening for my AI Controllers but they no longer appear in the outliner when the pawn they possess get unpossessed and destroyed

pallid trout
#

They get destroyed when everything referencing them gets destroyed

manic karma
#

any idea how can I fix stuff like this on my nav mesh?

#

Enemies are getting stuck at the bottom of the stairs

#

seems to be they can't bridge that gap

pallid trout
pallid trout
manic karma
#

you mean the cell height?

#

yeah the character is smaller

#

quite small actually

manic karma
pallid trout
manic karma
#

the generation near the stairs is so odd

pallid trout
manic karma
#

Nope

#

they get stuck at like the middle of the stair base

#

but at the sides they can get up

#

It's really weird

#

the whole map is producing areas where the AI get stuck

#

on corners

#

invisible objects

#

trying to path directly to the character instead of on the navmesh

lyric flint
#

So is navmesh UE's ONLY source to have ai work?

manic karma
coarse obsidian
#

@lyric flint Actually no, you could completely design AI without navmesh, blackboards and behaviour trees...

#

just by making rules in blueprints / cpp just like you would program anything else...

timber mortar
#

hey guys. i'm wondering if i could set a Blackboard variable (bool) spookedKey as a pointer to a corresponding isSpooked bool from the AI Controller's 'Pawn' class?
otherwise i'll just have to get the variable every tick.

misty wharf
#

@timber mortar no. The better solution would be to have an event dispatcher in your pawn like "OnSpookedStateChanged" which gets triggered when the spooked value is updated, you can then listen to the event in the controller to update the BB

cyan sigil
#

Hello, AI. I have several characters being put on the same location and asked to path to different locations. I am finding that this is unreliable, and they will often path to undesired locations or attempt to walk off the map. Is there a way to prevent this bug? Alternatively, is there an easy way for me to place them so they do not overlap but are as close to the spawn point as possible?

fresh remnant
#

@cyan sigil you can either do collision for each pawn which will keep them separate, or use crowd navigation(detour crowd)

cyan sigil
#

How would collision help me? The current algorithm is looping over each character and setting their location to the spawn point.

fresh remnant
#

physics will also push them off the navmesh if you spawn them all in the same location, but they should path back soon after, you need invisible collision walls to keep them from walking off the map

#

collision would have them spread apart once you do spawn them

#

the better way to do it is NOT to spawn them on top of each other

#

because that isn't supposed to ever be a good state for AI

cyan sigil
#

Yeah, that's the other part. What's an algorithm to spread them out? Do I have to use EQS?

fresh remnant
#

spiral

#

spiral + sweep collision traces

cyan sigil
#

Can you link me an example? I don't have spiral math memorized.

fresh remnant
#

you do a sweep around a spiral on a location

#

and see if there's a collision

#

if not then pop it down

#

use the capsule of the pawn to sweep, not a line trace, so you get accurate placement of where you can plop it down

#

scroll down for the equidistant one, works best

cyan sigil
#

Does this assume open space? The spawn point might be in a hallway

#

EQS it is!

fresh remnant
#

that's why you do the trace

cyan sigil
#

Will do

fresh remnant
#

you test each point, if it doesn't work go to the next point

pallid trout
# manic karma Nope

tinkering with navmesh settings worked for me a while back. if its still not for you then I dunno

manic karma
cyan sigil
#

@fresh remnant Thanks, spiral worked great, though it turns out it was also an issue with the MoveTo node I was using (unique to my team)

cyan sigil
#

Another AI question. I've set up my parent BT (though I wish I didn't have to make my own node for assigning the dynamic sub BTs). They currently branch like so:

#

However, the Idle includes a 5 second wait inside it, so even if Enemy is set, the wait needs to expire before the branch changes.

#

How do I have the tree re-evaluate when the value Enemy changes?

cerulean coyote
#

Try messing with the "observer aborts" here, it will notify the observer based on a change in value or result (you can choose) and then depending on what you pick it will "abort" the node, and start the sequence again once it senses a change @cyan sigil

cyan sigil
#

And that can be configured on the Decorator?

#

Do I need to put the decorator on the Idle node then?

cerulean coyote
#

yeah you can put it on the idle node as well. If you want, you can just attach them both to a sequence and have the decorator on that, and it will apply to both of them

cyan sigil
#

Ah, so whenever it flops it will go back to the sequence

fallow hound
#

Anyone ever seen a bt just get stuck in a branch? Looking at the bt it gets stuck in the first node of the branch regardless of which node I put there. The bt is still ticking. The branch has a decorator which should have aborted the branch but it's just running the first node task. This happens on the bt start maybe like 10 percent of the time.

fresh remnant
#

Anything out there to automatically allow units to jump between navmesh regions that are not connected but are a certain 'jumpable' distance apart? I would like it so that whenever the navmesh is regenerated, maybe a new platform is built, that these new areas are 'jumpable' from the current nav mesh for certain units when doing pathfinding

lyric flint
fresh remnant
#

Yeah I don't like nav link proxies they are very limited

#

I'll take a look at what Rama did, looks like the right direction to go here.

#

thanks for the links! @lyric flint

timber mortar
#

how does one get the Pawn or AI Controller from within a Behavior tree (task/service/decor)?

#

nevermind

pallid trout
#

is there a way i can filter out some specific pawns (like the ones who are dead) from eqs?

#

In the first part Im destroying the pawn after death and it works fine

misty wharf
#

you would have to write a custom EQS test for it I think which would check the dead state from the pawn

pallid trout
#

ive done this with the context inputs but never this

misty wharf
#

it is, but only in C++

bold crest
#

Whats a good way to have an AI "perceive" actors that damage the AI? I want the AI to chase after the player if they get hit by a player projectile, even if the player is out of sight

pine steeple
#

Perception Component and Report Damage Event

bold crest
#

thank you!

silent remnant
#

Is there a function for getting the nearest navigable/reachable point?

#

not a random point within radius, but the closest navigable point to a location

#

I found ProjectPointToNavigation which has query extent if anyone else is trying to find this

exotic veldt
#

is it possible to make 2 nav meshes for instance one for cops and one for npc's?

tall rock
#

Easiest way to have a BTTask that activates a GAS ability wait for the ability to call EndAbility?

misty wharf
#

Not really familiar with GAS but in general the way you can do those types of things is to bind some event listener which gets called when the action is complete, and have it call Finish Execute only then

#

I'd imagine there's some way you could get notified of the ability finishing

tall rock
#

Hmm yeah I'm trying to find that notifier, maybe i'll ask in the gas chat

weary zodiac
#

Anyone see anything out of the ordinary with my Behavior Tree?

#

and then AIController

#

For some reason that I don't understand the behavior tree doesn't get entered and ran.

#

I have the BT set on my Enemy AI BP and I have followed code execution to the call to this->RunBehaviorTree(MainTree) but I don't see the BT run.

#

That's what I see when I PIE, but now execution flow. I am pretty new to behaviors, so there's also that.

#

Not sure if "STEPS BACK -1" is indicative of anything related.

#

Thanks in advance for even looking at my question.

weary zodiac
#

ugh, solved... I forgot to call Super::BeginPlay() in my AIController override function

cyan sigil
#

I'm having issue with a custom decorator.

#

This breakpoint is never being hit, even though when I inspect the unit I can see that the correct blackboard key is filled.

#

oh! My mistake. I am getting blackboard value by name, not the current key.

fresh remnant
# exotic veldt is it possible to make 2 nav meshes for instance one for cops and one for npc's?

Yes, you can, there are a few things you have to do if you're using something crowd following, for it to work with both navmeshes. But for non-crowd following, I think the best way is to create two derived classes from ARecastNavMesh and setting the cop agent to use one of the derived classes, and the enemy to use the other. You want to make different ones for different agent radiuses usually. Then you set your agent to 'prefer' the specific derived Recast mesh class in the Agent Properties. Unreal's way of trying to figure out which navmesh to use for which actual agent is messy.

nova prawn
#

Hi, Is it possible for a child tree to run a parent tree? The child has a Run Behaviour node requesting to run the parent tree? Is this possible ? or are all trees individual?

#

I was h oping to run "common" tasks in the parent such as Idle, Wander and things like that and have specific tasks in the child tree

patent hornet
#

you can use run behavior tree task

#

i don't see why BT would bother even having a concept of "parent" tree

#

so i doubt there is anything to prevent you from doing it

#

the maintenance might get ugly though

nova prawn
#

So would I do better to have one tree with a bunch of sequences with decorators basically doing a Select on UnitType?

patent hornet
#

that would entirely depend on what you're doing

nova prawn
#

Coz I have Harvesters, Workers, MilitantUnit,

patent hornet
#

and they can run their own "root BT" each

#

reusing common tasks with run BT node

#

tasks, as in BTs

#

all 3 of those units will have more or less same logic for roaming around, eating, sleeping, or whatnot

#

you encapsulate those in BTs

#

and they run it from their "root BT", which you have one of for each unit type

nova prawn
#

This is what I have atm for a Harvester

#

It runs into the default state.

#

Parent

#

This tree never gets executed.

patent hornet
#

that does need FinishExecute in that task

#

if you ever want it to exit from that Print

nova prawn
#

or would this be a better idea in the parent tree?

#

obviously linking up the other nodes lol i forgot to do it before taking the snippet .

#

It never gets into the PrintUnitState.

patent hornet
#

that has a tendency to cause too much mess later on

#

so best avoided from the start

nova prawn
#

Thats what I thought which is why i was trying to get the parent tree to run.

patent hornet
#

BTs don't scale too great, so anything over 40-50 nodes is unmanageable

#

and you're inviting the massive BT situation with that last example

nova prawn
#

Question do I need to add Run Behaviour Tree to the Parent AI atm I only have Run Behaviour Tree in the Child.

patent hornet
#

define parent AI

nova prawn
#

This is the child AI

#

Parent has no AI tree connected.

patent hornet
#

the last screen you posted would require only the AI superclass to run BT

nova prawn
#

I thought the Run Behaviour Tree node would automatically run the Parent Tree once it hit the Run Beahviour Node.

patent hornet
#

anything else would require only subclasses

#

also

#

don't run BT from BeginPlay

#

as controller doesn't have a pawn possessed yet

nova prawn
#

Oh ok didnt know that only recently got into this, So still learning a lot. xD

patent hornet
#

when you spawn AI its usually

#

Spawn Pawn, Pawn calls BeginPlay, Spawn Controller, Controller calls BeginPlay, then COntroller possessed the Pawn

nova prawn
#

Is that the same for a Character class?

patent hornet
#

both BeginPlays already executed, but you do have OnPossessed or some such

#

yes, Character is a Pawn

nova prawn
#

Ok

patent hornet
#

there are a few exceptions to this, but for now, best run the BT from EventPossess

nova prawn
#

So this would be better ?

#

Ok I got that to still run into the default.

#

Never lights up.

patent hornet
#

show me the print task

nova prawn
#

I just found out what it is.. Seems weird but here goes.

#

Does run when it shares the same blackboard I get message "Hello from ParentTree" show up