#gameplay-ai
1 messages ยท Page 55 of 1
I'm updating some of my path check code to make sure it uses hierarchial checks since it's faster... but is there ever any reason to not use hierarchial mode? ๐ค
(Just for TestPathSync ie. checking if a path exists at all, not for actually getting a path)
Oh wait I just noticed it says "hierarchial mode ignores query filter"... guess that's what it is then...
And also that means I can't use it lol
Is there a good way to see what a pawn with the character movement component is TRYING to do?
It's supposed to stop before it reaches something and, well, it isn't
So I gotta figure out if it's got a logic bug or it's just shitty at stopping even though it's trying
It depends on what are you using to make your Pawn moving
how can i combine multiple arrays
or make it so anything spawned by an actor is a child actor
Append (they need to contain the same type)
SpawnActor -> Result -> AttachActor to Actor (result in target pin, self in Parent pin)
I just ended up grabbing 3 seperate "get all actors of class" and linking them to destroys
For simplicity
Sounds terrible ๐
apparently all of undertales dialog is one giant switch case statement
Iโve heard of this yeah.
Ofc, none of this is related to #gameplay-ai ๐
I know, I was just wondering why that comes up as justification in response to "Sounds terrible"
some of the best games out there are actually made terribly
guys I want to make a AI,he will always follow us. but when we look at it he'll stop,I couldnt find a good tutorial for that. can anyone help me? probably I'll set "ai move to" to our fps character but
Depends how complex you want it. At its simplest you can use regular MoveTo, a line trace, cast and stop movement. Otherwise, see the video pinned here on Behaviour Trees
idk if it's a ad or not,but if you know lethal company Coil-Head I want to make something like that
I donโt know it but what I said still applies.
but how? with PAWN sensing?
AI perception
what should I add?
You should watch that video I mentioned, it covers pretty much your exact use case
Youโll just need to modify the behaviour slightly
okey but which one?
In the video, it is said that I need to add blackboard. but there is no need. Because artificial intelligence will have 2 behaviors, chasing and stopping
what can I add instead of this?
Well if you use behaviour trees you need a blackboard. But you can also prly get this done with just AI perception
Im watching AI perception part...
ooh nvm,you mean no need to add these
but even in there it's shows blackboard
If your behaviour is that simple, you could just do a dot product between the player (character being chased) forward vector and the directional vector between the characters (ai location - player location). If the result is > for example .7, the player is "looking". You can adjust this value until you're happy with the results.
However, games are very rarely that simply so understanding and implementing BTs and AI perception early is a good idea
I made that, but how do I make pawn sensing infinite? he can't see me when I'm behind the wall...
You'd use a collision channel that the wall doesn't block. I think default is visibility which is generally everything in the world with visibility set to true.
It sounds like you should do a rudimentary AI course before jumping in. There are some basics you need to know before trying to make a functional game.
how can I turn that off
ok I made it
Hey guys, have an issue with my AI, where the enemy after losing sight of my should go into seeking state, but instead its going to attacking state and following. You can see in the bottom right that the state is indeed Seeking, but in the behaviour tree its running Attacking State
Inb4 another scolding about modeling state machines with behavior trees :ยฐ)
lol is this bad?
It makes it extremely hard to do what you're trying to do
But I think what you might want to do is look into interrupting that "Move ToTarget" node. That's what's keeping you stuck in that branch.
@floral compass thank you! I will look at that move to target node
though state aborts though when interrupted
I want to put a chat gpt learning program inside my game is this possy
Like can my character use chatgpt to learn and use things like scenexplain
I would think it would just need a plugin ?
Thatโs a #generative-ai question
Different people different opinions. If the game is quite small and you are not planning or you are 100% sure this is not gonna evolve into 159 subtrees, then I would say if it works, it works. The problem most people are talking about is when you are working in team or on a bigger project, you start doing something like that, and then someone comes, tells you to change the system, and you are like, uhmm i have to write it all from the 0 if you want these changes. So it's really honestly up to you. Still good to know the good methods to approach.
What's the most efficient way in to find the closest k actors of a certain class (or tag, whatever can be done most efficiently) from a certain point? I have to run a kNN algorithm for my AI, but I'd rather it didn't run in N^2 time
I'm new to UE5, but not to programming
probably use Sight Ai sense to detect actors and then in code make it to only sense specific class
That sounds like it comes with a lot of overhead and probably updates it every time any AI goes in or out of sense range of another AI, though
I only need the 4-5 closest ones
Hey guys. I'm super stuck on this very final bug in my game. I'm having issues with the enemy AI stopping himself from chasing the player after only a few seconds. I'm not sure where in the code this bug is happening but I put a print statement on the OnSeePlayer sensing event and it shows when the enemy loses sight of the player. I'm also having a huge issue with the enemy not roaming anymore. My AI Move to node that's connected to a GetRandomReachablePointinRadius keeps failing
but what is the context?
I should emphasize that I'm dealing with a very large number of actors.
Think simple flocking/swarming behavior
You have to change it so it will only LookForward when it has Target not set (make it as key), and, on the second branch, you dont have to put blackboard because if there are only 2, and first one will be true (has target, so it's not lookingforward), it will always choose 2nd selector.
Any videos or more details? I can't picture it
We know a lot of factual information about the starlingโits size and voice, where it lives, how it breeds and migratesโbut what remains a mystery is how it flies in murmurations, or flocks, without colliding. This short film by Jan van IJken was shot in the Netherlands, and it captures the birds gathering at dusk, just about to start their "perf...
so you are trying to make formations basically?
No, I'm implementing an agent-based flocking behavior where each bird reacts to the movement of its k nearest neighbors
so for k=4, for instance, the bird needs to check what it's 4 nearest neighbors are doing
so you need to study EQS
The hard part is efficiently determining which birds are closest for 1000 or 10,000 birds
I don't need EQS though. This should be some very simple calls. I don't need to worry about obstructions, I don't need to do anything special when a new object comes within range, etc.
I really just need to quickly find the 4 closest actors of a certain class
make collision spheres for each of bird with radius that you need for them to gather all actors from class in their collision range?
That was my instinct, but I suspect it's rather expensive for the engine to track all of those collision spheres, and I wasn't sure if it's querying them at times other than when I use them.
i think it will be expensive no matter what since its a lot of numbers
Yes, so the idea is to minimize that expense
Thanks!
Sounds like you need some custom octree search algorithm, otherwise yeah mass or EQS
But kind of smells like premature optimization. Mass can probably handle that, maybe.
Did you fix it?
@uncut rune I'm sorry I'm slightly confused. I also I was trying to build out a test version of my game and it keeps failing for some reason.
But you're saying I shouldn't use the blackboard/behavior tree? I also have code in each branch
run game and look what the behavior tree is doing and if its getting stuck somewhere
Yeah, Mass seems like it might be the way to go. Can you point me at docs for using octree search in Unreal Engine 5? I'm a little new to UE, but a veteran programmer.
He seems to be stuck at the chase player branch but it's telling me that he cant find the player
I'm sure there's some octree implementation deep within the engine. But not sure whether that's exposed at all. Otherwise it would have to be custom built.
Also there is a "CrowdAvoidance" thing in mass I believe? Might be worth a look, too
Read what I said in the first response. You don't need 2 decorators here. You need only one to check if it as target, if has no traget, it will lookaround, if has target will follow the target, if he has target, he wont look for target. You need only 1 decorator on 1 node and set them to self abort on key/value change.
I have a custom algorithm determining the movement behavior of each actor based on the behavior of others. I just need to locate the k nearest neighbors.
Here's the paper I'm working off of, if you're interested.
I get what you're saying but I just dont know how to do that exactly. I followed a guide to get the AI to this point and I get what you mean about it only needing one decorator but I'm unsure how to set that up in this tree properly
I got that. I meant the CrowdAvoidance thing might use something to detect neighbors. Sounds like it to me at least, just a shot in the dark
Ohhh, you're saying open the source and see what CrowdAvoidance is doing?
Yup!
Ugh, was hoping this would be much more painless
I'll make a note to take a look
Thanks!
You need only 1 decortaor that will check if the blackboard key AttackTarget (for example), has value or is set. If the blackboar AttackTarget is set, then it will do the FollowPlayer branch. If it has not, if will look for target. So you only need to set decorator blackboard on one branch. Are you using AI senses or how do you set the target for the ai?
or I see that you have boolean there? how do you set it?
so just change HasSeenPlayer bolean, to the AttackTarget (actor type), and set the AttackTarget to be the actor (Player in that case), that it sensed.
and when it senses player, you set blackboard key to be the actor (player), and then it organically happens that if it has target, it will attack it, and when it loses target or has not (yet), it will do the look around*
How big is the N? Most of the time that kind of thing isn't actually going to cause performance problems.
Ideally, about 10,000
But this is also something I'd like to call as often as possible
So for any number, it's important to be efficient
You're doing BOIDS, right? I recommend actually using the built-in version and not have them be actors.
Not sure I can implement the rules I want in Niagara. Not using the BOIDS algorithm.
Is the Boids algorithm editable in Niagara? Can actors be stateful in it?
Er, can particles be stateful, rather
I'm not sure. It's heavily tunable though. 10k actors alone is going to be really heavy performance wise. You could optionally look at using Mass and using a spatial data structure to get the nearest. An Octree or a quadtree.
HLSL?
Ahh, I don't know how to write shaders.
there's not really a direct way to do it with niagara alone then, boids is state free though
Can you recommend a starter for HLSL assuming I know C-style coding?
Would it be clever to have different AIControllers for computer/enemy units and for the real player? What i'm thinking that I will have couple of things that are in common, but computer ai will have some things different and I guess it would be easier to implement that?
How would an AIController be used with a player?
For a base unit behavior so if the units are idle for example, they need to sometimes alone decide that they will attack if the enemy comes near them, so they don't get 1 shoted for free if the player is not looking. Basically something like auto-agro, that could also be switched on and off. Something like ''I'm ready to attack if enemy comes''. Does it make sense?
Oh, for an RTS or something right?
Off the top of my hat I would use AIControllers for everything. The player would just not have an avatar in the game (aside from their mouse maybe). Units controlled by the player would just have much, much simpler AI. Actually, it could be so simple you might not need any AI classes at all.
Yeah I'm still thinking how to implement that, the simpliest and most clean what I'm coming to is to have 2 different AiControllers, probably with some copy pasted behaviors for both. That is why I want to make the AI simplier for the player, and at the same time I'm not sure if it's better to put ''behavior'' like if target is set then do: attack and this I guess I should do on Event Tick or with While? loop? That would make it also 2 different approaches for ''the same'' thing for computer and for the player, if you understand me. (player would use blueprints, while computer behavioral trees for the same thing).
maybe I'm actually misthinking AIControllers with behavioral trees??
I can have the same AIController but different behavioral trees for player and different for computer? That would be the point?
Yeah I think this is what's happening. You can have all differences in the BT, provided your requirements fit the flow of BTs.
And depending on the required complexity of your AI too
Do I remember correctly do I set Behavioral tree in the blueprint of the actor?
so it uses that tree i specified?
On the AI Controller's BTComponent
Your actors should never interface with any AI code, ideally
hmm, so would I need to make switch in the AiController for different classes to use different trees?
this is the way?
Many ways to do that
Can start BTs arbitrarily at runtime too
It depends
I do GOAP-lite and run a BT based on the selected action
Hmm, I guess in my case as I have 6-8 different units, where there are 3-4 types that would behave different, i would just create 4 behavioral trees and set them with switch based on class (just thinking out loud). Do you have any better ideas?
I guess there is no easy anserw ๐
all depends as I'm thinking about it
I will just have to decide and go with something
there is even a way to probably make 1 behavioral tree, but to check if something is ''warrior or archer'' and then choose that behavioral tree path, right?
or it's not really the ''good'' aproach?
because that would work, are there any nos?
Nah don't clutter your tree with irrelevant stuff.
Keep it simple
so would I go with different decorators or different behavioral trees for different kind of units?
I think for RTS units you can probably get away with just BTs.
You can do it per unit, why not. Depends on the complexity.
I might be overthinking it with ''how different'' i wnat to make it for each unit, but I guess it's gonna almost all the same just different parameters which will be easy provided by each unit. And I would fit that in 1 behavioral tree.
So the only ''last'' thing that Im trying to make more clear is to separate computer units ai from player ''ai aka behavioral trees" would be to make 2 different behavioral trees and keep it simple.
Again, not even sure you'll need any AI for player units
Since the player's telling them what to do
It's just easier for my head to imagine the attack, follow in the behavioral tree than inthe blue prints?
yeah but they need to keep attacking while having target
do I make it on tick then?
since I would need to have while loop (while target is set do)
and I would set the target for each unit by clicking with right button on the neemy unit
so what I was thinking I would just make it set state Attacking in behavioral tree and let it run in loop
at the same time I had idea that I would set bool to ''InAttackMode", and if the 1 target dies, and the bool is still set to true, it would look for the target next to it ๐
and it seemed right to do it with behavioral trees
Putting states in BTs is a bad time
Check the pinned messages, you'll get a better idea of it
i watched them all 2 times ๐
Huh
You mentioned AttackState
yeah
You don't wanna do that
i could set it by right clicking on enemy, and setting off by clicking anything else, then everything else would run
how else would I do it?
or are you saying that i should not use behavioral tree for the mechanic im trying to implement and just to do it in while loop / on tick?
or maybe even by timer? and invalidate timer when clicking somewhere else
I'm saying you shouldn't try to model state machine behavior with a behavior tree
and state machine in my case is which part?
AttackState? like the behavior behind it that will do: AttackTarget, FollowTarget on the loop?
this whole thing should be done in blue print?
State machine is a tool
The behavior itself is fine for BTs I think
I just don't think you'll want to do the selection of which behavior to run in BTs
But again, depends!
Depends on what you call your other branches :^)
And how you do the selection
Because BTs are static priority
If you can't definitely say that there is a static priority to your behaviors then it can be tough to implement
if no target WaitForTargetToComeCloser xD, if target set (by player, or came into), GoAttack
so basically Idle and Attacking
Well that can work
But it's rarely that simple
and GoAttack would be something like: FollowTarget, AttackTarget(dealdmg), maybe 1 more branch with ThrowSpell (with cooldown), and that's it
and maybe some units would have something like counter that if AttackTarget finished succesfulyl 3 times, then the next attack will be ''pro'' ๐
which I think it's similiar to the example from Epic Games where each time it went patroling, the hunger was increased by 0.1 and when reached 1 it had to go anjd look for food
Try it and report back how it goes :p
and I can picture it beeing done with the behavioral trees, maybe Im wrong ๐
will report for sure ! ๐
Hi not sure what Im doing wrong here but my enemy is not moving at all.
I have assigned an AIController to this enemy and using a AIMoveTo node to move them but it always returns fail. Can anyone help please? ๐
Does the map have a Nav Bounds?
Yep
Can you show us?
Is that the blueprint you're using? It's using its own location as the destination.
Circled the enemy for ease ๐
Isnt it getting the player cahracters location on BeginPLay?
Ah, it's just a sphere? Does it have a Character Movement Component? Is it marked as Static?
See how the nav mesh makes a hole under the enemy? that means the enemy's sphere component is marked as Static indicating it will never move.
Ohh ok never realised that I,ll check the Static Mesh settings.
And does your character have a Movement Component to actually perform the move?
Yep so its set to Movable and has a Character Movement Component
can see why im a bit puzzled as to whats going on.
Looks to me like the sphere doesn't actually have a valid path to navigate
Uncheck "Can Ever Affect Navigation" on the actor to test
it is unchecked
Ok would this make it move to player character location ?
I have unchecked all the boxes there was 1 checked for Affect Navigation
so i,ll test again.
Nope no movement still
Let's see the navmesh?
Huh
Its showing the sphere is not "cutting" out the navmesh now.
Well we've ruled that out
Thanks for the help ๐
Is your player actually valid when you call that move to node?
I tried this to check
Do a print string if its not valid
Is the actor actually possessed by an AIController?
Its very weird.
XD
Do i have to post a location in the AIMoveTo node or can you just use an actor ?
I think it prefers the actor if you provide one
Now? Why not before? :S
this prints out the player character outliner name so it knows that.
Oh ok
So it has the player actor which i assume means it knows where the player character is.
What you could also try is to run that not on begin play but like 1 frame later
I think there's a delay by 1 frame node
Ok i,ll add a 2 second delay after Begin Play, (I thought about the Delay Until next Tick node)
ok with a delay node of 2s I get the print out of "Player is located" after 2 seconds but no movement.
lol thanks for the help nn sleep well ! ๐
If you want to properly troubleshoot AI, use the Visual Logger
Ok i found out what was causing my issue not sure why though when I disabled gravity on the Character Movement component (Because its a ball levitating in the air) it would not move anywhere but when I enabled Gravity it worked. I am not sure if the Character Movement Component MUST have GRavity Enabled for AIMoveTo to function or if because its a levitating ball it has no contact with the Navmesh as its effectively not on the ground (Bit like Dodgems they have to be touching the electrical roof to move)
I am not sure if this is right though as this would mean that to create a AI Move To flying enemy you would have to sit something on a box and set visibility of the box to hidden in game and then the box would do all the moving for the Enemy on top of it. Maybe someone can shed some light on this please. ๐
If it's using CMC you would probably need to set its movement mode to flying, if it's on walking it most likely requires ground
Also using a Character as a ball seems kinda strange, it seems just a regular pawn with floating pawn movement would work better for that
I thought about using a Actor for the floating enemy because it seemed to fit, but I was unable to use AIMoveTo node with Actor are you able to use that with Pawn class?
This was the issue I h ad to set the CMC to flying and it worked, For testing purposes I,ll try to use it in Pawn Class too.
Thanks!
I think AIMoveTo probably requires a pawn, since actors can't be possessed by ai controllers, but pawns can
I,ve not had much experience with these Simple Move To nodes they sound very easy to use but for some reason im managing to mess it up xD
Do i need to add a CMC to a Pawn to make it move through the AIMoveTo nodes?
CMC only works on Characters, try using floating pawn movement instead
wow i never even knew that component existed ๐ฎ
Ok added that and added 250 to Velocity on X Axis Checked Can Fly and no movement
Sorry Im being so dumb here Im sure it,s not normally this hard.
I wouldn't worry about it, these are sometimes kinda complex
Im almostr tempted to look on the marketplace for a asset to see if i can reverse engineer it and see how others have done it am struggling to find up to date info on it. ๐
Aha! a friend sent me this https://www.youtube.com/watch?v=j_Y-Tkb3YJM&ab_channel=UnrealEngineLearning
new game - https://3dnikgames.itch.io/peach-trees-dungeon-ride
๐ Subscribe! - youtube.com/@UC5QL6BvMx7zFJygxKhWYdnw
๐Cartoons and Animations - youtube.com/channel/UCTLLDESngpySeCbfBBOYXfg
Blender Tutorials - youtube.com/@UCGwsQNhk0B4-qZ-6_6XiswA
Unity Tutorials - youtube.com/channel/UCgfbQSUUOwhhf9Io8b4fUBg
Godot Tutorials - youtube.co...
I mean, something has to be messed up aside from the AI stuff
Have you tried using a behavior tree with the MoveTo task?
I have used the behaviour tree before with Perception Components and done a simple chase, patrol search and roam freely ai system before.
I thought if i wanted to create a game similar to Gauntlet all i need basically is a if player in range chase them
So i thought a Behaviour Tree might be overkill for something as simple as that.
So try a 1 node behavior tree with MoveTo and see if that works. At least that way we could rule out a few things
It might be, but at this point I would just troubleshoot the problem
Because I don't see why what you did wouldn't work
Did you see i found out why the CMC Component wasnt working.
No, I was sleeping ๐
Ok i found out what was causing my issue not sure why though when I disabled gravity on the Character Movement component (Because its a ball levitating in the air) it would not move anywhere but when I enabled Gravity it worked. I am not sure if the Character Movement Component MUST have GRavity Enabled for AIMoveTo to function or if because its a levitating ball it has no contact with the Navmesh as its effectively not on the ground (Bit like Dodgems they have to be touching the electrical roof to move)
I had to change the movement mode to Flying on the CMC for it to work
I avoid Character anything like the plague, another reason to keep doing so!
So with this in mind someone suggested maybe a Pawn with a Floating Movement Component might work better so now having issues with that
Just learning stuff and troubleshooting at least with all these issues its more likely to stick in my head for future projects lol
Yeah, try a BT with a MoveTo node. If it doesn't work at least we can rule out that it's not a problem with the AIMoveTo node
So am trying to copy the Character + CMC move to random location using a Pawn and AIMoveTo with a Floating Movement Component.
Ok have learned a few things. ๐ I understand better now whats happening.
can anyone suggest how to get past this initial module setup to try to get the state tree component classes usable in cpp?
does anyone how to know in c++ if a vector blackboard key is unset?i see that when unset it has a magical large value, but do i really have to compare with it to see if it's set?
You need "AIModule"
There should be "IsSet" functions on the blackboard
I mean you can also just do this with the Blackboard decorator
Thank you so much
do I just regenerate the visual studio files and reopen? Still not able to add state tree component classes
With Rider you don't really need to, but yes
Might be some Rider fuckery, try code completion instead maybe
idk, can't get it working off a cpp fps template
include both state tree plugins, first thing is go add the modules, close rebuild etc
yea UStateTreeComponent I think
Sorry about that, I got it confused with BehaviorTree
For the component you need GameplayStateTreeModule
What happens if you just include #include "Components/StateTreeComponent.h" ?
And then build?
its greyed out
Yeah now build
Okay, I think Rider was still generating VS files maybe?
Newer versions do that automatically
So I just need to hide includes somewhere in the project?
didn't think that I needed to do that after installing the module
idk tried it from scratch in 5.3 too, I'm doing something wrong. Started new cpp FPS template, added the two state tree plugins, then closed everything. Built CS project files, opened rider, added the 3 modules to the build.cs
unless I'm just failing to understand that yes it's necessary to still have the #include StateTreeComponent.h and StateTreeComponentSchema.h in addition to adding the modules.
Which version of Rider are you on?
2023.3.3
If I remove the includes I lose the functionality to add the classes, is that expected?
Am I supposed to just have the includes somewhere in the project or was that a workaround to testing?
No, that's bonkers, sounds like Rider fuckery to me
Same
Without having to put random includes in there
Make sure you've opened the project from the .uproject file and not the .sln
I think some of this stuff doesn't work so well if you use the .sln
Hmm yea opening it correctly from uproject using rider
If you've been using Rider for a while, I would try clearing the caches for it... sometimes they get kinda wonky for some reason and it causes random erratic issues
from File->Invalidate caches
Dang thanks but no improvement
Guys I made 2 supported agents, one is the walk and the other is fly, basically I just set a nav proxy to fly so that only who's fly can use that proxy to "jump" between 2 platforms but I dont know how to set my ai character to use that fly instead of walk
Alright, hopefully that can help someone else, although it is the very basics of AI and I likely do not have the proper names I am open to correction if I am wrong in something. Also leaving the Draw.io file if someone want it.
I watched the first 3 videos of this tutorial serie by Ali Elzoheiry and I realized that I did not really understand the order in which things happened. What objects where linked and how they interacts. So I made the following diagrams to try and figure it out after finishing the 3rd video.
https://www.youtube.com/watch?v=-t3PbGRazKg&list=PLNwKK6OwH7eW1n49TW6-FmiZhqRn97cRy
Please correct me if I misunderstood but it helped me understand the order in which things call each others better and I hope this can help others as well.
Are there any good resources on designing good, less formulaic AI? Less from a technical perspective and more from a design or abstract perspective.
Like for example, instead of stupidly going if attack then do X; if block then do Y; if heal then do Z maybe having a more abstract aggression concept that dictates the next actions? Or a mood or something. Anything in that direction?
If you've built something simple like..chess or something like that, and you want to build simple AI for it, is it useful at all to use the builtin UE AI tools? Behavior trees and such?
Would anyone know why AI would take strange almost winding paths when using the move to even if there's a clear straight path the take. The image is an example of the type of path it's taking.
Edit: It's because I had them set at dynamic obstacles.
Edit2 : Scratch that, it looks like it still does this just less often.
I would recommend doing the AI with Blueprints course instead of that tutorial. From the look of it, the tutorial gives really bad advice.
GDC
Blueprint course? What is it?
It's in the pinned messages
Hello, guys!
Please tell me why this decorator can give true if Iโm not in the navmesh at all? Chose to find a path from the AI โโto the player
And it triggers precisely when approaching a certain point (not zero coordinates)
HI all!
I was watching an AI GDC talk and it mentioned some cool functionality that they did with their behavior trees, basically one-off "impulses" that they could shove in and out of the behavior tree at will based on different things (most likely pawn/controller feedback). I was wondering if anyone had any idea on a method for accomplishing this. I'm thinking of it basically like an abort but an abortion to a temporary BTT that's not always there.
Dynamic behavior node? You can inject a subtree into a running tree
Never used it though
I have never heard about those. So cool. Thank you !
Yeah it's maybe the best feature of BehaviorTrees that StateTrees do not have (yet)
Aside from, you know, actually working
Maybe UE6!
I'm using the GenericTeamAgentInterface to distinguish between friendlies and hostiles - I wish to have my agents deal damage or heal allies based on situation, is the only way to keep checking GetTeamAttitudeTowards in my tasks for actors in range, or is there a better way to handle it? Maybe an equivalent to GetHostileActors?
this maybe? #gameplay-ai message
Hi, I have a question, so the Env query system thinks there is no path to the location, but this is only because my character that is using the query is 600 units tall and the query therefore uses the actor's location as the centre, I think. How can I get it to use -300 as the centre?
Hey Any idea why would BehaviorTree execution stuck in RotateToFaceBBEntry ?
Only thing I see is this line:
if (CalculateAngleDifferenceDot(PawnDirection, FocalPoint - AIController->GetPawn()->GetActorLocation()) >= PrecisionDot)
Play around with that Precision maybe?
He Doesn't rotate at all, what is this code anyway ? the precision that I can pass to the task ?
is it what's inside the FaceBB Task ?
If there is no rotation at all I'd check whether your target is actually valid
That's the success condition on tick
it is valid, I'm checking for the validity before moving.
of the task ?if so, how did you access the task code.
I opened the project in my IDE and searched for "RotateToFaceBBEntry"
Okay thx, I found it too.
I'm having an issue getting this loop to stop. My AI investigates but then never stops.
I've tried adding timers to time it out that also doesn't work.
Ideally the AI investigates for a bit then goes back to idle.
If its being called over and over that would reset the loop, and the timer. So then how is it being called? How do I make it not do that?
On first glance I think the branch is being reselected over and over after 3 loops.
When the 3rd loop finishes, what is the "ActionState" in the blackboard set to? It should be "Investigate" right? In that case that branch will once again be selected. Since you're never changing the "ActionState" within that branch.
True, the "TaskReturnToDefaultState" should change it, but it seems to never get there. I guess that makes sense tho if it doesn't get there it will re-call the whole thing into another 3 loop
I mean one "fix" is really simple:
Use a sequence node and move your "ReturnToDefaultState" into that. The sequence would execute the selector in your image, and afterwards return to default
so like this?
Thanks let me run this
That worked!
Well, you've just messed up the left part of your investigate branch tho
Because now your "Go to roughly where the sound was heard" will loop forever
What you want is:
Sequence
-> Selector
-> Go to roughly where the sound was heard
-> Test go to random
-> Sequence
-> Wait
-> Return to default
Because I assume you want to "return to default" regardless of which type of investigation behavior has been chosen
Thanks, yeah I'm trying a few things. The first branch has a BB Condition where "is actor set" so that seems to trigger well enough and not loop forever.
Thanks a lot for your help. This seems to be working as expected now. Really appreciate it!
Sure, no problem ๐
Anyone's got a good tutorial on how to handle non repeating movements for a few NPC?
I want a bunch of NPC to randomly select amongst points of interests on the map and chose a route between their starting point and their targets. Issue is that if I just tell them to go there, they will but they're gonne "optimize" the route and all go the exact same path.
Sounds pretty custom, not sure there's a tutorial for that. I'd look for a Patrol tutorial and add in random points in between. AI doesn't move very naturally, at least in my exp. Very much move to location, rotate, move to location w/o much blending between movements.
I do wonder what would be a good solution for this also. Pathing between A and B but allowing some inaccuracy in choosing the "best" path
The only way I can think of is having some system that tweaks navigation area costs between doing the navigation queries, or uses different navigation filters in the queries which have different costs... both those solutions would cause the pathing to be slightly different as a result
At the same time you would also have to take into account that it makes little sense for an NPC to run through a monster-infested forest just because we tell them to have "variety" in their navigation
I had a few ideas but I really don't know.
First one was to manually define a few stopping points at the entry of every passageway (since in my case it's travelling inside a mall), find whichever is the "perfect" point (closest to it) then randomly select a point from the nearby points. Then you would have plenty of inaccuracies. That would mean defining a bunch of preset corner points and figuring out how to do that.
Yeah I guess you could have some kind of "smart" navigation in a situation where it's like that
It does, if you are making a game with dangerous monsters :p
I'm making a game in a mall with mostly friendly NPCs. NPCs are having their leasurly saturday afternoon shopping.
Eg. you know you want to get to a location that's on the third floor from the first floor, so you would then let the NPC choose randomly from nearby modes of transport to the third floor, for example an elevator or different escalators
In this kind of setup you wouldn't choose destinations to path to, but rather, you would choose the destination, and you would define objects that allow the npc to get to that destination, so the npc would then decide whether it needs to traverse through an object to get there or not
This could in theory be achieved also through just using nav query filters, for example if you have a choice between elevator and escalator, you could randomly pick a query filter that allows using one but not the other
Like a chain of points of interest or smart objects
Have them stop at a map of the mall to check their path and so on
I had a slightly similar issue in my game where the npc's would always walk into the store and then into the nearest shelf in the same order... I just randomized the order to solve it lol
(it's a video rental store simulator of sorts)
"Nav query filters" let me add that to the list of tutorial to learn.
essentially a query filter is just something that you can use to choose which nav areas are valid for the pathfinding query
it has a few other more advanced features also
That actually look exactly what I need. Randomly affiliate them to different filter for each path of the map. I'm just worried if that is normal to have dozens of Navmesh or if I'm making a mistake in my understanding.
You can define them using different nav areas, I'm not sure whether there's any particular limitations to those other than not sure if there's an easy way to have nav areas overlap
If I want to have different behavior trees for different kind of units, but on one AIController I have to specify that logic in Event On Posses to switch BT based on class or any other specifier?
I'm not sure about OnPossess, but anytime during or after BeginPlay works
Or you could just create blueprint AIController subclasses and change the BT reference in each of them
Great, Ill go with subclasses. Didn't check if it's possible.
Are there any easy ways or delegates to detect when an AI is using a specific nav area?
Trigger volumes might work instead
Would prefer to do it without relying on overlap code. Physics area query stuff is insanely slow on some platforms.
I was looking into the EQS code and it's somewhat tied to behavior trees. If I'm not using them, is it that worse to just pop a trigger volume when I need to and go through the hits myself?
You can run an EQS query devoid of BT's
Hey all, I've since heard it isn't optimal to handle dialogue within a BT but I've implemented it now ๐
I've set a quest system up and basically once the quest is handed in the AI will move to a location I've specified
The problem I'm having is, the MoveTo doesn't work if its done after the EndDialogue task, but it does if i do it before the EndDialogue
I don't see any reason why a previous task should stop it from running?
I'm not at all experienced with BTs, but did you try to add a "wait" after the MoveTo?
Yeah that doesn't work either ๐ฆ
We donโt know what you have in that end dialogue task. For all we know you forgot to put a finish execute success node
I realised it's because it's calls a custom event which uses 'stop logic', sorry ๐
Can i run these two in parallel? At the moment EndDialogue executes after it's moved to the location
Need advice and feedback.
So I made this behavioral tree for my worker, and it works. I'm setting blackboard key WorkerState by clicking on Resource when unit is selected. When I click on the ground or anyewhere else, it's set to Idle. This is just prototype. I set this from PlayerController to AiController by interface.
I also have the same 'behavior' done in blueprints, and the behavior tree seems more clear to me what is happening. I can also add Tasks like Collect that will actually take out the resource from the node, and then deposit it to the building. Everything seems clear.
There is also function inside AiController, that looks for the closest building, but I think I might just put it into task at the end of the Collect sequence, so in case building got destroyed it will have task and a way to find it.
Are there any disadvantages in the future from this approach?
I guess it will be easy to make task to send info that something got collected so -1 from TargetResource and +1 to the amount in the playercontroller on contact with building?
you could try a Simple Parallel
Overlaps are slow? ๐ค Which platforms is that?
Switch ? ๐
Tbh probably never gonna release anything on console but I was always under the impression overlaps were reasonably performant lol
PS4 and XB1. Anything involving the physics system is a death sentence to your FPS.
Interesting
I'm using overlaps a lot for some stuff at the moment, mainly because it was less effort than setting up a system like djikstra/influence maps for it lol
but it's easy enough to replace if it was to ever become a problem
To be fair we were optimizing a game with a ton of stuff going on in a game. But the overlap and trace queries, and things like physx vehicle movement and whatnot are stupid.
@misty wharfJust double checked. PS4 has line trace singles running anywhere from 30 to 250 microseconds. Not even the component moving but just the simple function call to update overlaps on components hits for 18 to 130 microseconds. It adds up really quick in a more complex game.
Aside from misusing selectors as state machines. You'll run into issues if it gets more complex than that.
I also don't see why "Collect" and "Deposit" are separate sequences when they're clearly just one sequence. But I guess you could argue for readability?
Yeah so this is basically gonna be it for the worker. I might add something like so if it's set by player to ''search for xtyperesource'' it will go to the closest resource of that type and auto gather (sets target). It's gonna be pretty simple for the worker bt. I find it a little bit easier to program whole thing with behavior trees than with the blueprint. Are there any no no to this approach or is it ok in general?
I mean BTs (selectors) are good at selecting behavior based on priority and recovering from failure with fallback behaviors, right? That's their whole thing.
In your BT above you're effectively suppressing that functionality by introducing a very manual selection mechanism (states). So now instead of selecting by priority automatically, you have to tell your BT what to select. Your BT logic is "leaking" outside of the BT. Now your AIController needs to know that your BT expects a certain "state" and has to explicitly tell the BT what to do. If you switch BTs or change it you're forced to adjust your AIController logic as well.
Your example is great because it also shows how redundant a "state" sometimes is. You have a "TargetResource" in your blackboard. Why not make the decorator select based on that? If we have a "TargetResource" then execute the "Gathering" branch, else "Idle". You can ditch the entire state logic in your BT and AIController.
If you really want to work with states I'd recommend using StateTree instead.
Ideally, you'll always have a priority of behaviors in mind when designing your BT. If you want manual control over what is executed, injecting subtrees or starting a new BT would likely be less spaghetti down the line.
That totally makes sense, I will follow your advice. I will check StateTree too.
Yeah, so basically I'm not trying to make really AI, but I want to force some kind of behavior that I want in my game and it makes sense for me to make it with behavior tree (it's easier to picture it and program step by step). As I said I have exact the same ''behavior'' that is written in blueprint, and it's more complicated than it should be ๐
Yeah that's fine, I also think BTs can be really good for organization and modularity if done right.
But whenever you read the word "state" in a BT you should be very careful about what comes next.
It's like trying to go grocery shopping
But instead of the shopping cart you just take your entire car into the store
Works, but not what it's made for
ok ๐
And likely will result in jail time
hahahaha, please nooo !
Is it possible to replace the default pathfinding with some RRT based one?
- This condition is supposed to abort this tree when TargetActor is set.
- TargetActor is set. (See BB keys on right)
- The tree is not being aborted.
- What the heck.
The AI starts in this patrol mode and CAN initially acquire a target. However, when it loses that target, it then breaks so it can no longer acquire any target
Target Actor is set. why would it abort?
I mistyped in the comment but not the actual condition, it aborts when TargetActor is NOT set
In any case, I kinda sorta figured this out? But the results are bizarre.
So "FindTarget" is what sets the TargetActor, and I put a check in there for when it's being called and TargetActor is already set. And it turns out that happens All The Time.
My current theory is that AI detection sorta "flickers" as it is gained and lost. My check for that continuing evaluates false on the right tree that's not in the picture, but when it gets over to the left tree, targetactor is immediately replaced on first run, and somehow that doesn't count as Value Changed for the condition?
It's a theory with a lot of holes in it, admittedly, but the behavior I'm seeing is pretty tough to explain
are you using something like onTargetPerceptionUpdated by chance?
or how are you updating
...Shit, lemme open up unreal and check
This is the part which confirms I'm still detecting the actor, in the right tree
And this is the detection function. BUT HOL UP
"IsValidTarget", from that second function, actually wraps a call to CheckTargetPerception, the SAME function from the first one!
btw there's a built-in perceived actors generator on the EQS composite nodes.
That last part is particularly confusing, because what it means in practice is that "FindTarget" is necessarily more strict than "CheckTargetPerception", since it WRAPS the core part of CheckTargetPerception
if you end up having more than one target to perceive, or if you have issues with perception updating, that will save your skin^
Eh, I'm not using EQS for this project. First because I think it still needs C++, second because I've just got hella custom logic in my AI systems so I've leaned toward custom solutions for most things, and second because I"d already written a lot of this before it was released so it kinda "missed the boat" on this release train, to mix metaphors
it doesn't need cpp
not for something like that anyways
but fair enough, if your way works
hmm there was a reason. Does it tie in with the navigation system?
But yeah this version is working. Well, notwithstanding whatever the hell race condition I'm running into now
Anyways I'm technically on vacation lol so I'm gonna see if I have any bright ideas over the trip. I actually "fixed" it for now with a hack where "FindTarget" checks whether the target is set and if it is, it forcably clears it again, so that the next tick it can "update" the field in a way the tree actually notices
And it works! Though in theory it makes the AI 2-3 ticks less responsive than it should be.
enjoy your vacation
as long as it works with navmesh
yes
pathfinding is a func ptr that you can replace
that you need inheritance to do so... ๐
can someone tell me how to make ai hit targets with things like grenades or artillery?
i know that i can predict projectile trajectory, im wondering how to use it for correcting aim of npcs
im pretty new to ai programming
you can write either here or pm me, i would be grateful for any tips
This kind of depends on how you need it to work. There is a node that can suggest a launch velocity for arced projectiles or such which you could probably use, but this will not take into account the velocity of the actor which would require a bit more complex logic if you want it to predict the movement
Is it possible have multiple AI sight and define what the character will do depending on which sight is working?
If you mean multiple sight senses - yes, but you need multiple perception components, one per sight
This also means it will do twice the linetraces etc. so keep that in mind
Hey guys, how can I find a specific smart object to use? I've seen many tutorials, but they all use the "FindSmartObjects", and let a NPC interact with any smart object. However, I want to find a specific smart object to use, as my NPC has a reference to the actor that contains the SmartObjectComponent. However, I can't seem to find a way to get a slot handle with a specific object reference, neither identify a object from the "FindSmartObjects" result, as it does not return any actor reference.
Any way to handle detection of particular parts of teh body? I want to know if a character can see the hand of the player.
After checking it seems these kind of functions were not available to Blueprint. Is it still the case?
I guess you could do a line trace to the hand bone?
it was just some version control dumbfoolery most likely so removed my question ๐
does anyone know how to filter output in one generator by output of another one (using custom test class) in EQS?
I'm not sure if any of that is BP exposed, I recall you can do it via C++
With AI perception yes... in C++ you can override IAISightTargetInterface
Can someone tell me why when I spawn a AI Actor it doesnt move when the original Blueprint its based off works fine, I have Auto Possess set to when Spawned or Placed In World, The enemies are spawning in but they arent moving at all when the original ones do move.
The 2 circled in this image have moved to the player characters location upon start of the game
The others rotate to face the player character but dont move.
Hey! I've been having an issue with getting AI to move in standalone vs in editor. In editor, the ai moves in all rooms with a dynamically generated navmesh/room. In standalone, the ai only moves in the first room generated, but subsequent rooms cause the AIMoveTo node to cycle failures. I am spawning these enemies after the room has been generated. Any help would be very much appreciated!
This is the code spawning enemies
Visual Logger would probably have more info on why they aren't moving
if they are rotating but not moving that suggests the logic is at least running
Its odd that the Blueprint they are based off work fine but the dynamically spawned ones dont
I must be doing something wrong because the logger shows nothing.Have never used this debugging tool before tbh
You have to first press Start for it to start logging
Ahh thanks ๐
Not sure what im looking at though tbh so much info
can see all the AIControllers
any red bars would indicate errors of some variety
no red bars that i can see
in the Path Following it says Moving when its not so the game "thinks" its moving. (I guess)
Are the ones you've put into the level manually which work set to use flying also?
The ones i put in level are set to flying as well
If you're using BTs I'd check what's happening with those next
Im using the AiMoveTo node
Otherwise it seems it's trying to move but for some reason is unable to
Doesnt make any sense as to why manually placed BP,s work but spawned ones dont seem when the spawned ones are just duplicates of the manual one. XD
I would verify it's actually in the correct movement mode and not in walking mode
I have baked my world partition navmesh but it does not show up when I play my game, my npc does not move. What's happening here? I did get the actors to generate.
I even checked they are the same Z-Height as the manually placed ones.Capsule Collision is set to No Collision so that cant be stopping it from moving
How did you "possess" the manually placed ones? Did you assign a controller in their Blueprint or did you do it in the scene?
Also, does your AI Controller automatically start the behavior tree?
Unlikely these are the issues, but they're common gotchas
This is just the default, not the actual one it's currently in
Also check the return value from the moveto node, I recall it might give a status code or something
Is that not the issue?
AIController?
Should that not be some BP_MyAIController or something?
Isnt that just the Basic AI Controller class instead of a user created one.
Because by default AIController does not have any BehaviorTree assigned
the manual ones are using the same controller as that.
If your logic is all in the pawn then it doesn't really matter which ai controller
There is no behaviour tree for this
Oh, gotcha, blueprints
Yes
Ah sorry, got it now, missed it earlier
Really interesting
A thing of note is that the ai will start moving if I show or hide navigation via the console using "show Navigation"
Ok so it spawns an automatically resuilts in SUCCESS
The manual 2 do the same thing but then print out GOT YA when they reach the player
The spawned ones never print out GOT YA so they never reach the target
Haven't been following but make sure you ensure to change the possession behavior for the AIController to support this. In your pawn, search for spawn and change it to both
this?
By default, automatic AI possession only happens on placed.
Ohh on the controller not the pawn ?
Good point
Check the visual logger as well. Check logs in general.
I looked at the logs there was no red bars, I think if these were "ground" enemys it,ll probably work fine xD
I,ll make a custom AI Controller and then do the OnPossession instead of doing the AIMoveTo inside the pawn
That is recommended anyway I think?
Pawns should be agnostic of their controllers. But depends on the game!
same thing they rotate to the player but not move.
OnPossessed
Ok odd... I used default blueprint and just added a cylinder mesh no changes to CMC and it all just works.
the cylinders all were converging on me, So it,s something to do with trying to do flying enemies, I might just use ground enemies and put "flying" enemies on top of an invisible box lol
Indeed bit puzzled to say the least.
How i can activate a Task only when i have a true variable in my BPI Character?
I made a decorator that is looking at a bool type variable in my character in a decorator and then I made a task that I gave it what it has to do (nothing for now) but it doesn't stop the execution flow of the BT even if it is true
Maybe add a print to check what value the decorator is actually returning
What is the difference between a nav modifier area class set to None, NavArea and NavArea_Default?
I don't recall for sure but if you look at the navmesh generation when you use those you should see the effect... None might've been effectively disabling the navmesh from that area
Otherwise you might need to use nav query filters for them to have any effect
None seems to keep the default navmesh under the modifier, and the others as well. Only difference I found is that NavArea_Default seems to prevail over other modifiers and use the default navmesh under them as well
Is there simple free flying navigation plugin?
What do you mean it doesn't stop the execution flow?
Have you tried looking on the marketplace?
Area classes change the cost of pathfinding. None doesn't add an area class at all. AreaClass is the base class, which doesn't set the costs. NavArea_Default does actually set the cost.
So in my case where I don't want the modifier to affect the navmesh at all None is the correct choice?
Everything continues to execute normally, even if the decorator variable is set to true
Why do you have a modifier that doesn't change the cost?
Are you expecting it to abort what it's doing and do the new thing?
Because at runtime it changes area class, there are times where I want it to have an Area Class which actually does something, and sometimes I want it to be "disabled" by having Area Class "None"
That's fair. I'm not sure you can change it to be none at runtime, so you might have to use default.
It would seem I can according to my experiments
Yes, I want everything to stop being done to execute only the BTT of the Roll when the bool that the decorator observes, when it is set to false, continue executing all the rest of the BT
Then you need to make it an observer abort. If you don't use C++, then you can only do that by using a blackboard key. You'll want to abort lower priority.
Also if it's the highest priority, then you need to move it all the way to the left.
It is to the far left, but before the Wield Sword and before the Death.
Should I put a blackboard? how would it be?
Should I put a status?
I could do it
Thanks!!
Is there any other way so I don't have to use casting? Theoreticaly I already have resource reference in the blackboard value as actor but since it's set as actor and not exactly building I don't have access to these things without casting
Depends. Why do you want to avoid casting?
Just for the avoiding sake, don't have good reason but I don't like casting unless it's inevitable
Then it's inevitable ๐
Ok ๐
AI only exists on the server. Having a Server RPC function is completely unnecessary. They also don't work for server owned actors.
To avoid casting you can you interfaces. If you used C++ classes, then casting isn't a problem at all.
This is event that is inside BP_Resource that I'm calling from the Task. Should I just make it normal function?
Yes.
So anything that I call from Task, but the event itself is on the Actor, it will be called as server? That's briliant actually.
I try to use interfaces in every place, but I'm not able to get interface from the blackboard value.
It's only players that can use client and server RPCs.
If it's only being called from the BT, then it'll be on the server.
The AI controller and all of it's components only exist on the server.
I have 1 more idea but it doesn't really work and I'm not sure why ๐ I'm trying to call Get AIController, from the OwnerController or Pawn (of the unit), and in the Ai Controller, I actually have ResourceTarget variable, which I could get from, but Get AiController doesn't really cast to the owning unit?
this is In AiController of the unit that is usit this AI
You need to cast to your AI controller type.
Okay, so in this case still takes casting. Got it!
You need to cast anytime you want to access the things you added.
Thank you โค๏ธ
Could someone help me? In the viewport, my spawned ai moves in all dynamically generated rooms. In standalone, the ai moves in the first room generated, but in subsequent rooms the AI MoveTo node is executing, yet not moving. If I have enemies placed in a room then those will work, but spawned ai won't unless it's the first room. The ai will start moving if I show or hide navigation via the console using "show Navigation".
Check this in bp of your actor that you are spawning
Yea that's set to world or spawned, spawning works in the first room, but not subsequent rooms when in the standalone game
does anyone know if AI Perception works from a 3D perspective
oh, it just uses a line cast doesn't it, so it would work
Yes it does. But you may run into an issue where if the object location is behind cover, but some of the body is visible it still wouldn't see the object.
Don't know if it's fixed now but it used to be an issue with sight perception
I'm using shooting as a service and would like the interval to reflect an AI's rate at which they apply a firing input. Guessing that must be done via cpp but it feels jank since you'd essentially set a default interval that doesn't actually affect the node. Any suggestions?
Probably just need to think of shooting as a task then.
Im brainstorming one thing. Let's say I have a lot ostats like UnitRange and others, which I want to use in the tree behavior to check if unit is in that range of something. What is the best way to get that data from BP_Unit to AIController_Unit? It get's funnier the more data you have, or I don't get something? What is the simpliest way? Make interface that gets all the stats and use possesed pawn as reference for these stats ? So If I need something I just reference from possesed pawn, GetUnitRange and set it inside AIController?
Learning agents big update and updated learning material: https://dev.epicgames.com/community/learning/courses/kRm/unreal-engine-learning-agents-5-4/MpeM/unreal-engine-what-s-new-in-learning-agents-5-4
any idea what would prevent my AI from moving in a packaged build? in editor everything works as expected but in a packaged build the spawn points i have selected will spawn the ai correctly, but they will not move as if they have no nav mesh. the spawn points inside of the building work just fine though. this is all one large nav mesh (minus the little guy in the right corner) and im not sure if its related to world partition or whats going on
are you sure you have navmesh built and see recastnavmesh actor in the outliner?
i assume its built since ai can move around, just not in the big area. yes i see that
resolved by turning on the regenerate upon load in the recast nav mesh, thank you!
Alright, I was not happy with my NPCs line of sight that would rely on the AIsight which end up looking somewhere around the crotch area. Which mean that any random obstacle would stop it with line trace. Currently, it can now look at the hand (will change later. Wanted to check how precise it is).
How can I allow Line trace to go through ranslucent objects? And how can I allow it to go through certain objects I'm going to define manually because I don't think they should obstruct vision?
How could I make it so my own body will break the line trace?
And finally how can I optimize it? Currently it will be running on tick for all NPCs, so how can I do some fuckery to ensure only NPCs within a certain distance (That I can modify with a stealth variable) even have the opportunity to detect? So that NPC 200m away don't get a perception check to save on performances?
- IAISightTargetInterface can be used to customize exactly how the sight sense checks are done.
- To make the traces go through stuff you need to adjust the collision profiles just the same as with any other trace. You can configure the default trace channel used for sight checks in project settings, or if you have a custom line trace setup then yeah just change that. Overlap or Ignore should let the trace to pass through. Same with the player blocking it, configure it to block the trace channel you use
- AI Perception has timeslicing for this purpose. I recall it also does a distance and sphere check of sorts to see if you're even in range
- Not enough. Or at least nobody has been able to explain to me how to. I need to check if particular bodyparts are visible, but as far as I know there is no way to attach a Stimuli to a particular bodypart. All stimulis are within the main body and target only at waist hight. Did not manage to change it and repeated attempt at asking around have only be met with "Use Line trace instead".
- I'll check the trace channel thing, it's not something I know about. I'll look it up.
- I wish I could make AI Perception check works, but I really didn't manage.
You just override the CanBeSeenFrom function and do your own linetraces, you can choose where to trace with your own logic etc.
If for some reason you can't get it to work, for #3 you can use similar methods as the perception system does to optimize
I guess I'm not gonna escape diving into the C++ code editor for it if I want to make it work.
Not if you want to use AI perception unfortunately no :)
How do I have to go to find these functions and open them with Visual studio?
You would need to make a new C++ base class for the actors where you want to use this
and have your BP actor inherit from that
Got any good tutorial to get started with that? I know how to code, I just don't know where to get started with codes in UE5
i have seen that there is a lot of tutorials that do this by matching the velocity, but i need the projectile velocity to be static for things like grenade launchers
as for movement prediction, that is a separate thing and i already have some idea how to that
Is there a way to observe a specific enemy behavior tree in real time without the need for spawning in only one enemy? I want to see what one of my specific enemies are doing but I'm not sure which enemy it is observing
Only way I Iโve found is by running the game and selecting that specific instance
If I click simulate and have that specific AI selected is that representative of that AI's behavior tree?
Iirc, yes.
I would also open the AI debugger to make sure that AI is now the self
Then you can be certain
Hey,
I have a Pawn with a Sphere component (to detect enemies and create the range of the Unit)
I have an issue for Navigation, MoveTo etc.
This issue here is that the Sphere Size is added to the radius of the Actor/Pawn so when I do a move to there is a lot of issues. (Overlap is not well calculated because the sphere is already overlapping)
My sphere is having a custom channel for Collision
Interesting question... not sure if there's anything you can do really other than not use the actor overlap features of the MoveTos and such
Yes and in that case, recreate my own move to I guess and calculating the location
Or maybe there is a better way for AI detection, but I don't know if using AI perception is not overkill ๐
Depends on what you're doing. AI perception is a fairly straightforward system and I wouldn't worry about it being overkill unless you have some very specific requirements
I will problably have a lot of AI so I don't know about the performances on it but I can try with it
As long as you configure it correctly it's probably just fine
Ie. if your AIs need to only detect the player, make sure it's set up to only do that, which would reduce the number of line traces it needs to do quite significantly depending on number of AIs within distance
Its more like an RTS with auto AI detecting other AI
Well it all really depends on the numbers and you probably would need to test it to really find out. It does have time slicing by default which you can tweak, meaning it can limit how much time it will spend per frame doing sense tests
anyone know how I can ensure my AI doesn't jump over a sub tree in their main behavior tree
I think my AI is skipping over it or something
It won't jump over it unless there's some reason for it such as the sequence it's in failing
although it wouldn't really look like it just jumped past it in that case
it must be going thorugh sub tree super fast then
I think i might know whats happening, so I have this question probability thing and well it's super dynamic in that it's super hit or miss if it's actual does the question thing, I think issue is it's not doing a question so zipping through the sub tree and back to the main one
my issue at moment is it seems the AI is going from Moving to Table and going over to Paying
even though the Current Guest Journey does go to ordering
and as you can see theres a 60.0 second wait there yet it's not doing any of that for some reason, any help would be great cause it wasn't until I added in the paying and leave table on right it's started to play up
Run the game, open the tree, click pause, step back and forth
Also if the center branch is skipping, it prly means that current guest journey is not equal to ordering
You can use the AI debugger at runtime (;) to see what the blackboard keys are currently set to
I'm having this excat same problem with the mass ai system right now. I'll try this tomorrow ๐
is there any discord which talks about making game AI from scratch?
C++ like making FSM from scratch
im making one in ECS architecture but not sure what to do where
I mean as long as it's UE I don't see why you can't discuss that here
But ECS + FSM sounds... challenging... ๐
i did made one in the past
FSM in Unity
pretty sure can do one in Unreal in traditional OOP approach
but ECS making it a bit tricky
Especially considering that there is already a very performant state machine in UE anyway
also even thinking whether i should use GOAP instead because ill design diverse ai system
for starters I would make a state
an enum integer or something
then always check. If same enum then ignore otherwise do OnEnter
that's FSM I can do but what if player input is there to override the behavior?
At this point I'd recommend checking out StateTree instead
i would still use what's there already but im not sold on memory management side
actor system doesn't have a good memory management tho
Not sure what you mean?
What do you get out of making your state machine ECS then?
Especially when there is also an ECS system already built into UE
gotta iterate through 3000+ NPCs
very primitive tbh
used flecs from Github
Hmm, well good luck, hope your implementation does the job!
So it is equal to ordering as it was working fine before
It's since I added the stuff to the right it then started skipping the central bit
can you keep switching between Behavior Tree during runtime?
Yes!
Although it might be better to inject BTs instead, not sure about the technicalities behind restarting an entire tree
Actually if someone knows what is better switching or injecting I'd appreciate some insights on this
think ill just give up for now and will go through this approach
already spent months on other stuffs
maybe something for future instead
You mean your state machine?
yeah. Currently doing Hybrid approach to work on ECS
i can communicate between ECS and Actor system
now worried about performance. xD
however i still got another problem yet to solve
i got pathfinding working but no local avoidance
I'm not sure if there's a big difference between switching and running subtrees... switching would potentially just set up a new blackboard and a few things like that could in theory have a very very minor performance difference
If you need to keep BB state, subtrees would probably be a simpler option
Although I'm not sure whether the BB would get reset if the switched BT has the same BB type
Yeah currently I do a full switch, but so far no issues. Although injection seems wiser because it enables you to have like an archetype BT and then customize individual sub-behaviors
What is the "clean" way to define a place NPCs need to move to? Do I create some sort of invisible actors and ask it to move to that actor?
That's what I would do at least. Seems like the simplest way to do it in a way that's also easy to modify
Hello friends why the KI is running aways from his patrol system when i hit him in the -x direction?
Here all you need to now
event tick activated my handle movement
Handle movement activated the patrol system
also event begin play activated the patrol system
i think it must something in the "Event AnyDamage" because there i have an select that should be change the rotation of the ai in the direction of the player...
Is there a way to get the current cost of a location in the navmesh. ? I would like to influence the score of a generator by setting a low score for generated points that have been generated on top of nav_areas that are of high cost.
Good morning, I'm having some isses understanding behavior trees, was hoping someone could help me out a bit.
I have a custom node that just set the AI state (and an equivalent value as a BB key so I can control states with the tree), What I want to happen is the AI see's the player, does an action (in this case screams) and then proceeds to chase. I've tried playing with different variables to see what the outcome is as well as refactoring the tree (this is the latest spaghetti I've come up with) to try and make this work. I'm obviously not doing something right I just haven't been able to figure it out.
While in PIE the graph get's stuck in this state, the left tree for chase player executes a single frame and then returns to this state. The scream nodes should be setting the AI state to chasing, but it's getting stuck.
What does the task SetAIState on the left do exactly? Which state does it set?
It's setting the enum state value on board the enemy actor and the blackboard key.
Here's the task
Maybe I misunderstood the question, it's setting the state to "Scream"
Yeah that was the question ๐
Then I understand, it's doing exactly what you designed it to do!
It's executing the "SetAIState" task which sets the current state to "Scream".
Then it moves to the next branch and checks if it can "ChasePlayer". According to your decorator, the state is not "Chasing", so that branch fails and it falls back to the rightmost branch.
Just a general question: why do you feel you need to incorporate "states" into a behavior tree?
There's a different tool for exactly that: StateTree
If you're referring to the animation state tree, then it's mostly because I want different AI behavior based on the enemy state, so I needed to incorporate it one way or another anyways.
This is my first time trying to program AI so I'm sure theres a better way to go about it. Mostly just brute forcing my way through the engine until stuff works anyways lol
No I'm referring to the more recent (geared for AI but not exclusive to AI) StateTree plugin that enables exactly what you're trying to describe!
https://dev.epicgames.com/documentation/en-us/unreal-engine/state-tree-in-unreal-engine?application_version=5.4
It's a common mistake to try and model a state machine inside of a behavior tree. BTs are definitely not designed to do that. They work very much with priority of behaviors instead of states that are switched at will ๐
I did not know about this
Let me look into that, might be why I'm not getting the behavior I want.
Although your example clearly has a priority, so BTs should work, too!
Just have to get rid of the states and restructure a bit :p
I'm still learning the blackboard and behavior tree's in Unreal, seems like everytime I turn around there's something new to learn lol
But state tree's look exactly like what I want. Hopefully I can figure out how to make it compatible with my c++ code, but I'm a bit less worried with that part.
I figured out how to do it in BT's lol
StateTrees are quite compatible with C++, similarly to BTs
You can implement tasks conditions etc. all in C++ or BP ๐
But since the plugin is relatively new it tends to be a bit buggy for advanced use cases
Looking at the quick start guide, it seems like I can program behaviors into this state tree as well. Would this replace the behavior tree?
Nope, they're just two different ways to model AI.
One deals with states that are switched arbitrarily (StateTree)
One deals with behaviors that have a hierarchical priority (BehaviorTree)
Depends very much on what your use case is and what you're comfortable with. But considering many people try to use BTs like state machines I think the former might be more beginner friendly, maybe?
State Trees more beginner friendly? Doubt
State Trees could be more beginner friendly if the documentation was less confusing :P
State tree does seem like the way I might need to go. Not havinga defined flow for behavior that flip in and out of certain states when necessary is pretty much exactly what I want.
Hello everyone, could you tell me the modules and the CPP class to derive a task for the state tree?
You say that now, but wait until you have 20 transitions across 5 different nested states and then tell me how you like StateTrees ๐
If there were actual decent resources on it yeah
Lmao well, I guess I'll have to cross that bridge when I get there.
My game has a single AI enemy, so I only have to worry about one actor.
Thx u
The thing with BTs is when used correctly they kind of force you to keep a reasonable design
With state machines you can absolutely go wild and nobody can stop you
@uneven cloud are you affected from layoffs
Searched everywhere cannot find a way to create my own BT Composite Node, it just does not compile at all. Not even a new Empty class. Tried ue4 and ue5, both give me error, just cannot create BT Composite Node in C++?
please any help
did not find Docs, Tutorials or Examples of Custom BT Composite Node anywhere
(I'm trying to Create a simple "Random Selector", instead of it always executing left from right) But not even an empty class compiles
PS: I've added "AI Module" in my public dependencies, but it did change anything
This works for me
.h
#pragma once
#include "CoreMinimal.h"
#include "BehaviorTree/BTCompositeNode.h"
#include "BTComposite_Test.generated.h"
UCLASS()
class MUGENBEHAVIORTREE_API UBTComposite_Test : public UBTCompositeNode
{
GENERATED_BODY()
};
What error message are you getting?
#pragma once
#include "CoreMinimal.h"
#include "BehaviorTree/BTCompositeNode.h"
#include "BTComposite_Test.generated.h"
UCLASS()
class ENEMIES_API UBTComposite_Test : public UBTCompositeNode
{
GENERATED_BODY()
};
Same code
2 Errors:
Severity Code Description Project File Line Suppression State Details
Error LNK2001 unresolved external symbol "public: virtual void __cdecl UBTCompositeNode::InitializeMemory(class UBehaviorTreeComponent &,unsigned char *,enum EBTMemoryInit::Type)const " (?InitializeMemory@UBTCompositeNode@@UEBAXAEAVUBehaviorTreeComponent@@PEAEW4Type@EBTMemoryInit@@@Z) Enemies F:\Unreal\Projetos\Enemies\Intermediate\ProjectFiles\BTComposite_Test.gen.cpp.obj 1
Severity Code Description Project File Line Suppression State Details
Error LNK2001 unresolved external symbol "public: virtual void __cdecl UBTCompositeNode::CleanupMemory(class UBehaviorTreeComponent &,unsigned char *,enum EBTMemoryClear::Type)const " (?CleanupMemory@UBTCompositeNode@@UEBAXAEAVUBehaviorTreeComponent@@PEAEW4Type@EBTMemoryClear@@@Z) Enemies F:\Unreal\Projetos\Enemies\Intermediate\ProjectFiles\BTComposite_Test.gen.cpp.obj 1
something about InitializeMemory and CleanupMemory
just cannot compile it
Can Sight Radius and Lose Sight Radius be manipulated from Events or something?
I want a "Stealth" stat which act as a multiplier to it. Like if you've got the stealth upgrade, the detection area get smaller.
If you look at those functions, are they exported? IE - something like AIMODULE_API in front of them.
In 5.3 at least they're exported, what version are you using?
Also make sure you really have "AIModule" as a dependency and generated your VS project files
That sounds weird, because it would affect your AI's sight for everything, not just the player with the high stat.
You probably want to have like a stealth threshold for each AI where you still perceive like you normally would but have an additional check whether the perceived thing's "stealth stat" is above/below a certain threshold
Or have another distance check based on the stealth stat of the perceived thing
The issue with that is that it would mean an extra check. Performance wise it is slightly worse
If I want to have AI behavior for my player character under certain circumstances, would I hold off calling RunBehaviorTree until I need it to run, or do I run it on event begin play and then set some sort of bool flag to prevent any logic in there from running until the desired time?
Comparisons and squared distance should be pretty cheap, the profiler will know :p
Check "RunBehaviorDynamic"
But a bool would do, too
It depends what else is in your tree and whether you need it or not!
5.4
AI Module Added and Empty BT Composite Node Class
If I delete this composite node it compiles again
Where would I find that? I don't seem to see it anywhere? I don't need anything else in the behavior tree when the player is in control. This is only for use in certain instances when control is taken from the player.
That looks correct, not sure about the "AdditionalDependencies" in .uproject, I don't use that. I'm on 5.3 so maybe something changed?
In that case probably starting the tree at runtime would be better
Alright thanks.
Any ideas on why my blackboard might be turning up null? I'm trying to set some values on it from the blueprint that's using the AI controller for it. Everything i've checked looks correct (comparing it against another AI setup I had done in another project). But whenever I try to call GetBlackboard, I get this error: PIE: Error: Blueprint Runtime Error: "Accessed None trying to read property CallFunc_GetBlackboard_ReturnValue". Node: Set Value as Vector Graph: CalculateScreenCenter Function: Calculate Screen Center Blueprint: BP_ThirdPersonCharacter
UE5.3 works fine, even without AI Module
UE5.4 though do not compile at all, should we report it?
Huh. Weird! Do the functions from your error message look different between those versions?
UE5.3 does not get errors at all, it just works, even without AI Modules
UE5.4 do not let you compile even an empty BT Composite Class.
Seems Like two functions are no declared or so...
InitializeMemory
CleanupMemory
Hmm
I can't get the state tree AI to work at all. I created two C++ tasks for the state tree (one that acts as an evaluator since I haven't figured out how to make an actual c++ evaluator) to find the player location and another that should just log the player location.
Doesn't seem like the state tree is working at all, I verified to make sure it was attached to my AI character correctly.
No. Been safe so far.
Well I figured out my issues with it. I was using a StateTree AI which doesn't seem to work correctly. Even with BP tasks I couldn't make the tree execute. So switching it to a regular state tree schema fixed the not executing bit.
Still can't figure out how to make an evaluator in c++ but using a global task to achieve the same result seems to be working so far.
So it seems like I need to call Possess from the AI Controller to get it to take over the player character, but the Possess node says it's only called on the server? I don't see an alternative and my game is not multiplayer so.. what am I supposed to use?
Could someone take a look at these bp's and tell me if they look correct as far as making the AI controller possess the player character, and then getting a reference to the controller in the second bp? It seems like it's all debugging right in the first bp, but in the second one I try to get the controller and it comes back as the BP_ThirdPersonController instead of the Ai controller. I've tried using the GetPlayerController node, GetAIController node, and even trying to find the Ai controller by using the GetActorOfClass node since I can see it in the Outliner... but when I do that it doesn't find anything. I'm not sure what I'm missing? https://blueprintue.com/blueprint/36tpbqbs/ , https://blueprintue.com/blueprint/u92e6fzr/
So I tried to reparent my AI character fromt he standard BP Character to the standard C++ character
there's only oen issue. They no longer seem to move, they only rotate in place
I checked the visual logger and after a little finagling it seems that it is actually claiming to successfully be moving, it just doesn't happen in game.
any ideas where I should look next?
The nav mesh is there and perfectly fine too by the way
i'm really kind of lost at what could be different between the blueprint and c++ character classes to cause this
or maybe I need to change a reference somewhere?
Can you show the log
Indeed, looks different, in 5.3 those functions are not overridden
5.4 BTCompositeNode.h
virtual void InitializeMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryInit::Type InitType) const override;
virtual void CleanupMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryClear::Type CleanupType) const override;
5.3 BTNode.h
/** initialize memory block */
AIMODULE_API virtual void InitializeMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryInit::Type InitType) const;
/** cleanup memory block */
AIMODULE_API virtual void CleanupMemory(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, EBTMemoryClear::Type CleanupType) const;
I don't know C++ well enough to say what exactly the problem is, but this seems to be the only difference. Don't know if the overridden functions would need AIMODULE_API as well
Glad to hear that
Hello guys how can i check it out here when ever the X value falls down or goes up i need to connect the return value of the X from actor location in something that can measure that
keep tracking of the old x value in a variable and compare to it ?
Hi guys ! How can I block AI movement without blocking character movement component (I want to continue to apply root motion) and without blocking rotation ?
how to compare it with waht kind of function? ok i have the x value in a variable now
Near equals + branch
nicccccceee thanks ๐
Abort the MoveTo?
I can abort moveTo with Stop Movement Immediatly
i want to prevent the ai from moving
No I mean you can abort the AI's MoveTo if you're using behavior trees
Not sure how it works in blueprint
I'm using BT
I can disable "movement input" from my player with
but I don't know how to do it for AIs
Using StopMovementImmediately will stop all movement I think, so root motion too maybe? Not sure
And your AIs have no input. So you'll have to abort the MoveTo in your behavior tree instead
You can also use StopLogic to stop the tree from running entirely but Iโm not sure how that would affect the CMC
I can abort current AI move to and current root motion, its ok. But I want to prevent new ai move to/movement
StopLogic stops the behavior tree. If my AI is in trap, he can no longer move but he can still attack and rotate
Decorator IsInTrap on the MoveTo node?
I can try this, but why if I have 15 Behavior trees with 3/4 ai move to tasks in each of them ?
I mean technically a trap would set your movement speed to 0 instead of disabling the movement request of the AI
Is that already a case of states in BTs? I find it hard to draw the line sometimes
maybe it can do the job
Trapped or not trapped seems stateful?
True, but so does "Player is in range or not", no?
Unless I'm confusing something
yes, we don't have "isTrapped" or "isFrozen" or "isStunned" in our game, we have State.MovementBlocked, State.RotationBlocked, State.AttackBlocked, State.AnimationBlocked tags
Same thing tbh
Kinda. Point being is if you find yourself having to maneuver around the tree fighting the tool, itโs prly the wrong one
Guess that's a good approach
not really, because only 1 decorator "HasNotMovementBlocked" is sufficient
I find it weird to put the responsibility of "I am trapped" into the AI
Probably belongs elsewhere
I'll try to set the walk speed to 0
That's what I would do right now if I had to implement that
Apply a gameplay effect that nulls your current speed for example
Soโฆ GAS? ๐
Yes, we have GAS. I was going to make an effect that overrides the speed attribute
Seems the most straightforward solution to me.
I mean, players don't manually have to stop moving when they're trapped right? So why would the AI
yes that's true, but for the player, I can block move inputs
The problem is those functions aren't exported outside of the module. So things outside of the AIMODULE won't be able to do things with them, IE - override them, or even call them.
You either wait for Epic to fix it, don't update to 5.4, or make source edits and export the methods yourself.
But they are exported in both 5.3 and 5.4 in BTNode.h
But 5.4 now overrides those functions without export in BTCompositeNode.h, didn't think that would break it
Override GetInstanceMemorySize after inheriting from UBTCompositeNode. If it compiles, then that is the problem.
Looks like it broke because they weren't overriding the method in 5.3, but they are in 5.4
It has since been fixed though
Have to wait for the next major release it seems.
So you'll have to patch it yourself.
Unless @crystal hatch can try to get it approved for a 5.4.2 release (if there is going to be a .2 release that is)
Qestion: i know its kinda stupid but :
How to make AI to react to bool value changes in blackboard?
Also how change Bool value in black board from false to True.
I'm asking because i tried and searched every where - It just doesn't want to work at all.
Just incase Event Call SetIsDead is working fine
I think "IsNotSet" is the wrong operator. It checks whether a BB key is missing rather than being false or true. You want an equals or not equals instead
how to do that?
What is the Blackboard Decorator Node in the Behavior Tree in Unreal Engine 4
Source Files: https://github.com/MWadstein/wtf-hdi-files
Its corrrect
IsNotSet == False
IsSet == True
Oh, ok!
So don't know if anyone can help with this so in the screenshot it's paused
You can see the Current Journey Enum is on ordering
However if I step into you can see it's then set to leaving
and I've found this is why it's skipping over the ordering part
Why are you doing that via a selector & state enum? Looks like one long sequence to me
Guys why my AI is not flying
When its so far away by the ground its not working
But when it closer it works
Anyone have any suggestions were how to start getting access to the navmesh and request Async Pathfinding? In C++
Most samples or tutorials use the standard AIController. I want to try and batch numerous Pathfinding requests on Async threads. So i can move plenty of AI agents.
have searched a bit in the following files:
NavigationSystem.h
AbstractNavData.h
AIController.h
Just need some sort nudge me in the right direction. Maybe which functions that would be needed?
I don't remember the specifics, but look into the existing navigation functionality that gets paths
there are async functions to calculate paths already in there also
Thanks for the response
In the AbstractNavData.h i found this FPathFindingResult AAbstractNavData::FindPathAbstract
In NavigationSystem.h there is FPathFindingResult FindPathSync and uint32 FindPathAsync
There were some more when i was searching in the engine files. But these two was those that sounded the most correct.
Guess i should try the NavigationSystem.h and see if i can get it to work.
Yeah FindPathAsync would be where I'd start for this
@dense owl
you see it doesn't really tell me anything
it thinks everything is going fine
the AI thinks it's moving on the navmesh, it's just not actually doing it.
at least that's my understanding of what i'm reading
Are you sending the move to request more than once? Also are you clicking on each of the AICon frame and reading the log underneath ?
So the log just says "LogPathFollowing (Log) Moving directly to move goal rather than following last path segment" which is fine
it is sending a new attempt to move to every 5 miliseconds
I'm not sure if I'm reading this right but it seems like it's trying to move to, think its doing it, then updates 5 miliseconds later trying to do the same thing since it hasn't actually moved
if it was working it would be a solid bar and stop checking right?
i'm going to change back the parenting and see what its output looks like in compariosn
ignore the first red part, that's just before I turn on the navmesh invoker
I have it on a toggle for testing reasons
so the log is the same, but it definitly shows up differently, you can see it forms a solid bar
the navmesh seems to be pinged more frequently too
could the problem be elsewhere than the AI?
yeah you shouldn't be doing that
if you keep saying move,move,move, the moveTo task will keep restarting every time and failing to do anything
mmm
it's a latent action you need to allow it time to complete
but the other version does that and works
so I think it might be something else, and that's just something I should change
at least I think that's what I'm reading, since the code is not different
only the base class it is a child from
that seems like some bad practice I picked up from a bad tutorial rather than the issue at hand I think
I guess I could try and fix that while I'm looking for the solution though
what does the first green frame show?
also Luthage would prly encourage you not to use invokers if avoidable, since they are quite expensive perf wise
Yeah I am aware of the downsides of nav invokers
but i havn't finalized my decisions on them yet and they're not too hard to swap between
for now they're very useful for testing
ok. so when the move first happens in that separate frame, what does the log show there
I'm not sure what you mean by green frame
you have a lot of red, followed by 1 green or blue w/e
with a space, and then a solid bar prly due to the attempts on tick
I don't see a green one sorry
the first frame that is not red says the same as the others
moving dirrectly to move goal
that's it? ๐ค
yep
this is the first frame witht he nav invoker on
and the first green one
er blue
click on each of the first few frames and see if you find anything like this
if not, look at the last red ones
basically more than just one line
they're all blue
the red ones are just because the nav invoker is off so there's no navmesh
once the navinvoker is on the nav mesh errors go away as expected
the log never says anything different between the AI that works with the normal character class and the C++ character class
just their behaviour in the game is different since one can't move
at least one of those frames should show more than just Moving directly to goal
especially on the bp class which is working as intended from what you described
WAIT
I FIGURED IT OUT
oh i'm a dummmy haha
it was the movment componenet
since I was using a custom movement component I forgot that it emptied out the walk speed values
ok now i'll just go and follow your earlier suggestions on ai
thanks so much for helping me out and I did learn a lot about the visual logger ๐
so I'll do some more research into good AI movement goals, but basically the idea is that they should move all the way to their goal then reassess?
np
yeah
ideally you don't want to keep requesting a move when it's still going
if you're using a BT it will do the work for you and wait for it to complete rather than ticking away
otherwise you should prly use the onSuccess/onMoveFinished pins to continue your execution path, if using the regular nodes
ok that makes a lot of sense to me
having said that if your goal location is a moving target, then you probably want to make the multiple requests ๐
that makes sense, in this case it's the player character
but I think it would be too bad if it didn't ping too often anyways
It doesn't have to course adjust every 5 mili seconds, once a second is probably enough for a basic AI
Any ideas as to why Get AIController returns none in this environment query context provider? The Querier Actor definitely has an AI Controller
Print the querier to verify it is what you think it is
Hey @misty wharf, Do you know how to create a state tree evaluator in C++? I tried following a similar template to the STTask, the code will compile but it won't actually show up as a selectable evaluator in the editor. I'm thinking there's a naming convention that's not inherently obvious.
Also to anyone else that might be able to help, I can't get my state tree to execute more than once. I'm guessing I don't have the correct transition logic setup or my tasks aren't coded properly.
You might be inheriting from the wrong base class... iirc there's StateTreeEvaluator and StateTreeEvaluatorCommon or something like this - one of those is wrong
Each state tree has a "schema" which defines which types of evaluators and tasks are valid for it
There's the StateTreeComponentSchema (or whatever it was called) which is used when running it from the ST Comp
The other one is StateTreeMassSchema or something like this
you probably want to look at the component one I'm guessing
Ahh ok. Yeah let me see what I'm doing, that should at least point me in the right direction on Evaluators hopefully lol
I'm using a global task as a work around in the meantime which has been working fine
lol
My other issue is the state tree is not executing more than once.
You may want to use the visual logger or the st debugger to see how it transitions between states
Do tick functions execute every frame in a task?
It's also possible that if your global task finishes, this can cause the whole ST to effectively freeze