#gameplay-ai
1 messages Β· Page 137 of 1
one moment
^^something I can select in this box. And as I understand, these are filters.
right but like i said, filter does not have a concept of NavigationData
So, you think it's not possible?
i can see its not possible using just a filter
hmm, ok, I still wondering but I know you have big knowledge. I have to think abou it.
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?
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.
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)
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
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
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
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
anyone know why this AI's rotation is instant? it doesn't seem to be obeying bOrientRotationToMovement
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
i'll check the rotationrate but i think it's rotating instantly regardless of my rotation rate. thanks for your suggestion regarding OnTargetPerceptionUpdated, i'll likely need to stop it from losing threat behind corners
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
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?
this is the error I get BTW
nobody knows?
Please be patient when asking questions.
Sorry I'm just struggling π I'll be more patient next time
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
or in other words, Is it possible to create a Nav Mesh Bound Volume at surface which doesnt have a collision???
You said bee but all of these classes read ape. Is that intended?
yes! Ape is the Italian word for bee π
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?
Yeah, Nav Mesh Bound volume doesn't have collision! For water you may use Physics volume
Blackboard is running fine if I debug it in realtime mmm
I will try this out
Does Physic Volume correspond with Ai?
yes
great
oh sorry nope! I've though about nav mesh volume
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
it should by default be set without any collision!
the "water/ocean' doesnt have a collision
and my Nav Mesh cannot be created
thats why I am asking
And is the blackboard key name also correct?
Is there a possibility to make a something like nav mesh, which can allow the Ai to move to location within the Nav Mesh
I guess so! Let me double check it
never tried a Nav Mesh and physics volume together so I'm not sure what happens
I'm sure the litteral name is right because if I decide to use a specific index for the class such as "0" it perfectly works
maybe something will works
Hmm. Why do you increase the blackboard value for all bee's when one bee hits a flower?
because I need the bee to get back to the beehive as soon as it gets enough pollen
but I want to update only the specific index of the bee who's hitting not all of them
Hello. I can use the blackboard and the behavior trhee using a pawn and not the character?π¬
Yes
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!
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
Check if your navmesh is generated on the new areas of the level
@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
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
If you haven't enabled it, change the navigation mesh Runtime Generation option to Dynamic in your project settings, that should probably fix it
Yeah, Dynamic should make it regenerate it at runtime when geometry changes
it works tysm :)
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
Does that get worse with overall size of navmesh, or is it primarily affected by size/complexity of the newly generated areas?
wdym as cost?
generating navmesh costs game thread time
so if you generate a lot of areas, you will get hitches
yes, the quicker your navmesh generates, the smoother for players
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
mybe ur pc is powerful?
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
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
@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
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
yeah best way
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
i use 8gb ram and i think it can effect a lot in generally unreal sometimes crashes when calculating things
8gb ram is pretty low for UE4 development
ik
my pc runs at 20-32gb ram use majority of the time π
my pc is 6yr so LOL
ah, time for an upgrade? π
yea :D
@clever skiff your animation BP, has to have a slot node
montages play through this slot node
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
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.
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
@lyric flint you can add blockers with crowd avoidance. What do you mean they are blocking themselves? Are they set to generate navmesh obstacles?
they are yes
of I dont my ai will just walk into it
do i just turn off navmesh gen and use blockers?
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
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
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
...
oh
what can I do to prevent pathfinding on this couch?
I feel like I already set the relevant collision flags
alternatively I can set the agent step height lower but I get other problems
like I've no idea why this mesh gets this pathfinding
@keen crystal make it a navmesh occluder
@keen crystal https://www.youtube.com/watch?v=wpyOZbyxQE8
What is the Nav Modifier Volume in Unreal Engine 4 .
Source Files: https://github.com/MWadstein/wtf-hdi-files
@fresh remnant youre good with AI I guess? π
no I just happen to have dove deep into this navmesh stuff
aah
thanks, I gave that a try and it didn't work, I ended up solving it by reducing the granularity of navigation
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
well, it's weird, I added a navmesh modifier and tried null, obstruct, etc, none of it did anything
you may have to rebuild ur navmesh, depends if you have dynamic navmesh generation on
yeah I've been rebuilding navmesh after trying every option
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
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 π€
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
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
Hey I am working with unreal's behavior tree to practice AI making. Now I came across a problem which the animation works at one state but not another Its sounds silly I know but let me show you:
Red Square - Doesn't work - Floats without animation towards the "Position"
Green Square - Works - Animation plays while
@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
Oh, ok. So maybe tag an agent
Sure try it
Ok, will do. Thx
The only difference I see is that you add an attacking state. Do you do your attack animations in an animation blueprint and possibly are setting a boolean true so it can transition to attack animation and then you are not setting it false before moving to the random location found?
The attack animation is a AnimMontage
It doesn't have a transition or any boolean just a play montage node
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.
May I ask why is that?
i dislike animbp playing montages
Montages should be played at the callsite
not in the animbp
I'd assum his task is calling the montage, I mentioned the animBP, hehe.
breaking encapsulation
Yeah the Task is calling the montage,
hold on i will double check
maybe show some more relevant information
Yeah, seeing inside them tasks would help.
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?
When I tested this sometime ago, the animbp stopped because if was interrupted by the PlayAnimation
You are using play animation which changes your animation mode.
ohhhh ok
You will need to switch your animation mode back to use animation blueprint after the attack plays.
Ahhh ok
Thank you for the explanation
Or use an actual play montage node and make sure to add the slot to your animBP.
Will do, much thx @warm dagger
^
This node gives much more flexibility and you can make it so your attack task only ends when the animation actually finishes.
montages are meant for this type of thing
You can also use notifys to trigger that spawn projectile instead of relying on hard-coded delay timings.
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.
Lol yeah, I have had to slow down montages to make sure notifys trigger at the right moment and not during the next iteration of the montage.
@pine steeple Noted ty . @warm dagger I will look forward to it, much thx for the explanation π
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?
FIXED, nmv π
If there is a better way, ping me please! I'd love to learn
this is probably a dumb question, but is it possible to create cpp tasks and decorators instead of blueprint tasks and decorators?
Absolutely! but why? anyways, take a look at Developer\AITestSuite\ In your engine source for more info
it's probably not necessary, but almost my entire project is in cpp and some things i find it more intuitive to express in cpp
good call
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
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
but of course, you can do everything in C++, I've done it before as well
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!
if i get this right, i won't be an indie lonely dev forever π
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?
Perhaps the blocking is hooked up to return success
you could try creating a derivative and overriding a block to return failure/abort
thanks ill have a look into it π
:triangular_flag_on_post: Aditya Raj#0050 received strike 1. As a result, they were muted for 10 minutes.
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?
Seems to be related to this: https://answers.unrealengine.com/questions/53382/is-the-launch-character-node-interrupted-or-overri.html
@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?
oh look at that, you're still active lol
Dynamic BT's with tags?
yes
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
Oh wow you're a spelunker. No, I don't use it because I don't do as much AI work lately. I don't have any examples publicly viewable (besides whatever was posted in 2018)
thank you
but you normally just call SetDynamicBehaviour on the behaviour tree component
with the tag, and the BT to run
where is somewhere you use this kind of thing? I currently have nested BT
i keep that for non dynamic stuff
but i only inject dynamic stuff into specific nodes
as they have a slight cost penalty
maybe I'm not understanding somthing. What is the "dynamic" aspect of these?
change them how?
@deft sedge just to butt in, I use dynamic BTs for enemy combat skills
so that they can choose from several
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?
I would drive this injection through data (tables/asset)
^ that is what i do
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?
I'm not sure I see a difference between that and having a tag check in a decorator
it would mostly be an organisational difference
you can have a massive BT and tag check a lot
it keeps your trees from becoming insane
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
designers like a BT field for, say, MobPatrolBehavior instead of a gamplay tag container which can have that tag
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
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
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
^
monster knows what attack its doing
injects the correct attack bt
and runs it
so you're likely grabbing a montage or something to play then from that data table?
no we use abilities for that
mmm, abilities, my old nemesis
since its a whole BT, it can be moving, targeting, montages, or whatever
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.
I don't know that you would want to use it to change between alert states, that would be built into some common BT
this is a specific to that monster, that bt was injected in
i don't inject everything, just what is required
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?
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
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
Yes
hmm. is there a performance draw back to using this?
@deft sedge yus
@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 π
how bad a cost penalty?
probably not noticable for 10-20 ai, but when your running 100 AI, i noticed a slight cost increase of around .2ms
Kaos can be more specific
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
ok so in this case that's fine. In my horde I probably wouldn't then
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
either the AI die quick, or players die very quick scenario
unless Kaos uses them cheats π
yeah π
thing is as soon as they die, i turn off nearly every system
so they cost nothing when dead
I can render 500 without a problem, just want to make sure i don't have cpu becoming the bottleneck
500 AI moving with CMC?
yep
π€
average CMC tick (non optimized is 0.03ms per AI)
that would be 15ms game time
believes starkium is doomed there
and that is on my spec pc
which means 40 on potato gaming laptop
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
uses empty character with no skeletal mesh and then has an HISM with Vertex animations set to the location and then custom collision detection system on top AND THEN uses monotick plugin to reduce cpu time
shipping build is like 4-8 ms total depending on the scene
yeah you loose a lot of flexibility tho
right, like I said, I can use it for the stealth game scenario, but not a zombie survival scenario. Two different projects
for the zombie scenario there's not a lot of variation so hard coded is fine
look at CoD zombies
can go higher if I switch to pawns
they have a max of 50is at a time
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
but you can do other tricks
like spawn them when the players gets in a certain range
kinda thing
sure, they are pooled too
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..?
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 π
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
you're trying to visualize them in-play?
yep
I'm sure there's a command to show the navmesh in PIE
not sure about seeing the actual bounds
its show navigation but that actually visualizes the navmesh itself
however so i noticed my spawned navmesh bounds are not properly setup anyway
I guess you're looking for something more fine tuned than just the navmesh being correct
it should be like
set the brush in C++ code then
Right, ill have to dive into brushes than, never created one
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
hhm, got any point to some example code?
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?
you just need to set the brush settings
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?
This is not executing
You gotta do some digging. Look through the brush component to try and find where the settings are stored
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
I guarantee, if you can find where it is stored, you can figure out how to change it
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
well are their struggles related to understanding the c++, or with the results of changing the values?
hhm, lol okay
@lyric flint thanks bro! saw it later cause I went to sleep! thats really helpfull π
i think with updating a nav mesh bounds volume at runtime, may not work
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
actually yes, rebuilding navmesh works, but that does not tell anything about the NavmeshBoundsVolume
tellin you it's gotta be in the brush somewhere
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?
iirc subtrees use the parent's BB and that's it
How does that work if the subtree is set up with a different blackboard with decorators expecting different values
Is it makes sense to run AI Move To in BTTask? Because its always failing with "aborted" flag
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
You can look at the behavior tree during runtime to see where its at in the tree
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
Probably unable to navigate then. Try placing a cube where you're telling it to go and verify its actually on the navmesh
π 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 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.
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
@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.
Yes that's more or less the conclusion I was typing out simultaneously haha. Although straight query tasks should probably be services I think?
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
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...
No idea but at least it works for my use :D
ugh, ai feels like the biggest slog in unreal.
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.
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.
you can change the interval
not sure if you can make it zero, but make it 100 or something should be good enough
is ticking at all a concern if there's no implementation for the tick event...?
i dont think so
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
an empty blueprint tick is expensive as shit if you have a lot of them
hmm that's what I thought
define a lot
"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
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
won't it be called in c++ still
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
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
I mean, force them to do another task in the bht
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.
you wanna cast inside a bbtask?
do event recieve execute ai then?
oh wait
i always get casting confused π
you can cast to a bb
like this @lyric flint
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...
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).
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
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?
There's a builtin decorator for it that you can use, blackboard condition or whatever it was called
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?
should i use a service, decorator, task, or some other means?
@timber mortar use a decorator
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?
I think you have to build the nav mesh while all the levels are visible in editor
then dont rebuild later
@storm zephyr set your navmesh to Runtime Generation: dynamic
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.
@fresh remnant does it have to be dynamic? right now i have dynamic with modifiers
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..
i managed to get it to work by changing 'Cell Height' to 20, any idea why it works then?
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?
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
thank you man
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
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
Yes thank you
I made the noob mistake of assuming the AI work anywhere
but now all is well
I appreciuate it
I didn't know that... I always just assumed that the navmesh was generated at runtime. good to know.
I suppose, duh... how else would it be present before PIE
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
:triangular_flag_on_post: Aditya Raj#0050 received strike 2. As a result, they were muted for 1 hour.
Epic has some work to do https://youtu.be/nnuSQvoroJo
0:04:24 - AI Test starts
Scripting AI test in Modbox using OpenAI GPT 3 + Replica for voice acting.
2:26 It's like having a human actor to direct in your game
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
is there a way to run something only when the BTService first starts?
i was missing bNotifyBecomeRelevant 
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());
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);
}
}
@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.
Does any of you know how to move higher the SIght AI Perception point? I want the enemy to see the head
@wet ether only doable in C++
I assumed this option, but what exactly should I do? I have no even a single idea
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
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
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
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?
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
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
did you fix the code
I've added this and the errors were gone
static const FName NAME_AILineOfSight = FName(TEXT("TestPawnLineOfSight"));
FHitResult HitResult;
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
Yea, i tried that, but here is what i got
Any socket? Any special name?
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
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?
Yes. I used this and now the enemy properly sees the character
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
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?
there's the orient rotation to movement setting in characters
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)
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
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 π
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?
funny thing about that, its stuck in that MoveTo until the move is completed
can't do anything else
I thought that part of a tree would be enough. I have a movement interrupting task in another place
why you nesting simple paralleles?
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
Not sure, maybe I misunderstood your problem, but perhaps you should consider running RequestStimuliListenerUpdate on any component that changes parameters?
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
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
Are you sure its the server where the problem is? That should be ok on the server. but the controllers dont exist on clients
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
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.
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
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?
Is creating multiple behavior trees not best practice for the same enemy character ? Like a patrol enemy and a lookout enemy.
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
Gotcha, thanks!
For a single AI, good way is to have states stored in an enum and switch between them according to some conditions.
The same works for you. Use a selector to run the behavior according to the state
For multiple that do different things, I use multiple bt
How many different things do you have
Thats pretty simple
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?
Only if its way too complex
I see. I'm not sure what the line is lol
What would be considered complex?
like taking cover during a firefight?
i made a simple one with patrol, investigate, follow, chase, find/take cover/find cover to reload, find health pickups etc . doable in one BT
I see. π to me that seems complex
you wouldn't happen to have a vid of that would you?
No
When you say complex... do you mean computation complx?
where there a multiple options for an agent to do
or should I say, multiple decisions
If there was a single option it wouldn't be a treeπ
Just do what works for you.
Also multiple Bts need to be on the same blackboard to be changed at runtime
I can't have multiple blackboards?
Does the blackboard exist per instance of an agent?
I think no. Maybe if they're inherited
Yes
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
@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)
Is anyone here good at making ai?
i would hope someone is
I am like horrible making ai with blueprints
@misty wharf you can also just casually toss an object with IGameplayTagAssetInterface into a BB
Interesting
I had a feeling the gameplay tags would be possible to translate into an FName or something
they are names
but it seemed less compatible than just having the gameplay tag option for the type
with a lot of fancy ontop
Right, good to know
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
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
yeah, we wrapped it π
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
Looks like FGameplayTag::RequestGameplayTag is actually deprecated, should use UGameplayTagsManager::Get().RequestGameplayTag instead
locked on 4.25 so not for me
does not look deprecated for me in 4.26 either
its just a nice static wrapper for
{
return UGameplayTagsManager::Get().RequestGameplayTag(TagName, ErrorIfNotFound);
}```
Wait which file is that in
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
I think I was looking in the wrong file :P nevermind the deprecation
GameplayTagsModule::RequestGameplayTag was the one I was looking at
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
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
@void stump Nothing especially unique about what you're describing. A general look into how behavior trees should be fine for what you want.
are there no performance limitations ?
maybe some good workarounds?
what about flowfields and collision avoidance between ai workers
800 ai's wont be on the screen at once.
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
For something like that you're going to definitely want an AI setup that is not evaluating every single frame for every single AI.I would try it with stock behavior trees first though, and just see how it does.
Disabling physics and options like tick only when render could be useful
Recent Ue livestream on crowd optimization with niagara could be exactly what you want
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.
@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
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.
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
very helpful thanks @misty wharf
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..
:D I fixed it don't mind me I have the iq of a crustacean
Luckily I can think of no better animal to embody than a crab if your goal is to move along a single axis.
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!
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
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?
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
How can I find it?
I havent heard of this before. Cant find any documentationπ
If an AI is hostile, you can get the player pawn and change the HUD state from the AI tree itself maybe
Instead of getting all AIs you would be getting the player from all AIs individually
The issue with that is that they will overlap... Meaning that the patrol will cancel the hostile, and the searching and so on
If the player is hostile, it should overlap anything else
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
@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
And then using tick to check changes?
Btw, I could find any docs about AIManager. If you could provide me a link to what you mean or describe it with an example, I would appreciate it.
you can store the previous state and the current state. Also an integer for the number of hostile AIs in the gamemode or level bp or game state. each interval (sec or tick), check if the state is hostile.if the previous state was not hostile then +1 else if the current state if not hostile and the previous was hostile then -1. You could easily get how many hostile ais there are
could work for all states with a bit of implementation
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?
Its not using get all actors of class
So yes its definitely a lot more efficient
So it's get all actors of class that's really expensive I get?
Yes
Do it once and store all in an array, use ai manager or use the workaround i said above. Theres tons of ways
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
Yes
Thats what I was afraid
A simple is valid check will fix that
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
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...
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)
definitely separate bt's and controllers. separate bb's, might as well
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 π
Question: What does the near clipping radius do?
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
They get destroyed when everything referencing them gets destroyed
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
In project settings try increasing the height of the nav mesh
is your character smaller than the mannequin
sorry ^
thats probably why youre facing this issue. Either the cell height for the nav mesh or step height in your character works
I've got the cell height at 10 and the max step height at 36 in the recast
the generation near the stairs is so odd
No matter the generation. is it functional
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
So is navmesh UE's ONLY source to have ai work?
keep forgetting to reply you sorry
@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...
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.
@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
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?
@cyan sigil you can either do collision for each pawn which will keep them separate, or use crowd navigation(detour crowd)
How would collision help me? The current algorithm is looping over each character and setting their location to the spawn point.
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
Yeah, that's the other part. What's an algorithm to spread them out? Do I have to use EQS?
Can you link me an example? I don't have spiral math memorized.
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
you're in luck, I have that handy:
// from https://stackoverflow.com/questions/13894715/draw-equidistant-points-on-a-spiral
scroll down for the equidistant one, works best
that's why you do the trace
Will do
you test each point, if it doesn't work go to the next point
tinkering with navmesh settings worked for me a while back. if its still not for you then I dunno
yeah I've spent hours messing around and not really gotten anyway
@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)
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?
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
And that can be configured on the Decorator?
Do I need to put the decorator on the Idle node then?
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
Ah, so whenever it flops it will go back to the sequence
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.
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
maybe https://docs.unrealengine.com/en-US/Resources/ContentExamples/NavMesh/1_2/index.html ? Although Rama has a different opinion π https://forums.unrealengine.com/development-discussion/c-gameplay-programming/3681-navlink-and-making-ai-jump?p=222996#post222996
An overview of the NavMesh example level, example 1.2: Nav Link Proxy.
For gameplay programmers writing C++ code.
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
how does one get the Pawn or AI Controller from within a Behavior tree (task/service/decor)?
nevermind
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
you would have to write a custom EQS test for it I think which would check the dead state from the pawn
custom eqs test? is that even possible.
ive done this with the context inputs but never this
it is, but only in C++
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
Perception Component and Report Damage Event
thank you!
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
is it possible to make 2 nav meshes for instance one for cops and one for npc's?
Easiest way to have a BTTask that activates a GAS ability wait for the ability to call EndAbility?
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
Hmm yeah I'm trying to find that notifier, maybe i'll ask in the gas chat
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.
ugh, solved... I forgot to call Super::BeginPlay() in my AIController override function
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.
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.
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
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
So would I do better to have one tree with a bunch of sequences with decorators basically doing a Select on UnitType?
that would entirely depend on what you're doing
Coz I have Harvesters, Workers, MilitantUnit,
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
This is what I have atm for a Harvester
It runs into the default state.
Parent
This tree never gets executed.
that does need FinishExecute in that task
if you ever want it to exit from that Print
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.
that has a tendency to cause too much mess later on
so best avoided from the start
Thats what I thought which is why i was trying to get the parent tree to run.
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
Question do I need to add Run Behaviour Tree to the Parent AI atm I only have Run Behaviour Tree in the Child.
define parent AI
the last screen you posted would require only the AI superclass to run BT
I thought the Run Behaviour Tree node would automatically run the Parent Tree once it hit the Run Beahviour Node.
anything else would require only subclasses
also
don't run BT from BeginPlay
as controller doesn't have a pawn possessed yet
Oh ok didnt know that only recently got into this, So still learning a lot. xD
when you spawn AI its usually
Spawn Pawn, Pawn calls BeginPlay, Spawn Controller, Controller calls BeginPlay, then COntroller possessed the Pawn
Is that the same for a Character class?
both BeginPlays already executed, but you do have OnPossessed or some such
yes, Character is a Pawn
Ok
there are a few exceptions to this, but for now, best run the BT from EventPossess
So this would be better ?
Ok I got that to still run into the default.
Never lights up.
show me the print task