#gameplay-ai
1 messages ยท Page 112 of 1
this ai channel is quite dead aswell
most people either give up with ai, or keep themselves to themselves due to the UE4 ai system ๐
๐
has anyone every done an ai navy ship? Totally dont know where to start with this..
listing on a piece of paper what does it need to do really
it needs to kind of strafe the enemy and angle itself etc. ever played world of warships?
yes, and that is pretty vague for designing an AI
To make a ai that knockback the player whan thay overlay ๐ I used in the end with radical force for nice results
is there a way to have a decorator basically only evaluate once when the behavior tree is created?
because I have some conditions that wouldn't change for the lifetime of the AI enemy basically
just figure it'd make it slightly more efficient if it permanently pruned the subtrees that it couldn't evaluate
I've created a collision sphere around the player which I want another AI/pawn to take into account when using GetRandomReachablePointInRadius. The collision capsule on the AI pawn does collide with the player's collision sphere, but it doesn't seem to consider it when getting reachable point. What happens is that the AI sometimes finds a point that is at the opposite of the player and just stops/get stuck in front of the player. How do I make the AI consider the player's collision?
Overlap pawn and make the object type the same as AI and player
@simple minnow cost is negligible, and they just might improve the BT's readability
@simple minnow use a boolean.
Well, I donโt want the decorators to have to be instanced so that rules out any sort of state in there, I was just wondering if there was an evaluation mode where it only gets evaluated once per tree, but that doesnโt seem to be the case
It does if its on root node of a tree ran from another tree
just a quick question is it possible to calculate a path to a point, store it and then use that for the ai movement ? (just looking for a yes or no just to see if I'm heading in the right direction)
yea
ok thanks
Can someone please help me understand whats going on here?
Any reason why the Mesh Component Update Flag "only tick pose when rendered" works for clients while the movement component "Update only if rendered" doesn't?
is there something else going on here?
shouldn't the same rendering check that tells the AI actor/mesh/components if its being rendered by a client to update the pose also contribute to the movement component?
Is this just a bug from testing in editor with 2 clients?
hello. I found a pretty neat AI blog (not may posts and not really updated but with good information nevertheless)
Link: https://www.vikram.codes/blog
Anyone know how Epic managed to pull off the new Horde mode in Fortnite while keeping above 200fps easily?
They seem to have 50+ AI on screen at some points with little to no drops
I wonder if that's 50 AI controllers and characters?
Maybe they are sharing animation some other optimisation? Either way it's very impressive
Client side has no AI controller so that's not related, but characters only. Yes they use sharing of animations its been announced as new feature.
Very true, I forgot that the server does all the logic behind the scenes
So it's much more lightweight for clients
Definitely interested in the sharing plugin, will look into it
So so. Client has to work a lot on rendering and animating things. On server, they are just standing capsules only (in best case)
True but the client doesn't have to run the "brain" logic which is often the thing that can bog down performance on the CPU (as they each might be checking for many things multiple times a second), the visual side has much more leeway (optimised anim system, skelmesh LODs etc.)
Still impressive as it runs extremely well
Hopefully they'll share some of the tricks they used on it as pretty much any time there are more than 40 characters on screen, there's a hefty drop due to character movement component
Maybe they used the cheaper movement options available, or maybe the server can just handle it, as the client just gets the replicated position
@unborn jungle the clients can handle everything other than movement. On dedicated server the server doesnโt render anything and using cpp and pooling along with navigation movement you can get pretty cheap ai (6ms cost for 50 ai)
There is the animation tick only when rendering and the movement only tick when rendering for clients to help the load
With perception and behavior trees there is already a lot of batching going on as well
As long as your controlling components culling manually and keeping the movement components from carrying around a lot of components the cost is reasonable
6ms for 50 ai?
how is that cheap;
i have 130 ai running at 6ms ๐
the CMC is poorly optimized for AI
its built more for Player controller characters
if you want top performance, best to write your own movement component
I agree โ๏ธbut I didnโt write my own movement component
But I also donโt need more than 50 ai on screen at once
make sure all animations are fast pathed, they are not doing lots of stuff constantly on tick (use timers if you need to do things), and your BT services are set to the highest possible tick time to function
lots of optimizations to get 100+ ai on screen
but it is possible
@silk drum we spawn 100 monsters pre-placed in the map
And the cost is really 4ms -6ms based on what is happening and all 50 rendered and honestly Iโm only partially done optimizing
and they are completly dead per say, when a player is within X range of them they enable there ticks and render there meshes
other than that they are just dormant there
but we can have 100 ai running around the player
at 6ms
and thats just with a tuned CMC
i really do need to write a complete movement component though
Iโm still trying to figure out why my movement component isnโt recognizing clients to โupdate only when renderingโ bool
It seems this only works for the server unlike the animation tick method on the mesh
๐คท what engine version?
Listen server has to render the ai in order to update movement
But it could be an editor testing bug
From simulating 2 clients
I havenโt tried running it from a standalone yet
There is a only update when rendering bool on the movement component
For even more optimization
4.19.2
yeah
dunno, when my ai are placed on map and not moving
i just disable all ticks on the pawn
and the only thing that runs is the Behaviour treee
this re-enables everything when a player comes close
Yeah thatโs my setup
None of my actors tick
I use perception events and BT state enum with decoration
No tick
i just have a bt service not even perception (cause they have to listen and gets quite expensive)
i just every .5 seconds do a check for players near them
if there is, they come alive ๐
and thats cheap as chips
You doing a line trace
Hmm ๐ค
Store in array
if one is less that the distance to come alive
then they wake up
the array is pre-populated in gamestate
Thatโs nice
it has all player controllers
You could do the same with a spawn manager I guess
my spawn manager is quite complex
Or posses/unposses
Yeah you can unposses and kill all logic on the ai
where i will pool controllers and pawns
and when we spawn new ai, we first try to pull a controller and pawn from the pool, instead of spawning new ones
to save on game hitches when spawning 10+ ai
Seems like a great movement component optimization but unfortunately it seems recentlyrendered() only returns for the owner
which in this case is the server
https://gyazo.com/84c015c63df98d7450bc552c774199eb hey guys how can I check the distance between players here
I already got the two world locations of the AI and player now I want a logic for how to check for the distance between them and if it's less than something the audio will trigger but how can I do that with vectors
there is float distance(v1,v2) already what is your question i dont get it
@mystic dock https://gyazo.com/9d47cc52fa660f789f925d4baa1dc7bf
I want to trigger the music once the distance of the player enemy reaches a point
the problem is that I dunno what to compare or the logic to set up I got the two locations of the characters
so what can I check for ?
use overlap spheres, pry easier
your screen vid is ghosting a lot, how did that happen
Going by the above BT, swap that selector for a sequence
You're welcome. ๐
@pine steeple Very interesting chat above. Do you have any tricks to reduce the CMC performance impact as I have also noticed this is slowing things down the most. I'm looking at it from an angle similar to the Fornite horde AI though- humanlike characters that are definitely pooled but otherwise have many of the navigating and spawned at once. There could possibly be even more than 50 on screen at once with a full squad, and my game is still running at close to max framerate. Epic really did a good job optimising. Maybe they used the cheaper pawn movement option even though I haven't noticed much of a change there
they do have a custom movemement component for the husks
2 of the most resource intensive things are, CMC and SkeletalMesh (Animations, bones, etc)
Ah that explains why it seems so much cheaper. They are also using the shared anim plugin probably to further reduce cost
Thanks
Hi everyone! I was wondering if anyone had any AI navigation solutions for surfaces, like planets with a center of mass. I currently have a player character that adjusts their orientation relative to the COM.
hi, i dont know if this is a bug or im doing something wrong. I got a 3 cubes streched each one has his own spline, they should rotate around the enemy, but instead they go crazy around the map. im going to post my blueprint. My blueprint works on a actor, basically a blade wall trap that loops around the wall.
it starts with a event begin play then goes to a sequence to 3 different timelines, to 3 different blades
they all go crazy around the map
the blades are part of the enemy
A rough guess. Physics. Moving things will have the game apply physics to the moved item. I'll also say I am by far not an expert in these things. I may be completely off.
Also, that particular issue probably not an AI one ๐
Found it thanks
If I wanted to specify all actors of a certain class in EQS, but with further conditions (are they alive / on the same team etc.), would I need to create a custom generator in that case?
The all actors of class EQS generator is great but doesn't seem to allow any more filtering so it'd return lots of potentially invalid results
Or maybe a custom test is what's needed here using the base All Actors Of Class EQS generator?
@patent hornet So in my case I should get all characters via the EQS generator, then create a custom test to filter based on health, team ID etc.?
pretty much
Ok thank you!
generator first, then tests, cheap to expensive ones
Will do the custom test first as it completely filters out most characters
Then the standard distance / trace
you'll definitely want to check for bool IsDead before you check something like IsPathPassable
Yeah exactly
I want to make sure the target is alive and valid
Otherwise the query could run constantly and keep returning invalid results
I guess I thought it wouldn't need a test since I can filter these characters in a context
But maybe I'm confusing contexts and tests
If possible, I'd like to get the functionality of the Get Actors Of Class EQS generator but on a specified context
As then I can supply only the relevant actors as the starting point, instead of every character on the map
But regardless, the custom test should work
eqs automatically runs the cheapest queries first
specified by the cost enum
Distance test being Low, Pathfinding being High
@pine steeple I'm more confused on whether I need a custom test in my case or a custom context. I am using the Get Actors Of Class generator which returns all characters of my type, and want to filter them down to only relevant ones (alive, has a certain amount of health, team ID etc.)
This seems like a custom test, but where do contexts come in then?
As a custom context can also return this same info
For example the trace or distance tests will ask for a context
So should I not do a custom test and instead pass in my custom context, or is there a way to have the distance and trace tests just use the remaining actors from a previous test as the context?
a context is who or what you are tracing to/from
so for a line trace for example
you want to trace from Item to Player, so Item will be start context, Player will be target context
so think of contexts of "who i want to test against"
or who i want to generate points around
@pine steeple Thank you very much! So in the case of only tracing to the enemy characters and not every character on the map, should I specify these as contexts, or should I filter via a test before tracing?
That's the distinction I'm having a bit of a hard time understanding
If there's a way to basically have the trace test trace to all previously filtered results (in the case of the All Actors Of Class generator being then run through a custom test to ensure they are on the opposite team, then pass those results in as a context?)
For example on the official UE4 docs, they use a context to filter out actors by team
Instead of a test
I'm quite confused on which one should be used in the case of picking the best enemy character in an area
sure you can use contexts to supply a set of actors to test against
thats what i said above, contexts are what you test against
hello. I am trying to move a car towards a TargetPoint. The problem is the path computed is efficient but it doesn't account for the width of my object. I have placed 2 navigation testing actors with the same agent radius and height as my car object but the path drawn between these two actors is still not changing after updating the nav agent radius. What am I missing?
Thats odd, HeavyGM. I'd expect the nav agent radius is contributing to the path.
When AI reaches the first target point, it stops for a split second before starting to move to next target point, is there a way to fix it?
nope and yes
we worked around that, by teleporting a empty actor around
and having the ai goal track that
so the ai never stops when it reaches the location
@woeful parcel did you adjust the cells?
is there a way to make a sequence stop if the decorator conditions are no longer met?
or do I need to like make a service to decide the branch and then have that on a parent node?
basically I have melee attacks and ranged attacks, I want to use melee if the enemy is closer and ranged otherwise
but the problem is if the player is close so they pick the melee branch and I run away, it won't end the move to task
I guess other choice would be to make a new move to task that aborts if the distance is out of the desired range
@simple minnow decorator reacts to value change
observer aborts whatever it really needs, in this case it would probably be self
and your tasks need to return finished OnAbortReceived
hmm observer aborts self doesn't seem to work for the move to task, maybe
it will send abort to it
so inside the task, override OnAbort
and have it FinishExecute(false)
if its engine task, you can just derive BP from it and add stuff
I put a breakpoint in UBTTask_MoveTo::AbortTask, and it does not get hit except for when I close the PIE instance during the task
oh, maybe in my decorator do I need to do something specifically to handle the flow control updates?
it has 2 modes
value and result change
iirc, value will immediately react to BB changes
and result only when exec passes thru it
not quite sure there, really
it seems like the decorator might have to manually call ConditionalFlowAbort when the condition might've changed
well, it looks like if it's condition based on a blackboard key, it would automatically call it because BlackboardBase does that
if the key changes
updates/whatever
so in my case it's a distance check between the enemy ai and the blackboard key target player, and that key doesn't change
well it can change but like not if I'm the only alive player
for melee or ranged abort routine
you'ld probably want closest player
or closest enemy, depending if AI can beat other AI
yeah I have a service that automatically selects the correct player to attack based on conditions, so in the event the target key changed because of that, it would flow abort as is currently
ok, I got it working by overriding TickNode for my decorator and manually calling CalculateRawConditionValue and if it becomes false, call conditional abort (if the flow abort mode's not none)
@pine steeple the cells are like this:
the problem is if I adjust the agent radius and height from the recastnavmesh, my PathFollowingComponent will not move the car
It wont generate points for the car to follow on the nav mesh ๐ฆ
but if I would like to add other types of AI objects with smaller radius, wouldn't changing the recastnavmesh-default be a problem?
is there a way to define a recastnavmesh for objects individually ?
the navmesh is generated by voxelizing the world and then fitting a mesh to that
what sort of nav agents does your project support?
well right now a simple vehicle (that has a VehicleMovement component)
I would like to add humanoid characters as well (pedestrians) @wary ivy
so i would have different radiuses for different agents
Hi, anyone knows its possible to define a area (with volume shape?) to be a proir path (like a road)
@woeful parcel I meant project settings, I think there's a list where you can define different agents and different radiuses for them and such
not sure if that's the place to put them though :\
@wary ivy I will try to see if that changes anything. I would avoid changing the project settings for my case here but I will give a look
thanks
@wary ivy maybe this will shed more light on my problem:
I did find some settings in the project settings and set the max agent radius to be the one outputed by the debugger
but the pathfollowingcomponent still thinks the path that should be followed is "the optimal one" and as you can see the car can't turn because it doesn't have the space to do so
no idea sadly, haven't dealt with multiple sizes of nav agents
ah I see. thanks anyways!
@woeful parcel when you drop down the "supported agents" property in the Nav mesh bounds volume actor, do you see your agent setting is activated?
Maybe it is just using some default internal values until you check those to be used
Also, i don't usually change settings on the recastnavmesh actor, but instead i configure these settings in the project settings, and just regenerate the the recastnavmesh with the new settings being applied.
I found this to be a good strategy, since it happens sometimes the recast just goes crazy after a few changes to the map, and i have to recreate this guy in order to get it working properly.
@mystic dock yeah I tried that but still fail
I set the nav mesh bounds to be the whole map
but when I hit the " on my AI car to see it's navmesh
I get this
in edit mode I have
I modified the agens in the project settings
Yeah the gameplay debugger is broken for the most part, tho it should work in PIE.
made sure that my nav mesh bounds has the vehicle supported as my agent
do I have to go somewhere and tag my vehicle as "Vehicle" or something?
I am going nuts I've been at this for days now
If you have more Supported Agent NavigationSystem will pick "best fit" for your AI (a one that will guarantee not getting stuck, if possible).
So that means it should pick it up once the dimensions are fit, without specifying it anywhere.
Do you have this enabled on your movement comp? If there is such a setting anywhere to be found.
yes
I have tested with both enabled and disabled
the issue is that if I change the recast values (agent radius/height)
my agent will not move at all
I know it sounds weird
Probably because it thinks stuck already. There are strange results sometimes happening with good values too, i think ai is kinda messy to work with.
๐ฆ
Btw the label says it will look for 'collision capsule size' tho your actors here showing cube and sphere. Maybe your pawn that moves has to have a capsule as a root component, and use the pawn itself to follow the path and not arbitrary actors.
I'm not familiar with your setup actually, but maybe the issue is there to begin with
the moment I add a supported actor in the project settings
the nav mesh for my vehicle just stops working
Likei said im not familiar with your setup, but you must understand that many systems of unreal, especially the ai are based on assumption that you are following the described ways in documentation, or looking at the code and understand how it works. Otherwise it will just get you strange results since it is not working properly under the given circumstances.
I'm not saying your setup is wrong, but it could be the issue actually.
yeah I might have fucked up something in my project
might as well scratch it and start from the beginning
:) Dont get dramatic. This might be a simple overlook of your setup. You just have to understand where the problem lies, and it will take some time. I've never had this particular task to work on, so i absolutely have no idea what else you should look at
But the way you are testing is looking good, i'd do something like that too i guess, and going in code to see what makes it tick, figure out the error by following the internals of the engine. It could take days indeed. And by the lack of documentation it is frustrating too.
yeah
thanks ๐
I dont have much in my project anyways
so thats why Im saying I can scratch and start again
I think there is a chance youll end up here again, but whatever feels good just follow your guts
No I am not @pine steeple
so my AI is blocked because it can't compute the path if I add an agent and change the default values
the nav data for the agent is empty whenever I update the nav agent radius and height from the recast or the project settings
well seems there are a lot of people that had this problem
I think someone should pin those answers...
I spent days head bashing on everything I could find until I finally searched the right thing on google
did you not delete the recast data?
i thought you said you did that
its common thing when adjusting the bounds
just moving the bounds regens the data aswell
I was moving it a bit
but I had to restart my project and then moving it helped
because my nav mesh was being updated visually but for the AI object it wasnt
so i could see the mesh with the right radius but the car would not move
anyone knows its possible to define a area (like a road) that ai will use prior other area's in navmesh?
nav bounds or volume thingys ๐
has anyone else had issues with navmeshes not generating in 4.20+
because mine used to work fine until then, but all of a sudden its stopped generating them across projects
it only seems to be an issue with 'saved' maps, since the default map works fine
i've actually imported maps that have navmeshes not generating into the default to check its not just my maps being weird, but they work in the default so
@thorny crest Yes there have been some funky things happening with navmesh for me
Sometimes it happens in builds too which is a real pain
What is wrong in this simple code? The charcter see the other one, but just dont want to move to him.
Dont know why they dont want to move, I tried it with Behaviour Tree with the simple move to, but even this doesnt work
But I placed a nav mesh into my map
I'm setting the Focal Point and its reading my target player, but the AI still won't face the target. No matter what I try the AI simply won't face the target. Multiplayer setup so I'm not sure if I'm missing an RPC or something? Have tried several ways to no avail
Pawnsensing is depreciated, AI Perception is the new version. Other than that, sorry no idea.
no matter what i do, even in single player mode, ai won't face the player unless I use moveto. I've tried simple SetFocus and other ways, but no matter what the AI just doesnt look at the player. I dont get it
it says the focus is set on the player but still wont face it
Hey guys! i have a small question:
EQS is still considered experimental, and i was checking it because i'm in need to get the "Closest" navigation point from an unreachable area on the navmesh, and it seems EQS is basically made for this...
is EQS experimental because of performance or stability issues? is it production ready?
cheers!
I think itโs because they donโt think itโs as user-friendly to use as it could be, and itโs not a priority for them to update the UI and stuff right now
But plenty of people are using it in their projects
Itโs been out for like 3-4 years now at this point
i get it
thanks!
i was trying to do a simple distance to an actor
test
but i'm having issues and the documentation is broken
ah there it is... i was missing a context
geez, its pretty difficult to learn to use EQS without the user guide
Anyone ever tried to implement a utility AI system? I came across that topic and it looks great, but there are some open questions that someone who is familiar with the concept surely can answer
Kanna: I've done it a few times.. whats the issue?
so, when you do your task evaluation you probably do in it a set interval right? how do you manage transitioning between tasks? do you allow a task to be abandoned every time another task becomes more valid? Or do you make a differentiation between tasks that are allowed to be quit (like moving to a certain location) and tasks that are not allowed to be quit (like performing an attack)?
unfortunately there aren't many unreal specific tutorials on that matter ... I suppose in unreal you want to use the AIController as some kind of intelligence unit and some kind of array storing your tasks, which would probably be UObjects of some sort... but I am still quite unsure on how to implement that. I guess I would use blueprints to visualize the thought process and write the actual tasks and evaluation code with it's curves in c++
which in return would mean that every different AI class needs its own custom controller - so an intelligence component would maybe make more sense
hey guys, been making a utiliy ai plugin for the market. Would be cool if more people could fill out this survey so I can better gauge what kinds of tool and usage scenarios are needed https://www.surveymonkey.com/r/Y65QNW6
Take this survey powered by surveymonkey.com. Create your own surveys for free.
So I'm trying to decide how I want players to react when they get hit by enemies attacks. Should I make them ragdoll and then can recover or should I use animations and maybe launch players? Think in terms of large enemies with heavy attacks such as a large Sword or Mace smaching you and sending your flying. Also this is a multiplayer game so replication is key.
hmm I wouldn't suggest ragdolling on a knockback. if you're using gameplay abilities I'd use the root motion tasks for that, not sure how easy it would be to copy that behavior if you aren't using GAS, though
Yea I didn't think ragdoll was the best. I was playing Dark Souls III yesterday and noticed they use animations and move you or launch you somehow. I guess I'll just have to research more.
@simple minnow Ok so I had an idea that kinda works. I get the direction the enemy is facing when he hits an opponent and then launch the character in that direction. It kinda works. I'm going to see if I can maybe add a new animation state for flying through the air and see how it looks. https://i.gyazo.com/27f0b73f17d973ce74c274638c4d3b76.png
Problem is replicating that when thereโs a ping of like 150ms
You may get lots of server corrections
Hey all, anyone have the problem where a Behavior Tree becomes inactive with another level is loaded in? Im loading in lighting data from other scenes and I do have Enable AISystem checked in all scenes. When I turn off the level streaming, the behavior tree starts working.
Thanks!
yep, had a similar problem, but unfortunately didn't find a solution :/
thanks Kanna, if I figure it out ill ping you.
hi all, may be someone know why DistanceToTarget is not executing(it executes only one time before first run of moveto)?
its a service probably missing the ticks while executing the branch
is it just me or does GetRandomPointInNavigableRadius give you points that definitely are off the nav mesh?
@simple minnow yeah Iโve noticed it happens quite a bit (4.22). Often inside geo or in other inaccessible areas that the navmesh definitely isnโt occupying.
Quite frustrating in situations where you only want a certain number of items to spawn but be definitely accessible by players and AI
Iโve worked around it by placing many potential spawn points in definitely accessible locations but for more dynamic stuff (like near a moving player), the problem remains
has anyone ran into issues like this with the navmesh? The green path should be straight like the purple ones but it does that weird bend
the goal location is just on the border of two navmesh tiles
after changing the tile size it works just fine
are you trying to make something grid based? If so, I would rather create my own pathing and mark fields as walkable or non walkable
that's not what I asked ๐
but yea, I am
I want it to work on top of the navigation system
and it works other than for those weird errors at tile edges
I was using FindPathSync for the path but I settled for a nav raycast
seems to work better
navlinks and all that shit works too
I'm trying to create AI for a character that moves around from
one random location to another, but every time his behavior tree containing his AI is activated, he freezes in place both with his animation and walking. The output log keeps saying that the problem is with my BonnieNPC reference.
Lemme zoom on that last image
So apparently BonnieNPC is pending kill? How do I fix that?
to me that looks like your ai character is tagged by the garbage collection and about to be deleted. your chica ai as well
I never encountered that problem in bluebrint, so I cannot help directly. I had a similar thing in C++ however and it turned out that my actor was not referenced by anything and the system therefore cleaned it up. maybe that information already can help a little....
Hey guys, yesterday move to actor node was working without problems, and after I deleted part of c++ code which added detour component to my custom aicontroller, move to actor stopped working, navmesh is there but movement request fails. Any other move to nodes are not working either. I tried to revert code it is still not working, even reparenting to another ai controller.
I spawn ai controllers from game mode and then possess bots with them all from c++ if that makes any difference
I am already out of options to try, what can you advise me to do
Well it's not much but if you try 'move towards directly' (not sure of the cpp equivalent) without projecting the destination on nav (usually a chekmark on the node, remove the project to nav) it may start moving once again, and that means the nav is broken. Alternatively there is an event of all move nodes being triggered AAIController::OnMoveCompleted with a struct FPathFollowingResult.Code that may give you some hints why is it not able to project you any kind of paths.
That's not much to go on, but you can try these things maybe it helps to reveal the issue. I think it's nav related, but you never know.
@mystic dock I found out, that blueprint which was derived from C++ controller had issues in initializing correct navigation component, so I had to create fresh blueprint and copy all of the functions there T-T
such a waste of time
Hi, a quick question. I dont seem to find in Google, but how do i cast to the behaviour tree, on the NPC (character) Blueprint?
without casting in a AIController
Pretty sure you have to get the behavior tree from the ai controller
How do you do or clauses with decorators?
I think decorators have to be ands don't they?
oh okay strange
but you could maybe apply De Morgan's law, eg. a || b is the same thing as !(!a && !b)
I'm just trying to run a branch if either of these decorators are true, seems like a simple use case
none of the AI documentation seems to work for me anymore
The state of docs is puzzling to me ๐
yeah they've been kinda buggy last couple weeks, I wonder when they'll actually switch to the new documentation system they mentioned
oh, here you go
you can declare a composite decorator
and then access all the sub decorators you want in there
yeah that should do it
looks like that @smoky summit
ahh okay awesome, I'll try and figure out that
just add the composite and then there's a sorta blueprint like graph you can edit with the decorators and a couple of logic nodes
@smoky summit
oh
nvm delayed
i was going to say Composite, but ya know discord
๐
๐
If one were to make an AI that doesn't move but just performs would you bother making it a pawn or just an Actor?
depends on if one needs an AIController or not
its not just moving, there is no BT for Actors either
I decided to go ahead and make it a child of a regular player pawn just in case and to have all the same essentially vars and methods Ive added to it at this point.
I cant seem to be able to use behavior trees from AAICharacter::BeginPlay using RunBehaviorTree. Does not work, even for a derived blueprint class. Pure blueprint works without issues. Has anyone tackled similar problem ?
you need a delay
or do it in Possessed
cause the character will run begin play BEFORE the controller possesses it
Is there no documentation on the RVO Avoidance? I want to understand it better to I can find the best values for my AI. Like what are the best values for the Avoidance Consideration Radius and Avoidance Weight
the best documentation is the source files
thats how i learnt all about crowd avoidance
True, I'll have rummage
I have my ai check is playerisenemy is set and it works fine but once its set it never becomes unset how might I go about unsetting it
how're you setting PlayerisEnemy?
Im using quite a bit of logic in the controller and if all that logic goes through then at the end I call a function which sets the blackboard key
it sets it fine but it just never loses sight of player no matter how far I go away from the ai everytime the ai runs the BT again playerisenemy is always set ๐ฆ
you generally don't want to set stuff that needs to update on the blackboard from the player controller, instead you should make a Behavior Tree Service that every so often (default is every 0.5 seconds), does a check and updates PlayerisEnemy
then you put the service on a node higher on the tree than the one you showed, and then it will automatically update and select the correct branch as needed
if you're doing a MoveTo task like that, you may want to also change CanSeePlayer to do a flow abort "self" which means if it's in the middle of the Move To task and then suddenly PlayerisEnemy is no longer set, it'll stop the Move To task
Is it possible to implement AI with something simpler than CharacterMovementComponent for performance but still be able to use some kind of avoidance algorithm like RVO Avoidance?
How do i activate an NPC, when another NPC dies?
@night robin Possibly a simple move to or move actor to, combined with an EQS? @lyric flint sure, have a variable that tracks if an npc is dead or not. on your next npc have it check on tick or by timer, or have the dead npc call a function that activates an npc or something like that?
Even Move To would require a character movement component I would assume, no?
To define the movement configuration of the character
@jaunty peak i have tried to call a fuction, when the npc dies, thats connected to "run behaviour tree" on the Aicontroller of the other NPC, but it doesnt work. And i've also made a fuction, but probably isnt right.
@night robin , fairly sure a 'move actor to' is a regular node in that you can use it outwith of BTs et cetera. It also ignores nav mesh if I recall properly.
I do need the nav mesh. and @lyric flint You can just hook the comparator to the return value
@lyric flint What exactly is the relationship between the 2 NPCs? If they specifically know of each other, you can keep references in the actors themselves or in another Manager actor and deal with the deaths and activations in the actor or manager. Or, if you want a general approach, you can use event delegates
im making a boss, each has 5 parts. and when 1 part dies it activates the other. i made them characters.
but im casting to the behaviour tree wich is in the npc brain, is there a bettter way to do it? @jaunty peak
Is there a way to get the first reachable point from an origin that isn't random but starts from origin and works its way out? Or is that what GetRandomReachablePoint does?
Hey all, cant seem to figure it out. Any way to stop a specific behavior tree on the AI and not the current way im doing it ๐ Seems like it would give me problems down the road.
I have a pawn, that is standing in a ring (the ring is static) and after 5 seconds the ring is invisible. Then the pawn should walk with the AI move to node to a location. My problem is, that when the ring is invisible and the pawn move, he stop were the ring was and the AI move to nede print "Aborted"
How do i check that a npc died, so that another npc can start attacking?
I already tried with custom events and with lower or equal float to the health of the npc that has to die
is there other ways to do it?
What's the best way to handle movement with ai? I am trying to make a large scale game with hundreds of ai. If I try and go over 25 the game lags due to them all moving at once.
depends on a lot of things
custom movement component helps, CMC is a hog
if your camera is any variation of top-down you don't really have much of a drawback if you use NavMeshWalking
we can have 150, maybe 200 running around with the game still running smooth
@patent hornet I've been scrolling through the forums, I found a post saying that you shouldn't use character movement component for ai. And that you should switch to pawn movement component. I couldn't find "pawn movement component" anywhere, so I tried "floating pawn movement component"
It helped performance, but not that much at all
I only had 40 ai on screen and the fps dropped to 30
But it only dropped to 30 as soon as they started moving.
you might be doing something crazy in the AI logic
As soon as the pawns start moving my frames drop drastically
pathfinding and movement don't cost that much
or something crazy in animation... blueprints? it has happened before
I have it go for an overlap check, but that's about it.
Retesting this with a move to random location, they only move 1 at a time now. What's up with that?
i couldn't tell you, im not a psychic ๐
why are there 6000 on begin component overlaps?
for 40 enemies that seems like a lot
you can do stat charmovement or whatever to see specifically what's taking so long in that
Now I'm having even more problems.
The projectile bps cause extreme lag
I seriously need help
Optimizing my project
It tells you there that your overlap check is ridiculously expensive
Over 90% of your time there is spent updating overlaps
What on earth is your overlap doing?
@magic jasper I have flags that overlap the ai so that they capture it, and then I have the bullets that overlap the player with sphere collision which makes bullet cracks.
I didnt know ue4 has so many limits
Overlaps are really, really slow.
@magic jasper what should I use instead of overlaps?
I don't know, really depends what you're doing with the overlap event
Can't tell you if the amount of overlaps is the issue or what you're doing with the event
are there any good alternatives to nav meshes? it seems theyre only good for small maps and dynamic option seems to mess it up completely
navigation invokers
oo what are those?
not for large worlds
oh cool thanks
they are cheaper then covering the entire thing in a navmesh
yeah that would make sense actually
but they do have their drawbacks, which you'll find out about after some googling
oh ok
they are well suited for single player open worlds scenario
where you don't really care if the NPCs move when the player is not around to see them
ok what causes ai to run around like crazy on the spot
the enemy is supposed to run directly at the player but with this invoker thing it just runs in circles essentially
yet another enemy that walks in random directions works fine
Is it possible to create a global blackboard that all AI actors have access to?
yes
you define it as the parent blackboard
then you create child blackboards from that
and give your specific ai the child blackboard and they inherit the parent blackboard
@pine steeple thanks, then my follow up question would be if you could assign the parent blackboard to a game mode? I saw the blackboard component but I couldn't figure out how to assign a specific blackboard to it.
For some reason the MoveTo tasks crashes my engine
and any other function to make an AI moves does completely nothing
do you have a nav mesh?
HI!
Question about Decorators: does anyone know if there's any difference in performance when using NotifyObserver : OnValueChange vs On Result Change in decorators?
no they are just different things
Value Change means when that value changes to anything
Result change means only when the condition changes
is anyone using this ue4 HTN planner? https://github.com/DennisSoemers/HTN_Plan_Reuse
I believe it's based on SHOP / JSHOP2
isn't it still experimental
and it probably works w/ actors and such
which I don't really have...
Hey, anyone online here on this channel?
Anyone that as a idea why Event Recieve TIck AI would stop ticking after about a minute or so, completely stop firing
Tyring to use Smart Links so my AI can jump up to locations. I can't seem to get the Event Receive Smart Link Reached firing
Any advice?
I've followed what people have said online and a video tutorial but it does not seem to be working as intended.
Got it working but it doesn't seem to be too good
Like if I wanted an enemy to platform a little, it def doesn't seem ideal.
@lyric flint
MoveTo Tasks seems to be bugged in 4.22.3
all of my moveTo related BB's are busted and i get editor crashes
So you arent the only one, ive been trying to write up a bug report for the entire day
@vagrant summit I managed to fix it for myself
I was using crowdcontrol ai controllers, but they ended up being replaced with normal ones again
so i reparented my classes
this corrupted them, I'm guessing, causing the crashes
a new controller fixed this
huh good to know
@pine steeple nice. I knew the functionality differences but I was afraid about the possibility of Value Change would mean that the code checks every frame for it while Result Change would be a callback or something like that.
Will double check the code though.
Thanks!
Hi!
I'm trying to use the Visual Logger to draw stuff on the level, but it doesn't draw anything.
I can record the session, I can log text without problems but the drawing stuff doesn't work at all.
Any clues?
Snippet from within my AI controller
#if ENABLE_VISUAL_LOG
UE_VLOG_LOCATION(this, AILog, Verbose, investigationPoint, 100.f, FColor::Red, TEXT("Investigation Point"));
float boxHalfSide = 50.f;
UE_VLOG_BOX(this, AILog, Verbose
, FBox(investigationPoint - boxHalfSide, investigationPoint + boxHalfSide)
, FColor::Red, TEXT("Investigation Point"));
#endif
Neither of them show up in the editor.
is AILog a VLOG category?
oh nvm they use the same categories
only thing i can think of is those points are local not work ๐คท
Not sure I understand what you mean by the points being local
investigationPoint is that local or world space?
ah right... It's world space
anyone here that uses Perception heavily? How much performance friendly is it? I'm questioning myself if it's better to write an EQS to grab friendlies around me or use the perception system, but I can't decide without knowing numbers.
we have around 100 monsters on map all running perception and if setup properly its about .8ms total for 100 ai
which is cheaper than the eqs only system we tried which was running around 1.4ms
oh nice. The thing with EQS is that it runs in a separate thread, so if it takes longer it doesn't matter, the game thread is not affected at all. I can see the Perception system code uses the term "query" but I have no clue if it runs in the game thread or in a separate one. Hence my concern
also, what do you mean by "setup properly"?
Hey guys, currently designing an utility driven AI system and I am a bit unsure how to represent my decisions. I decided to go for a fixed time cycle where my AI evaluates different world states to make a weighted decision. I have abortable and non abortable behaviors. I want it to be completely dynamic, any behavior can be followed by any behavior. Now I am searching for some kind of visual representation.
So I guess I will end up with some kind of fancy state machine. I like how animator states are representated and I also like how behavior trees in general are representated - but my question is, can I reuse these systems for my custom one, without rewriting half of the engine while doing a handstand and serving ice cream at the same time??
you might find just introducing a utility selector node to BTs will get you most of the way to what you've described, without too much pain. There's a BT utility plugin knocking on github you could look at
mhhh, yeah that could actually really just do the trick ๐ฎ
and would be a quite simple solution
Hello everyone, i got a problem with checking the bool in BH.
What is wrong with this ?
I have experienced problems when having selectors with just one child.
Other than that, unless you give us more info, I can't know
ok, I'm going to use an example a teacher once used with me
"European Spacial Station to Control, we need help"
"Control to ESS, what's the problem?"
"I don't know, help!"
They will die in space
That said, what do you see? do you pass the conditions? does that code execute? what are you trying to achieve? why do you have a Selector with just one child? an Sequence with just one child? You could remove them and have the wait node only. Where's that blueprint snippet from? The AI Controller?
Also, as an advice: don't use symbols in your variable names and try to stick to english. Life as a learning developer will be much easier
TLDR: How to change / resize Nav Agent Detection Shape?
Hi there, I am new to AI, just learned the basics but I'm still trying to figure out how to make my AI enemy not clip into walls.
So from what I understood it uses the capsule of the character somehow, but when I untick the option "Update Nav Agent with Owners Collision" on the character movement component, it does not seem to change the behaviour in any way. Also increasing or decreasing the Nav Agent Radius does not seem to have any effect.
The same goes for the Radius in the Project Settings, changing Cell Size does have a visual effect but it also did not seem to change behaviour.
When you tick "Can Ever Affect Navigation" on a component, does it mean the nav agent takes it into account? Because it also seems to do nothing.
I want to make NPC stay in place after bool called WaitInPlace.
But idk why its not connecting with bool.
Bool in NPC works fine bcoz its print true but in BH is not working and i dont know where is mistake i do it with documentation and looking for simmilar problem in ue4forum
@slow bobcat
which one of those decorators is not working? is the variable they check properly set in the details panel?
@odd hazel Maybe you want it to wait longer? The Wait is just set to 2 seconds
AI works fine but this Wait on the left want start while bool is True
is your decorator tracking the right variable?
The other thing: you don't need a selector just for your wait node. You can make that wait node a child of the first selector and place the decorator in the task itself
what I see there (photo is cropped), is that
- Wait in place is false, so it skips the 1st selector (again, you don't need that selector, that decorator can be in the wait node and the node can be a child of your 1st node
- Target Animal is true, so execute the branch
- Execute this Sequence:
- wait (done)
- something not visible in the picture (done)
- moveTo (done)
- something not visible in the picture. That's were you're trapped.
What's happening then? We can't see the current logic running
My problem is that this WaitInPlace should start when bool "MamSpraweDoGracza?" is true, but it dosnt. I see the bool sets to true but in BH nothings changing. My question is what i need to do, to make this Wait action on the left when "MamSpraweDoGracza?" is true
Ok, what I'm trying to make you see is this: see that white line in the last picture you sent? if that line is executing a never ending task (like a moveTo that never reaches the destination), your condition will never execute. BT's do not evaluate all the branches every frame. If something needs time to finish (async, like the movement tasks) it will wait there until it finishes.
Again, show us the entire picture, otherwise infinite possibilities could happen
You might be setting your bool to true, and then your decorator might be checking On Result Change instead of On Value Changed, thought there you are, doing something that is not finishing and your condition not changing due the lack of evaluation
it is on result change, and i set on true by basic now. same thing
My AI is working fine. But this WaitInPlace is for NPC to stops when i tell them to
So they walking around and its fine, but i want to stop them so i made this, but is not working
Yeah, I get that.
On Result will only work if the decorator evaluates again and, by the looks of that picture, that's not happening.
For the last time: if you don't show us the rest of the tree while it's stuck (or I think it's stuck by the looks of your last picture) there's no way we can help
but everything works fine!
Only this first one dont want to start. Maybe is not working like that
i will ask you another question
my AI looks like that
My theory from your previous picture
i made bool when i click on NPC to stop and talk with.
and this bool is in 1st postion
should it be jump into it when bool is true?
No if you keep checking for Result Change.
Result Change only "triggers" when the decorator evaluates.
If you change that by "On Value Change" it might work
Also, to MoveTo Nodes... why?
My bet? Your NPC is running an endless MoveTo (the second one)
yeah, like that.
same
where's your tree stuck? what is it executing?
its never stack
they looping nicly
then doing stuff and playing animations
they just walking around
but i want them to stop when i tell them to and wait 2 sec
Is this running entirely? From the wait I marked on the left to the wait I marked on the right?
yep
set a breakpoint in the last wait node. Then check in the bottom right corner Blackboard debugger (or at least it's there by default) the value of your bool, the one that fails.
Using the Visual Logger would help too, much easier to understand the whole picture
but it its on True bcoz im in dialog mode so its working
but it aint jumping to this thing on left
so, if you set a breakpoint in your selector in the left and you look here (this is my current BB), does it say your variable is true?
Those are my values at runtime while running my bt.
no is not wtf
Well, that's the 1st thing you need to check: what's the value of your keys
Happy bug hunting!
No clue man. That's a logic problem. My advice is that you set a breakpoint in that set value as bool and check when is that being called and who's calling that.
this is why i prefer using Blackboard Key selectors and handling stuff inside the BT that the AI would need
i never use that string based stuff
too many bugs can happen (wrong name, invalid blackboard, etc)
Edited: I moved into that but, sometimes, you need to setup stuff out of the BT (in my case, from the AI controller) and then, not much to do but using FName...
EQS need something similar so we don't need to use FName to pass parameters in c++
i have NEVER used anything but BB Key selectors
and i have around 20 monsters with a few of them being super complex
But how much logic do you have in c++? Because I think is a matter of approach. I tend to have a lot of stuff in c++ (within the AI Contoller) and, at some point, I have situations like this
Blackboard->SetValueAsVector(InvestigationPointBBKName, NewInvestigationPoint);
I guess I can use a selector instead
what's the c++ class for a bb key selector?
FBlackboardKeySelector
nice. I'm going to change couple things around to use that in c++. I only use 4 bb keys that I actually need to set from c++, so easy to change. I feel bit dummy for not realising about this before. Thanks for the tip!
yeah, I like that. F****** FNames
i mean it technically uses them, but its handled inside the key
meaning in the Behaviour tree i select what it wants to be
you can also filter using them
so if you have lots of keys, you can filter it to be only a vector key or w/e
like this
yeah, that's nice. I rarely need to filter, but that a nice add. Feels more reliable.
I will at some point... no doubt. This is going to be very useful
Does anyone know how to get AI to go between instances of meshes the navmeshbounds shows they should be able to go between the two meshes but the moment they get near the boundary they stop like they can't navigate the navmesh
How many branches can one behavior tree hold?
can i force BH to end one task and jump to another?
when i want to
When i set the RotateAndWait i want to pause everyother action and jump into RotateAndWait
have the walking around abort itself
when RotateAndWait is set
change abort self to abort both or abort lower priority
@lyric flint Technically I think it's infinite, in unreal I think it's capped to 1000? I might be misremembering though
My custom BTTask is driving me insane. What's wrong with my code?
MyBlackboard->SetValue<UBlackboardKeyType_Int>(MyKey.GetSelectedKeyID(), 999);
UE_LOG(LogTemp, Log, TEXT("Post-update blackboard value: %d"), MyBlackboard->GetValue<UBlackboardKeyType_Int>(MyKey.GetSelectedKeyID()));
It always logs 0. What do I have to do to set the value?
@kind wigeon i don't use the templated version like that
MyBlackboard->SetValueAsInt(MyKey.GetSelectedName, 999);
Awesome, thanks. All the example code I've found used that version, so I assumed that's what I was supposed to use.
stupid question time! im trying to set up 2 simple ai things, idle roaming / run away. im using the ai perception to change a bool value. if i do a blackboard condition check on that bool for "Is Set" and "Is Not Set" ... even if its false its still set right? because it isnt invalid
Hello! I set an enemy with an ai sight perception in the ai controller and when I use the debug the sight cone doesn't rotate with the player and just faces the same way all the time, if anyone could help I'd be grateful! Thanks!
I've sorted it now!
Is there any way to change the direction that AI Move To uses to move towards something. F.e. now it always uses positive X but I also would like it to use negative X in some cases
So all one had to do was uncheck "Use Controller Rotation Yaw" which made the thing rotate when moving
Ok to my problem resolve was that my bool have diffrent name as name and it wasnt working, now is working fine
Nice! maybe you should follow the advice of Kaos and use Balck Board Selectors. They avoid many problems.
Question about perception:
I want to override this
CanBeSeenFrom(const FVector& ObserverLocation, FVector& OutSeenLocation, int32& NumberOfLoSChecksPerformed, float& OutSightStrength, const AActor* IgnoreActor /*= NULL*/) const
so I can customize how the sight sense detects the target in question.
Am I supposed to do the line trace etc there? How is NumberOfLoSChecksPerformed used?
I can't find any documentation and the code is not commented
i'd do a cone check before throwing traces around, unless its already done under the hood
its much much cheaper
Questions:
- When you say you do a Cone Check, do you mean within that function when you override it?
- Much cheaper: if I'm not mistaken, any geometry check (except for AABB, the capsule and Sphere ) is more expensive that a linetrace. Obviously if the line trace is super long and the filtering channels are crazy, it will be expensive. Do you have numbers or something I can read about this to confirm?
- Done under the hood: what do you mean? the line traces? I don't think I follow.
The thing with the perception system, at least with the AI sight is that it's super optimized because it slices the calculations in time windows, making it super efficient. It also does a pre-calculation before the line trace to see if you are in radius in the Pie (they call it pie because the angle of vision) using sqr distances and so on. That and the extra functionality (loose radius, time since last detected, Visual Logger...) is what convinces me about it.
About the cone: The problem with the cone check is that, the further you check, the wider the area at the end, potentially checking more objects. For short distances is nice but it's usually not very convenient for long distances.
you are not doing a collision check
you know your location and view direction
you know target location
and you know the cone angle you're interested in
comes to a single dot product and one cosine to calculate
bool USolsticeLocationLibrary::IsInCone(FVector ConeOrigin, FVector ConeDirection, float ConeHalfAngle, FVector Point, bool bIgnoreZ /*= false*/)
{
if (bIgnoreZ)
{
ConeOrigin.Z = 0.f;
ConeDirection.Z = 0.f;
Point.Z = 0.f;
}
float dot = FVector::DotProduct(ConeDirection, Point - ConeOrigin);
float cosineSquared = FMath::Pow(dot, 2) / (FVector::DistSquared(ConeOrigin, Point) * ConeDirection.SizeSquared());
float consineAngleSquared = FMath::Pow(FMath::Cos(ConeHalfAngle / 180.0f * UKismetMathLibrary::GetPI()), 2);
return dot > 0 && cosineSquared >= consineAngleSquared;
}
@slow bobcat
note that this function does only a cone check, distance check not included
aah right... I was mixing things. Ok Ok. I'm still interested in the usage ofnthe parameter I mentioned none the less
is there a way to rebuild navigation during the game? Looks like my invokers arent working in packaged builds. They only work play in editor
nvm I removed the navmesh stuff and readded and seems to work now o.0
I want to override this
CanBeSeenFrom(const FVector& ObserverLocation, FVector& OutSeenLocation,
int32& NumberOfLoSChecksPerformed, float& OutSightStrength, const AActor* IgnoreActor /*= NULL*/) const
so I can customize how the sight sense detects the target in question.
Am I supposed to do the line trace etc there? How is NumberOfLoSChecksPerformed used?
I can't find any documentation and the code is not commented
If anyone is curious, that value is actually an OUT parameter. I completely miss the & next to it... It's basically the number of line traces you do in your overridden function. Then that number is added to TracesCount. TracesCount is the variable they check to control how many traces you do per check. There's a limit to improve performance. If you do too many, they postpone the query for the next time you sort the sight perceived actors.
The code was very clear. Nothing like a good night of sleeping....
MakeBlackBoardKeySelector to retrieve stored keys in the blackboard, how do I know the key id etc of the key I want to get?
Blackboard key selectors are only really used inside BTServices, BTTasks and BTDecorators
outside of them, pretty much you have to use the FName way
but i never set blackboard stuff outside of a BTService, BTTask or BTDecorator
if i need stuff from the ai, i have a service which retrieves it
or i grab it when the task runs, etc
that way all blackboard/bt stuff is encapsulated
Are tasks supposed to be the logic of what AI can do?
@pine steeple I am making a custom move to task, and I want to access a blackboard key using its name in a blackboard key selector, I am having issues with setting the allowed types and finding the id
you dont need to use the is
create a variable
of type Blackboard key selector
and click the Eye icon next to it
then when you add that node to the BT
it will allow you to choose the key
you want to bind to it
ok , so I was overthinking it it seems, thanks for the answer gonna do that now!
np
Still getting used to BTs
๐
@azure cliff I use them to access preset functions to run from the controller and actor the ai controls, I'm not sure if it's the way to do it but it runs well and works well so far, so I've set up different attack priority functions which are accessed in the services, which sets keys and when certain keys are set it allows for certain attacks which are tasks, in each unique attack is it's own attacks and therefore I can build combos by just sequencing some tasks that run functions from the controlled pawn. So in my case it just fascilitates logic to the BT but don't actually contain logic in them
@azure cliff Tasks are what the AI should do
most of the time i defer these off
to the ai specificially
i tend to keep most of my complicated logic in c++ so i do have a few C++ tasks to keep things fast
all my main ticking services are c++ for speed increase
A service is like a task, but it runs while the branch below it is running
it can be used to update blackboard with values that might change
whilst tasks below it run
decorators are used to change the flow of tasks or prohibit entering a branch
Im facing issue whether i should put attackrate, cooldown of individual attack. Im not exactly sure where should i put it at as i have a combat component for both player and ai.
I see, i think service is what i needed as well.
take this for example
this is a BT im currently working on
services (the green ones)
will be running whilst all tasks below it are running
Decorators (the blue ones) will filter the branch i want to enter
and tasks are obvs the purple ones
I see, thats pretty useful
From the image, the logics are in services and tasks right?
so i use services mainly to check if things have changed with the AI
tasks run the logic
for that specific branch
decorators filter what task i should run
so in the above example
CheckForAttack
pulls info from the ai
if the ai wants to attack, it changes its state
which then forces it to go to the attacking behaviour tree
via a bt decorator observing for changes in the Current state
The states key exists in the blackboard or controller?
so my states are stored on both
well not the controller
but the ai has a component
which handles it
i have a service running in the main behaviour tree
which pulls the state
from the ai
and updates the blackboard keys
I see
Do you think i should create each combat system for player and ai?
Or is it better to use the same combat system?
are they the same ?
as in the same skeleton? same attacks?
etc
if so, then make it generic
i have AI controlled characters
which act just like real players (same guns, same skills)
these are seperate from the monsters
and we share the logic (just have to handle the input as obvs ai cant send input commands)
The difference were player has no attack rate as it calls attack with inputs.
yeah you would need to handle the activation of attacks
via some logic
like a cooldown
between each activation
Yup, but ai requires attack rate to know when it can attack.
Player and ai has cooldown for certain attacks
@pine steeple where do u put the logic for dealing damage?
inside the skill/weapon
Hmm, so each skill/weapon has cast trace logic in it?
yes i never handle such things inside a task
Are they individual blueprint or just datas?
i defer complex stuff out
we have Skill C++ class
which ai use
these hold all logic for said skill (ability)
weapons (guns) are handled via the weapon system
like this for example
this is a skill activation task
Where is SpitAcid being called? Will it bind the event multiple times?
its being called via a enum selector
switch*
based on what attack he wants to do
and no only once
a task will run till FinishExecute is called
or its aborted
so if you never call finish execute it will get stuck
I see, but where do u put your cooldowns? Are they inside DoActivate?
yes, all handled inside the ability class
which is a UObject
which we then create BP's from
which hold all the logic
for that attack
If its on cooldown, how do u change the attack as the finish execute set it successful.
it wont activate the skill
if its on cooldown
and monster will try another attack or just abort attacking
this is an example
but i handle it slighly different
but gives you an idea of how i do it
Hmm, can i assume before the tree gets to this task, it checks whether ai can attack?
yes that is how i do it
it checks range to player
does tons of checks
to ensure the attack is ok to activate
Ahh, the range checking is in a task as well?
Ahh i see
which is why they are quite powerful
cause i can have one task to check if an attack can happen
and can adjust it per node
to suit
so if its checking for player range
and i want to check the player is within X range
i can adjust that all from the behaviour tree
Oh so the range data are stored in task only?
this service for example
Not in ai controller blueprint?
this checks if the monster is within broad attack range of player
then decides if it wants to do a ranged attack or close attack
then i do additional checks
in a task
for a specific attack
its quite complicated
but it works
and its not complicated for me cause i wrote it ๐
All in tree? Not in three skills?
eh?
i have a task
which checks if the skill can be activated
the CanBeActivated does some logic
to check if the skill can be activated (ie, close enough to player, player is not dead or concealed) etc
if that returns success, we continue the sequence
and activate the skill
Ahh ic so another range checking in the skill
yes
the service is more like a "consider attack"
ie if a player is within range, he will try to attack, out of range, he doesnt even bother trying to attack (to save on performance)
I see, really appreciate the tips!
Thanks!
@pine steeple you mentioned that the so skills/attacks were uobject. Where did u construct them? In the ai combat component?
Ah saw it in the previous ss. Thanks!
is it better to have a god ai tree for ai behavior configured by player (player can tell this ai to say flee from enemies when low on hp, or fight to the death)?
how do you compartmentalize say "what to do when low on health", etc etc in a behavior tree?
basically what im asking is can you combine multiple smaller very specific behavior trees together to form a larger ai tree? or should behavior trees be all for one, god trees???
@pine steeple do you use runBehaviorTree in the tree itself or you have logic in controller to run appropriate tree?
the tree itself
you can run subtrees
so i have one master tree, which runs subtrees
any reason why if i go from root directly to each of the sequences individually it works, but if i have a selector, the branch on the left says the vector is invalid? (GotVector?)
why are you running the service twice?
@tulip shale As @pine steeple mentioned, you don't need to run the service twice, the service will be ticking as long as the chain below it is being executed, so the one under the wait is not needed
@lyric flint without that one under wait they move once and stop. either way the problem i was talking about is the selector. if i go from root to the left sequence they keep moving around randomly. if i go from root to the right sequence, they sit still and then chase the player (placeholder for now). if i plug into the selector, the left branch says the vector is invalid. the right branch does work though if the player is seen
read up
Blackboard key selector
basically i never ever modify blackboard keys from outside of a BTService/BTTask
if i need stuff from the ai, then i have a service which pulls the information
this way i never have to use that horrible crap and if i change a key name, i don't need to remember where i set that name for a bb
thanks, I realize it's horrible crap which is why I asked. I'll look into selectors.
@pine steeple bit of a delay here but.. in my screenshot, i was using the service on activation, not tick. i didnt think id need it to be spitting out a random vector if the thing only moves every 3-4 seconds. also, still unsure why it doesnt get a vector when i have the selector in there, but works fine if i plug right into that sequence. new to this so im still screwing eeeeverything up for sure
ok but why would it work when plugged directly in but not after selector?
i was just following a tutorial, some used a task some used a service, this one was service i was just going with it
yeah i wouldn't trust them tutorials
i have wrote around 60 behaviour trees
and have around 60 bt tasks/services/decorators ๐
i know behaviour trees quite well
well im just trying to make a critter that roams around and then runs away when it detects something. i have each side working but cant use selector properly
so
well... and instead of running away it runs AT the threat but thats just a placeholder
remove that service
already working on making it a task
if it is only getting a random vector on activation seems kinda pointless
so this sequence here
you want to move to the random vector
wait once there
and then move again
as long as no thread is detected/
threat
right. it seems to work by itself
i put it in the sequence thing because it needed it to start. im guessing as a task itd be... yep just like that
ok but my problem was still the selector, im definitely going to do it like that pic though
it says the vector is invalid when i have the selector, is there something about them thats kind of hidden or easy for an idiot to overlook?
i have fallen victim to a checkbox more than id like to admit
ya i saw ur comment earlier about it. uh, not sure about it yet (still using make literal string) but i dunno how that would be the selector problem
it allows you to select the blackboard item you want to update
better than using the awful Name way
less prone to errors
oh i only use the literal name thing in the controller for the threat part of it... my vector task is just
also i highly suggest you dont update Blackboard from outside of tasks/services
have a ticakble service running
that polls the values
and pulls them from the controller/ai pawn
this way everything is consolidated inside your behaviour tree
thats how i keep external values synched for my ai
(btw i write these services in c++ for performance) but its def better than having blackboard stuff littered everywhere, especially when trying to bug find
hmm so... this may be what you were saying a moment ago, but they only check if a threat is detected after they wait, about to randomly move again. is that tickable service thing you were saying?
if they run from left to right, how can i have something interrupt it to change the branch?
decorators
you can have them abort self, lower or both
if the value they are monitoring changes
Ya i have not figured that out yet. Is that what ppl call an observer?
yes
ah i found a wtf is video about it, i think it works. i set the "wait" to 30 seconds and it definitely changed branches while still in wait, so thats good
so this looks cleaner than my original garbage?
i still have some stuff in my ai controller switching values, like when it senses the player. not sure how/if that can be put into the behavior tree itself
yeah
my sense from player controller
ai controller*
sets a value on the ai controller
i have a service ticking on the selector after the root node
which pulls the values from the ai controller
@pine steeple I am working on a three stage boss, I have initially set teh different stages as different trees and use the ai-controller t switch, I haven't done multi stage bosses before so it's a first and I'm not sure if the appraoch I'm doing, be switching to a completely differetn tree is any different sfrom setting subtrees in a master tree
ai controller doesnt need to switch trees
Yeah but the stages are complex and I get confused having them all in the same main BT and I was worried it would be less performant f I used one master tree
dont need to do that either
you can use subtrees
just run them from within the main BT
so your main boss bt
would have 3 states
Stage 1, Stage 2 and Stage3
each stage is a subtree
you can do it from with BT
look at the Run Behaviour task
Ok that is very true, that would possibly solve aother issue I had running a decorator on the root, I got a warning whe I tried to do that that said if it's not a subtree I can't place a decorator on teh root
in behaviour tree
@pine steeple so, you have your ai controller set a value like for itself, then the BT checks that value? so you arent setting a blackboard value through the ai controller. is that right?
yep
does it involve a lot of casting or an interface or something? thats one of the things im struggling with. communication between things
Well BT task and services will communicate with either your ai or ai-controller and teh BlackBoard, but you won't need to cast alot and no interfacing needed. Maybe at the most you do one cast from either the Controlled Pawn to your actor and one cast from Owner Controller to your specific specific ai-controller , depending on what functionality you need, sometime you need custom functions within those classes to run and therefor you do a cast
@tulip shale
hmm...
well its like i can get the base classes and all that, but nothing specific to that ai. my brain hurts with this ai thing, it seems much different than the other stuff i can barely figure out <_<
Let me show you one BP task I have, it isn't perfect as I jumbled it together quickly
better than what i hack together
its like i somewhat understand normal bp, but this ai thing is such a different way of doing things. i could probably get my simple critter ai working in just the blueprint, but thats not the right way of doing it and i really want to learn how this stuff works. startin simple
So here I first check if any actors of a certain class is percepted by the perception system, if yes then I cast to the boss class and from there I acess one function to sort which enemy to have the highest priority
sure looks complicated o.O
Well at first it is but when you get used to how to problem solve these kinds of problems then it becomes much easier , the sorting fucntions is pretty simple aswell, it check for how many times a player has shot the boss and healed themselves/other players then choose the highest basically, how I set this up is at ApplyDamage I check that the actor who applies dmage to the boss is of a certain class, then I add 1 to it's hitticker" and each time a player heals another player or itself it sets a "healticker" in the health component, which is acessed in that 'Healer Or Atacker' function
ah, ya i was gonna do the same for a threat system. not for the critter though, it only knows fear of all things
Basically, what I'm getting to it isn't much more different then regualr BPing, but it hase some differences like to actually pass these values to the BT you need Blackboard keys and set them and those keys are teh only values teh BT can access
Yeah that works aswell, some different priority systems in tandem with eachother makes the boss less predictable
i think something that screws me up here is... the values in the keys doesnt persist right? like they update every tick/execute
i was trying to make a simple check for a bool in the ai controller, because its easy to set there. couldnt figure it out
you can therefore hacing it update every 20 seconds instead of 20 ticks per second
This is basically the first step you need to do
from the controller? I took a random Bool that is in the controller class only and passed it, this is for demonstration not an actual bool I want to check, s oI jsut took any old random bool
oh i see, its like a default one
If you need a specific bool form a specific controller then you need to cast first from OwnerController to whatever your controller is named and from there get teh bool you need
ya, ive been told to avoid casting whenever possible, thats why i was trying to figure out if an interface could work, but im not having any luck there eh
Yes exaclty, it's a parent variable, so any ai controllers child classes work without issue, yes casting casues calls whe you don't always need it. but casting from related classes is the most correct way to use it, interfacing when the classes are not directly connected
so its not as costly to cast from a pawn to a child, but to cast from pawn to a tree would be worse?
this in the right direction?
yes
So lets say you have a health component that you attach to a class, then the best approach is interfacing casue they are not directly related and will be less effective using casts cause ti will need more preparations to work, and interfacing when not needed is not bad but becomes convoluted at time,s therefor I always suggest interfacing cross-class, casting in class hieararchy
Also, next step is to actually set teh BT to read/write that value to an actual Blackboard variable
like this;
this is my whole BT so far
the right branch is a bit broken but the actual check works. its the movement that is broken (havent worked on the task for it yet)
a lil tricky trying to get a vector away from something
Is it a custom move to node in the right side?
no just the MoveDirectlyToward, i tried that instead
if i wanted it to move TO the threat, i could tell it to move to the actor and it continuously follows it. moving away though, i need to keep calculating a new vector. not quite sure how to keep getting a new vector and having it move to it though
This is a part of my custom move to task, it is the only parts that moves the character, the parts I dindt inlcude are basically funciton calls for the Ai to attack while running towars the player.
Only thing except this is to add a 'finish execute' node at either completion of failure to move
my goal is to move -away- from them, so i think it has to be a vector not an actor
hmm, ok maybe same thing as i posted, but with a vector, and make a service to keep the vector updated
Check the box, Continous Goal Tracking and it should keep the location updated when then service updates it
ya this is gonna take me a while to figure out
I have a question. If I add ai perception on a custom model, will it guess where its eyes are?
no