#gameplay-ai
1 messages ¡ Page 43 of 1
yes
because "AI Tasks" is a separate concept :)
thats what i meant
Usually for behavior tree tasks, you would create a Blackboard Key Selector variable in your task
the first time lol srry if i was confusing
If you mark it instance editable, it will then be available to modify in the BT editor view and you can assign a BB value to it
You can also just add the logic to find the object directly in the task. You don't have to use the BB if you don't feel it's a good solution
(In one of my projects the NPC's search for objects and store the information about them internally and NPC-related tasks use the NPC's internal "knowledge" instead)
can you simplify what you said for me srry its confusing
Basically the NPC itself has a variable which stores a list of objects
oh like create a array of that object that i want to move to
Yeah
If you want to keep things simple, you could just put the logic to find the object into the task itself
The main benefit of using the BB is that you can share information between nodes, and for example decorators can abort based on BB value changes easily
but if you don't need any of that then there's less reasons to use it
https://forums.unrealengine.com/t/what-is-the-best-way-to-get-and-store-references-for-use-in-a-behavior-tree/661186 i use this but i dont think its right for what i want
Hello. I am wondering the best way to get and store references to characters/objects in a behavior tree. I suppose I could either grab them in the AI Controller or Task and assign them. But my question then is⌠how do I retrieve the reference? Or is it more efficient to just cast for references every time in each task? There is the node âGet Bl...
That seems fine
how do i get it tho to be used for a npc to move towards an object because i did it and it doesnt do it
You have to check what the problem is that's causing it to not move
Is the variable not set or is there some other issue
its not casting
Hi! I'm wanting to build a simple village simulation that includes gathering and retrieving from nodes and bringing them back to the village "center". I'll be using this as my learning project but am not sure where in Unreal Engine to begin that learning.
Should I be looking at the blueprint system?
The only things I really know how to do right now are to create the physical assets that will be my developer art representing the stuff, and add those to the world. I haven't gotten to executing code yet; just creating objects and lights. TYIA!
That can mean multiple things, the value could be null or it could be a different type of actor. You need to check the value to determine the root cause
Ok
No one is going to walk you through building a game. I recommend starting by doing some courses in the learning library. Then make some simpler prototypes before jumping into a more complicated game.
Thanks for answering! I may have not stated my question clearly enough - I'm wanting to build the simple prototype. What I am wondering is if I should be looking into this with a mind of using the blueprints system as I don't have any context for coding in UE specifically and am intending to focus my learning in the areas of the engine I will be using. đ
But if there is a specific starting point you would recommend instead, in the learning library, I'm absolutely about hearing that recommendation.
Having thought about it, my question can really be boiled down to: "New to UE, should I jump right in to blueprint system or add that to the workflow after I have been successful with C++ alone?"
Was asking here because I felt that my application might be relevant.
Grrr... Rubber duck effect in full swing. đ¤Śââď¸ I actually need to be looking into animation next and following the rabbit trail ended up answering my original question. Yeah, blueprint system is going to be relevant for me.
As a beginner you definitely want to be using blueprints first. It will give you a much nicer entrypoint and overview of the basic systems before jumping into C++
Full games can be built on BPs but using C++ will certainly help you make your project more robust
(plus various features which are C++ only)
This makes sense. I wasn't sure if I was in this universe, or the one wherein any serious prospective dev masters C++ before adding blueprint otherwise it's a recipe for disaster. Y'know? đ
Thank you, and you also Luthage.
I'll be back in a few days with that prototype to woot about it, hopefully. đ¤
hello i'm trying to make a simple turret. so far i got it to successfully rotate towards player but it instantly snaps to it. i want it to be smooth and also give some leeway for the player to escape the line of sight
i know the main issue lies in here
i'm calling this function in the turret actor in a behaviour tree task
and i can't have timelines in functions
and i can't get delta time either because this is not event tick
for interps
One way to do it would be to have a target rotation value on your turret
You can set the target rotation from the BT task, or set a target actor from the BT, and then calculate the target rotation
Then the turret actor itself would rinterp towards the target on its own tick
i mean i do have the reference. i am sending the reference from turret to behaviour tree.
i feel like i want to seggregate all the processing to the behaviour tree otherwise i can just not have a behaviour tree for a simple turret
If you really want to do it in the BT then you could have a ticking BT task or a BT service
the few videos i've seen on yt do it on event tick
It's fairly normal for the BT to not do the specific actions though - it would be fairly reasonable to put the logic for rotating towards a target into the turret blueprint, where the BT simply tells it what its target is and it figures out the rest on its own
thing is i know i don't want an event because that would be tooo many event calls when player is in range and moving.
How many turrets are you going to have
idk maybe 5-6 per level might be more
Yeah that's nothing, you can do it on tick just fine
There's no point in avoiding ticks for things that you clearly need to do on tick
i feel like that's bad programming practice imo
A timeline is exactly the same thing as ticking in this type of usage
yes but timeline ends at a point and that gives me assurance that it's not going to run forever
You can turn off tick after you've rotated to the target too
?
There is a node to turn tick on/off :)
Personally I would make it so that you set the target actor on your turret, and the turret then ticks to rotate towards its target actor
But you could also have a tick event in your BT task which handles the rotation if you want
in this case i wouldn't need the function in turret actor correct?
Yeah
i'm sorry i'm just being dumb but i do need the root scene reference in the task
cause i can't rotate it otherwise
You could get it from the turret actor I guess
and this is just me prototyping
when i get the model it has 2 moving parts one only rotates on the z axis and the other(barellels) move up and down
I'm not quite sure why you want toe BT to do all of the work though :) It's going to couple your AI logic to how the turret handles its own logic
why i don't want the turret to do the logic is because we might scale it
maybe have different turrets and stuff
That sounds exactly like a reason to have the turret do the logic
one turret might just be slow and do z rotation first then adjust barell while other turrets might do them parallely
so having them in tasks i can just change the sequence node to parallel
although now that i think about it i might need to have different bt for different turrets then
Well, if you have different kinds of turrets but they all have similar logic then you could share the BT
or i can have mini bts one does handle only the z rotation while another does only up down and maybe i can run behaviour trees within behaviour trees?
But if your BT task has the logic to do the rotation, then that would get in the way of sharing it because each turret could need a different way of handling it
as you said they might rotate in slightly different ways, so your BT task would need to be able to handle the different turret types
but if the logic for rotating is in the turret itself, your BT task can simply tell the turret to rotate and it doesn't need to know what type of turret it is
in this case i need to fire events like constantly in tick
as player is moving
Well how else are you going to do it
and idk why but i feel like i shouldn't be doing it
i'm not as opposed to call a function that many times
You do realize that if you call a function on every frame you're doing exactly the same thing tick does
As I said there is no reason to avoid tick for things that need to be done on tick
there's no difference with event vs function in that sense
the reason you want to avoid calling events is because you've seen too many tutorials that tell you to not use tick without understanding lol
ok i did this
and i'm calling the event rn
but the turret although rotates smoothly is still very fast and player doesn't have leeway to escape
the timeline is like 5 seconds
wait no i made it 10
it's occationally snapping to player and stopping for some reason
It kind of depends on how often you're trying to rotate it
Because of how the timeline works, if you change the rotation target while it's already rotating, it will simply continue from where it left off rather than continuing from the start of the timeline
i did plug the pin into play from start instead
ok so the issue i have now is that the turret instantly rotates(idk how or why it does it but it rushes through the timeline) and i need a return node which i can't have in an event flow
It usually isnât
Are you just trying to make an AI turret face your player ?
yes
You donât need all of that
i need to know when it's facing player so that i can finish the task so that i can move onto the next task
what do i need?
đ
You can adjust the speed by changing the CMC or floating pawn comp rotation speed
it has no parameters
only blackboard key it accepts is self
?
That just means you didnât expose the right bb key properly
what does it need?
Or youâre using a location vector rather than an actor ref
A bb key that stores your desired target actor
huh?
i have it
do i need to override it?
i mean i have an actor key
other than self
Is it being used by any other BT node right now? Cause if you canât select it it usually means you havenât exposed it properly
Hang tight, Iâll pull up my project in a min, gonna need some coffee first
ok
Can you show the details of your bb key?
Haha yeah I was just gonna say that
ok so how does this node work?
Basically does what it says it does
like will it automatically face towards player and stop executing once it's done?
and i didn't understand this CMC? floating pawn comp rotation speed?
Char movement component
Or floating pawn movement comp
Is your turret a char or a pawn?
also my turret will have different static meshes/ have one skeleteal mesh which will have seperate bones that need to be rotated
so how does that work?
it's a pawn
Iâm confused. You said itâs a pawn but before that you said itâs going to have an SKM which implies char
i don't have the mesh right now artist will provide it to me. so i cannot have a skeletal mesh if it's a pawn?
well i do have 2 skeletal meshes temporarily in the actor
so...
the guns are skeletal meshes and the cube is a static mesh which i'm using as standin
It should be a char
the actual mesh will have like 3 parts non moving base the top part that only rotates in z axis and the barellels which will have limited movement up and down
Thatâs fine
i should be able to change it to that no problem but i don't understand why it needs to be a char
Cause it already comes with a skeletal mesh for starters
And a char movement component
Itâs easier to do this now rather than risk breaking stuff when reparenting it later
well i'm just gonna ignore the current skeletal mesh because i don't have one right now
and it comes with this, which you'll need in order to adjust its rotation speed
that's fine
did you read above?
yeah i mean this is the only node i have in behaviour tree
soo
it still snaps
do you wanna hop into a vc?
I don't do that
not sure what's going on on your end, this is what I have and it's even using a location instead of an actor, works fine:
it will be easier for me to show you rather than record a video or send pics continously is why i'm asking
i'll screen share
we can still message
had to disable yaw rotation
ok but how do i make something similar for the barllel rotation
which will be clamped
or do i need to have a task for that
There are a lot of technical issues. First you have the navigation problems. Dynamic generation doesn't just have a perf cost during generation, but also a memory cost. You also lose the ability to see in editor how the navigation is built, which is a big hindrance. As someone who's done procedurally generated games, this is a big dev cost.
Next you have the problem of multiple people working in the same map. UE5 improves the workflow, but not completely. File contention is a big problem for every team.
Then you have the issue of the more stuff you have in a map, the longer it takes to load.
There are probably a lot more than I know about, because I haven't tried it.
A turret most definitely should not be a character.
This should be done with the turret actor and not a BT task. The BT task should tell the turret to rotate, it does the rotation, the BT task waits for the rotation to end by using a delegate (event dispatcher in BP) and finishes once the delegate has been fired.
It's completely unnecessary extra expense and turrets don't rotate like a character does.
yeah fair, I was thinking char because he mentioned having an SKM in it but ig it won't need to move like a unit would
They also don't usually move. Outside of rotation.
yeah fair point
Lots of things have a SKM.
I rmbr you mentioning dispatchers to make a BT task wait for something to complete a while back but never did get a chance to test it
so you wouldn't use rotate to face bb key for a unit that doesn't move? ig it's meant to work off chars eh
So the task calls an event in the turret and turret will call a event dispatched when finished? If so how do I bind the event into the task?
Ps: i shut down my computer so I can't test/play around it right now just trying to imagine and remember stuff. I'll do it first thing tomorrow.
That's what I thought so I made it a character initially
Because i thought it's all going to be simple rotations but it turned out this complicated.
You bind to it just like any other event dispatcher. If you don't know how to do that you can look it up.
No you don't rotate it as you would a character, because it's usually a specific part of the mesh that moves.
I'm also not asking majority of the vector math issues I have I'm trying to play around and figure that out myself because I'll just embarrass myself asking them and someone saying just go learn/watch some tutorials about basic vector math. :p
DOT product will change your life
there's even an EQS test built-in for it
and also we have #game-math if you need more advanced help
The only time I binded an event is when i create like a user widget within a user widget and I have to get back it's button event. So I know I can expose it on spawning it. Or when I have reference of it. But I'm unsure of how I'd get the reference to the task within the bp actor.
Eqs seems overkill for a turret
You don't get a reference to the task to bind something. You have an event dispatcher on the actor and the task binds to it.
I'll play around with that tomorrow. So which do you recommend? A timeline? Or event tick?
And I do use the node set actor relative rotation for the actual rotation correct?(in this case I'm using actor rotation because i don't have a base that doesn't move but I will change it to mesh rotation later on)
There really isn't much of a difference between the two. Timeline is probably easier.
I do not recommend set relative location. Just use set location.
I got an issue with EQS. I want to get the node/dot or whatever the green points are called that is closest to the querier. In the pic the winner is the dot that is furthest away, but i want the one that is closest. If i change the Distance test to inverse linear, it prefers smallest, which flips the green dot numbers.
ends up running into walls when trying to stay out of range lmao
Then add better tests.
đ
AI don't automatically act intelligently. You actually have to do the work to make them have reasonable behavior
What is your question?
How do i get the closest point?
You use a distance check with inverse linear
Hey all! Trying to figure out how to get my AI to not switch targets after they've already perceived the first one? Currently they'll see one player, but then when they've perceived another, they'll switch to that target instead or sometimes just completely ignore both targets and i'm unsure why.
Because no where are you selecting a target.
oh my god you're right LOL I dont know why i thought it'd just stick to the first target it sees without being told to
what kind of things can make an AI move to node fail?
I made a simple task for a random location and it's getting a random location fine, and the AI move to was working but now it always fails.
I'm scratching my head as to why
nvm
haha i confused radius and acceptable radius
they're very subtly named
that would definitly make sense as to why it would fail
so.. i have one more question. does the task calculate to which point to rotate to or does the turret handle it because both of them have player ref
I personally would send the actor to rotate to into the event, but really it doesn't matter.
so with the timeline what's happening is it changes rapidly. it does majority of the integer in like an instant and at the end it does the precision points which is barely visible so it feels like the turret is moving instantly then has a delay/wait
the precision points takes alot of time for it to lerp
idk how to fix this
Ive been doing alot of research of how to reference non player actors in ai behavioral task node for the use of the ai moving to it, for the purpose of npc management games. I look through several forums, used several assets from the unreal store. All of them either use eqs, the get all actors of class, get all actors with interface, get all actors with tags. Is that all the methods for this type of thing?
Show that code again
And sorry is this a char now or back to a normal pawn?
Does a pawn have control rotation settings I canât rmbr
i wanted to do it using rotation movement component but that was
even more complicated imo
Also, why use the scene root component for this rather than self?
idk it throws error when i use self
Ik char has some settings that can override the control rotation causing problems with it, but pawn prly doesnât have those
Youâll need to use diff versions of those pure functions when you use the actor (canât have component as target)
pawn doesn't have a movement component i have to manually add it
Yeah makes sense so itâs likely not being overridden
Since youâre doing all of this on the root, you might as well rotate the whole actor then
But in the interim, I would right click, watch value on your Z values and see what comes through at runtime
as i will only be rotating part of the actor i.e a mesh
Youâll need to select a debug object to see them
i did and as i said i figured out that the lerp for some reason does the sweep in non- uniform fashion
it first does majority of the integer value then from 3/4th of the rest of timeline it starts to fine tune the precision points
oh wait
maybe it's because alpha only needs values from 0-1
and my timeline is 3 seconds
It needs values between 0 and 1 but unless youâre feeding it the time it shouldnât be a problem
Your track is between 0 and 0.5 as far as I could tell
Actually, you should prly end on 1 so you donât stop half-way, else so will the lerp
No, not the time
i did it to .5 for testing i had it to 1 before
Keep it at 1 tho
The time can be anything, your end value should be 1 tho else youâll never reach B
You said youâre calling this event from a task?
i mean although it eventually does reach i have the same problem regardless
Have you tested the event in normal circumstances (i.e. press P to call it)?
when it comes to the end it slows down to adjust the floating points
i have not
i thought maybe because the floating precision points are the issue, maybe flooring them might help it make an approximation quicker
If weâre talking floating point error, floor wonât fix that.
also i found this bug right now
it chooses to go all the way around rather that go the other direction
Try using normalize axis before feeding them into the lerp
Also this is more #blueprint than #gameplay-ai now đ
normalize seemed to fix it
but yes
look at how much time it goes to update but how quickly it rotates
what i'd expect is the rotation to be spread out until the finish is called
Looks about 2 seconds
i changed the length of timeline back to 3 seconds
but anyway coming back to ai. i'm unsure of what to do
do i have like 2 aiperceptions?
because the current ai perception that i have is 360 degree sight
but i also need to know when it's facing the player so that it can stop rotating and shoot at him
also i don't know how i would do the barellels
let's say the turret was on the wall
:/
DOT product
Thatâs for location
but how do i know if the player is in within range for shooting
you mean to do dot product of rotations?
for what and what?
Turret rotation and player rotation iirc
Get distance to actor
no by range i mean if the barell is pointing at player or if it's pointing to the side and player already moved out of it's line of sight
i'm guessing ray cast is unavoidable
or another collider
or another ai perception
No you should only have 1
EQS solves most of these problems
And you can run a service that checks itâs in range and right rotation etc
Dot product. Line of sight will tell you if anything is blocking it, but if you only need to know if it's facing the target then you use the dot product.
It entirely depends on what you are trying to do. There's no such thing as only one way to do a thing.
Oh
But from what I hear about these nodes is that they donât âupdateâ or count newly spawned in or loaded in, also they slow games down. So why use them
Why do you expect them to update something? You find an object to target and then do whatever behavior you want. If you need it to update, then you have to build functionality for it.
They don't automatically slow down the game. It can be perf heavy in certain circumstances, but that's the same with anything. There's a myth that Find Actor of Class is slow, but it's wrong.
Like update on an actor being added to the game of the same class
Oh I didnât know it was a myth
That's a weird thing to expect to happen. Just use a service. It's not complicated.
Ok
If you use the EQS, which I recommend doing, you don't even have to make a service. One is already built in.
Ok
Are they great for making games that are survival colony management
Yes. It's the environmental query system. So it's built for querying the game world.
Cool
When using EQS, how do I apply my on custom checks on GetActorOfClass task?
Can I make my own EQS Task in C++ that inherits from that task and apply my own checks to each actor?
Sure, or just use a test which filters out unwanted actor types
An EQS node reference test?
"EQS Node Reference" is the name of that page, they are just called tests lol
But yes one of those could be used so you don't need to create a whole new generator for it
Okay, I will look into using my own tests with the existing generators.
Thank you.
You are correct
Usefulness of BT's depends on what you're doing and how you want to structure it
They're not a silver bullet for every imaginable scenario
In the type of scenario you describe they could be useful for higher level behavior selection, such as choosing targets or whether to pursue, run away, or some other such behavior
And you can have a node like "Attack" or whatever which then just delegates the actual attack logic to the controller or whereever it is
iirc there is some kind of eye height / head height value somewhere that it uses
for visualization you can use the gameplay debugger during gameplay at least
How should I get the State Tree context in my Finish EQS query callback in C++?
there's some builtin tasks which use delegates maybe check those? Such as FStateTreeTask_PlayContextualAnim
I am just copying how Epic structured their **InstanceDataType ** for that Task.
Thank you.
ok i think i figured out what was messing the lerp up
I think I don't know how to make a cooldown StateTree condition. Which is pretty funny
- ST conditions cannot hold state, aren't notified of task execution
- data flows downwards, so if the state gated by the cooldown condition runs and I wanted to save out a timestamp, it cannot produce an output that the condition can then read next time
external data storage for this kinda stuff?
You can override GetActorEyesViewPoint in your pawn or controller subclass, but it can only be done in C++.
I wonder if you would have to make the cooldown a task
I could do that, but my tree is:
- CombatRoot
- CombatIdle (stand around target)
- Attack
If I want them to idle while waiting for an Attack cooldown, it won't really work (the above formatted wrong, Attack and CombatIdle are siblings)
I'm going to make a squad manager where cooldowns are handled for everyone, but it's a bit strange that I can't fudge it for now
Yeah there's a few bits like that in ST which are a bit clunky
maybe in Mass it's more straightforward but this is the actor level
Why would it make a difference if it's Mass? đ¤
As far as I can tell Mass just makes things more complicated if anything but I've not really looked at it
being able to read/write to arbitrary fragments maybe? I'm just theorising
hey there everyone đ
Is BT nesting a good thing to do or not?
i mean it looks clean and easier to read when doing the nesting , but i don't know if there is any performance cost to it...
Itâs perfectly fine
Assuming you mean using subtrees
like this right?
Yeah
got it ...
as the behavior tree grows bigger it hard to read so i thought to create sub tree for each section
yeah they are using the same blackboard
one more question..
lets say i have this BT structure and right now my wait task is executing....
but something happened somewhere because of which i want to re-run my section "2.2",
one way i am thinking is to restart the whole brain logic (because i know that if i restart the control wil skip all the secton before "2.2" and direcly execute this section) ...are they any other ways to do something like this?
i hope i am not sounding dumb đ
It wonât let you use a diff one
The engine gets really mad at you if you try đ
Why do you want to restart your current branch?
there is a logic in that branch that i want to re-evaluate when my AI takes damage...
so even if my AI doesn't takes the damage then also this branch execute, but if it takes Damage, then i want to instantly re-evaluate it so that my AI can take new position
sounds like you should be doing that logic somewhere else, and kicking back to it when you take damage
if you find yourself trying to break the pattern then it's likely you've not found the best way to fit into it
learning state trees, the "Shoot At Target" and "Move To Target" states are never run but the "Turn Towards Target" state is. Im not sure why this is the case because my understanding is that the "Shoot At Target" state will always run after "Turn Towards Target"
that's what i am thinking...
looks like i need to rearrange my BT
Should I use eqs because wht Iâm trying to do is when my Npc gets tired/sleepy I want the ai to if a bed is around to go for that bed but if itâs not pick a direction and follow that direction untill it detects one of tht makes sense
Or do all actor of class
I also want it to update anytime an actor spawns in or is loaded in
Or dragged in
Does Find Target return success/failure? If yes, then that's the cause. If any active task returns something else than running it will trigger transitions from that state
ah I see, thanks!
I literally told you yesterday that I recommend using the EQS. That's exactly what it is designed to do.
Ok
I've got a BTTask that changes the walk speed(as im trying to implement a run). This works but then I'm not sure how to reset it when they leave that task/sequence.
basically it keeps stacking the increase
Create a new task to reset speed when they are done
ok yea, so there isnt a way to have an event when its complete? i guess since its on a tick?
Do it like this, when it is done with the task, you cue up next task that resets it, kinda like i do here, but with speed:
Use a service with the on become relevant/on cease relevant functions and not a task.
interesting, still new to bt i will look into services
This is really bad advice. If the walk task is aborted then clear focus is never called. That's why it should be in a service and not a task, like the built in default focus is.
Yeah makes sense, i haven't looked into services yet
I have an ai that i want to go to the nearest node. How can i go about to do that? And at the same time make sure it doesn't go towards the one that is on the other side of the wall?
Pathfinding batch test set to cost.
Services happen while the branch is running. The 2 functions I mentioned are called when you first go into that branch and then when you exit.
hmm not seeing them on the list, I have "set default focus" and "Run EQS query", guessing i have to make a new service.
Thank you @uneven cloud
Thank you! Now he goes in the right direction, but he's going all the way past the closest node
It entirely depends on the score. I recommend using the visual logger as that will tell you how it's scoring them.
how would i do the eqs percieved actor generator there seems to be no tutorial on it
Never mind figure it out
But I donât think I canât use eqs because I have to switch on auto register as source which crashes my game any game like even if I get a new game
Yep canât use perception at all
Is there an advantage of using services vs decorators in this exact case?
You do know there are other generators and you can also make them, right?
No
I knew of othe generator
Now you do.
I prefer the distinction between decorators as control flow and services as happening during execution.
Okay so do you have a guide or something because it doesnât seem to be one for blueprints.
Cause whatâs do item generation from actors and do item generation
Have you done the AI with Blueprints course on the learning library?
No
You really need to start there instead of looking up random tutorials
There is a built-in perceived actors generator you can put on an EQS composite node
YeaaaaâŚ
They are trying to find objects to use, not targets. Also don't understand the systems enough to know what a generator is.
Ah fair enough. Would this be a good place to use smart objects ?
Not at their level. Need to understand the basics.
Hey everyone I need help I need help I want to make car reverse when it's stuck and get unstuck how do I do it? I'm also using pawn sensing please help me
You should really not use pawn sensing. It's been replaced by the perception system. However, you should not use it for getting stuck.
Are you using any sort of navigation?
Well I'm using spline calculations and what should I use instead of pawn sensing?
The perception system.
If you are using splines, how is it getting stuck?
Well there's an intersection so basically when the car is going to turn left and the other one coming straight they collide face to face making each other stuck because they keep detecting each other
And here's the code of my pawn sensing
Your logic is not great. Both cars will stop for 1 second and then both start driving again. There is no logic for who has the right away and you don't wait until the other car has cleared the intersection.
Well that's what happened to me I don't think it ever waited 1 sec
It doesn't move forever and that bothers
You are also only detecting when you first see something, which is one of the many issues with pawn sensing.
If its not stopping for 1 second, then you aren't even sensing it. Again, I recommend using the perception system. https://docs.unrealengine.com/5.3/en-US/ai-perception-in-unreal-engine/
But also, you need to fix your logic.
so i have an issue again. i got the mesh. but rotating seperate parts of it doesn't work as it does not rotate ai perception component
they are going to rig it and animate it so it will be a skeletal mesh even
Use transform (modify) bone node in the anim bp, get the location and rotation of a spherecollision u use for each rotation point from the BP the mesh will be in, basically just control the bones u want to rotate with the world location/rotation of spheres in ur main BP, like a ghetto af control rig
yeah but the problem is ai perception doesn't rotate
so i'm thinking maybe i need to have the static mesh of the base seperate and have a child actor for just the rotating turret skeletal mesh with ai
It rotates with actor rotation
So yea just have a seperate non rendered sphere collision
?
issue is mesh
not the collision
the base should be fixed
but i can't have that in the same actor as the turret if i use actor rotation for ai perception
or i'll have to rotate that in the exact opposite direction for that to work
Nah just have the AI be its own bp and send targeting data to the turret
U can have two child bps in one master BP
either way that's 2 actors no?
I mean yea but if it works it works
so i have base as an actor and just removed the base from the turret i currently have working and made my working turret as child actor in the base actor
the turret does work as intended but i can't seem to see it's perception debug
and i'm super confused
Okay well thatâs kinda what I meant, but more like a spotter/sniper relationship between two seperate bps, so just have an empty pawn with aiperception to send data to the turret that just points at the location the spotter tells it to
i'll have to make connections between both the bp actors in that case and i don't know how to and it's more work than what i currently have
i have it working where everything else apart from the base is in one actor
Good deal
What do you mean by logic
So if I use perception system it will detect and move on or what?
Because also don't forget there are traffic light so basically if it's red I want them to stop behind the car and not hit the car
Also I'm using ue4
I want this EQS test to prefer greater, but if i choose Linear scoring value, the value of the dots change at the same time. So it doesn't matter if i choose Linear or Inverse Linear. Anyone know why? Or what i am doing wrong?
He doesn't go to the dot closest, but always furthest away
If i turn on Reference value and put it to 0, i get the results i want, however, some locations far away get a score of 1, which i can't figure out why
Hey if I make capsule half height of an NPC Character higher than 250 the "DoesPathExist" decorator fails, why?
I've tried fiddling with the nav mesh settings but didn't work
The way you have it scripted will not work. Like I said before, both cars will stop for 1 second and then start driving. They will still run into each other.
No it didn't happen before
Mines stops forever until one of them moves the other will start moving
What other tests do you have? Did you try to look at the scoring in the visual logger like I told you to yesterday?
So yh and what do you suggest I use?
There is nothing that is going to make it magically work. You need to write logic for who has the right of way.
Do you suggest I use box collision or pawn sensing?
Neither. I already told you that pawn sensing has been replaced with AI perception.
And is pawn sensing and ai perception the same thing?
Just act like pawn sensing doesn't exist
Genuinely don't know why you're hung up on this piece of the puzzle
AIPerception replaces pawn sensing
OK
I also don't know why there has seemingly been in uptick in people using pawn sensing lately.
They watch shitty/outdated tutorials
I mean, you really have to be reaching into the depths of aged tutorials to come upon this
Like...2nd page of Google depths
Yeah but if you go to YouTube and type unreal tutorial you tend to get all the wrong stuff đ
Well yeah, you're on Youtube and you're probably watching Gorka Games
There was a few humble bundles selling UE courses recently I think
Could be a factor?
The quality on those can be a hit or miss :P
I only have 1 other test, and it's a trace test to get locations not visible to the querier. That one is only set to filter. This is the output from the path cost test, which doesn't tell me much tbh
I found out this weekend that there is also a UE "pro" course that uses pawn sensing.
Unsurprising. I'm pretty sure I've seen Epic employees retweet Gorka Games videos
Only reason I paid any attention to them being RT'd is because people are saying they are bad lol
And in the viewfinder it picks weird winners that is far away
Can you also show what the points look like in the viewfinder?
R u trying to do a EQS thing or what are u scoring
So i have a enum that sets an action for the npc ai such as Travelling, or fetching stuff from inventory or going towards an object to either work, eat, sleep, etc. that i can set with parameters in a service node in the ai tree but i was wondering if its possible to set that enum in a eqs
hopefully im making sense
This is from the visual logger and the EQS test pawn
That's... weird. What does it look like if you use the regular pathfinding, not the batch one?
The testing pawn shows good results, but the visual log show a weird winner, one that is in plain view of the player.
Turn off the other tests and show both the visual logger viewpoint and the timeline. I don't need to see the testing pawn results as they are not as good as the visual logger. Also hit P to show the nav mesh.
This is only the path test, or do you mean the trace test aswell?
Turn off all tests except for the path test.
Yeah that's this one
Looks like that one is working. I think that having the trace test be filter and score was causing problems. You can set the trace test to filter only.
Yeah that's what i've been doing. This is with only filter on the trace test.
not to be difficult or anything is there a difference between eqs and what other programmers do with doing like a npc ai thing?
The first part of the question is something concrete, the 2nd is quite broad. What do you mean "like a npc ai thing"?
EQS is used to query the environment for things. Like a place to go, an item to find, cover to find, etc...
You then use that information to make a more informed decision for your AI
sleeping, eating, etc.
and like you said place to go, item to find,
EQS itself doesn't have any behavioral logic. It's used to grab information from the world so you can make more informed decisions for your AI in regards to the world itself.
So they work together
ok, hopefully im not being rude but could you not do this is regular service node
Do what? Query the world?
get information
true
But why would you when you have a pretty good system with decent enough tooling built around it that is purpose built specifically for this?
idk just curious
Easy - need to query for information in the world? EQS is going to be what you reach for
I figured out what it was, and i can't believe it took me that long. But there was a problem with getting the target and returning the right actor to the eqs context. No wonder it showed weird stuff, it always ended up using the AIC actor. Thank you so much for the help, i think i finally can move on
Although, it still provides those random far away winners when using the batch and not just pathfinding
Why do you continue to ask this question? You seem to be searching for the "best" answer when there is no such thing. If you are completely against using the EQS, then do it whatever way that you want.
I'm a professional AI engineer with over a decade of experience, most of which is in UE. I'd use the EQS, because that's literally what it's built for. If you don't agree, then do it however you want.
Because my brain canât decide, and whts wrong with asking questions
That's called indecision paralysis. It's a good way to not get anything done.
Or my adhd acting up but yea
Can the EQS trace test, test the entire mesh and not just center?
You would need to implement a custom test for that I think
There's no simple way to test an entire mesh to begin with since you can't exactly trace to every single point on it in a reasonable way so how you want to handle that is kind of up to you
Yeah, that's what i feared. Custom test is doable tho. Maybe add a buffer sphere to get the AI enemy all the way behind cover, and not just halfway there
I made it into a BT task and chose the second location picked from the returned array, which works pretty good!
is there a way for eqs to switch actor classes for an action, for example if the npc is sleep it will change to bed, hunger change to plant or something, work to workstation, so i dont have to make a eqs for each one.
Hard to tell unless you give specific examples. But EQS can be generated around and tests can be performed on blackboard values that you set in other functions or in the AIC
Anyone able to help here
for some reason wether the AIState changes to Combat for example the behaviour tree won't move to other one
Text too small, can't read anything
this is bassically what I have these sequences coming from a selector
combat is most left, invesitgating mid and right patrolling
its kind of working it's just bit wierd as it's waiting to complete it's task before it'll abort out of the branch to run the combat one
even thought the decorater is bassically saying it shouldn't be doing anything in there
Tried setting it to abort self instead of lower priority? Idk, i'm fairly new to BT
nope not working
I'd look into where you are setting the states
Or are you setting the states in the tasks?
sorted it
I have Lock AILogic ticked
it ends up locking anything happening until it's done it's move to thing which is good but not for my case haha
like how do you change the search actor class procedurally in the actor of class node in eqs depending on the situation or get a child class of that class in a situation
In my case i assign a target in the AIC, and i pick that target so i can make it the context i want, like this
Look up the AI tutorials from Ali Elzoheiry on youtube, they are pretty good
Why are you trying to force your BT to act like a state machine?
You make your own generator.
What you mean, that's how I've always used it
I think it's because BT is not suited for setting states
I'm confused I'm not setting states?
The decorators are just blocking entry into it unless the enum state is set correctly from outside the BT
There a set bb key thing in there but that's to basically force it to go through a particular way
The enum what now?
I have an AIstate enum that's all
Sounds⌠stateful đ
That it is
I didnât think to do that dammit
And i did it somewhat but with set variables not get
You are setting states. You are forcing the BT to act like a state machine, which is really common for people inexperienced in BTs. But you lose a lot of the benefits of a BT by doing that.
How can I make AI path through other pawns? I've turned off Can Ever Affect Navigation and set collision to ignore pawns on every component, but they will still try to path around eachother rather walking through eachother.
They aren't pathing around each other, unless you added some horribleness to it. You likely have RVO on or using detour.
Detour was what I was looking for thank you
Hello everyone, I'm implementing the node blueprint "Simple Move To Actor" but an error like this appears, and the target character doesn't work.
UNavigationSystemV1::SimpleMoveToActor called for NavSys:None Controller:None controlling Pawn:NULL
Does anyone know the solution?
thank you, please help.
In terms of I'm simply resetting a value to ensure it goes into a specific place ?
Everything else is being set outside of the BT so in the controller each
Apologise from my part but I'm struggling to understand how I'm using BT in completely wrong way which is what your kind of pointing out
Is it possible to place an AIC with AI sensing on the player character? I want reactions from when the player is seeing certain actors
I tried, but it's not posessing or updating on the percetionupdate event
It's possible but complicated
You can use an AI controller to possess the player pawn, the player pawn is just a regular pawn afterall
But you can't have the player also possess it at the same time, so if you want to control it, you would have to set up some kind of system where the player "controls" the AI controller
Hi, I'm learning StateTree. So far i understood everything, but one thing bugs me: How can i enter the leaf states AFTER the parent state succeeds/fails?
I need to run a query first before going to leaf node, so i can access the OUT variable that's a Location the query found (and the query works asynchronously so i don't have the requested location right before going instantly into leaf states).
I guess it shouldn't be the leaf state but a sibling, but then i can't bind into the value from the querying state.
I tried Changing Selection Behavior from "Try Select Children In Order" to "Try Enter" but it behaves practically the same way- the "Go to queried location" state is getting entered before the query finishes.
The result is the Player going into location 0,0,0 and Aborting the previous move to request.
Doing something like that is kinda complicated with ST's unfortunately
It would indeed be easier if you could just have it as a sibling state, but there's nowhere for you to put the results in that case so it would be accessible for the next one
It might be possible for you to set it up so that you add a "waiting" state before the actual state, where you have a task in the waiting state or transition which keeps checking whether the value is set
Ohhhh okay, i think i have an idea how to solve that! As you said, I can make a leaf node that binds into the query and Succeeds/Fails when the Query finishes!
Yeah ok. I think i'm just gonna use pawnsensing for this then
Hello everyone, I'm trying to use Simple Move To Actor, well my BP is Pawn.
When I run it an error appears, namely "PIE: Warning: SimpleMove failed for AIController_0: movement not allowed" can anyone provide a solution? Unfortunately I don't want this pawn to change into a character.
Or is that the only way? thank you.
Okay, now i'm confused.
-
EnterState won't even trigger on task in B if the task in A doesn't succeed. I thought that by default states that aren't leafs just execute their tasks, but they select the child states regardless of the task state
-
The whole tree behaves like it executes on tick, B gets called basically every frame (when A succeeds), i want B to "stall" the tree logic and not transition until it gets to the destination, but it doesn't work like that , the logic kinda goes back to Root the moment you enter the state
A isn't latent in any way, it just checks actors currently percieved actros from AIPerception
Have you looked into EQS? If you simply want to move an actor based on states or triggers
if one of the task finishes, it will try to trigger a transition I think, so, does the task A call FinishTask somewhere in it?
Yeah, it does, if it finds a percieved actor, it finishes with success, if it doesn't find, it finishes on fail
if it is one of the tasks that are just along for the ride, you don't have to call finish task
in this case, the go to task should call it
I think that way, the state tree will wait until the move to is finished
oh, okay, gimme a sec, i will test that
Sorry i'm newbiew, what is EQS?
I said wrong, Behavior Tree (BT) is what you want to get started with. EQS is a querrying system for the AI to gather data from the environment. BT and EQS combined can tell where pawns/enemies should go. I highly recommend to check out Ali Elzoheiry's youtube tutorials on "smart enemy ai"
I'm attempting to 'drive' (without simulating 4 wheels) an actor between different locations in my world (drive actor within firing range of other actor). Originally I tried dumb logic, now I am turning towards trying to use AI. So looking at a few approaches (c++ oriented):
2. Approach 2: AIController + *MovementComponent --> maybe there is some way to of using these in concert: (AIController->SetControlRotation(x), and movementComponent->SetMinSpeed() (its odd I see GetMaxSpeed() documented, but no way to Set it? wtf?
3. Other, lots of movementComponents include NavMovementComponent, again I suspect this does not magically handle turning for me.```
any Thoughts/Pointers as to the flaws in my approach?
Yeah, that fixed all my problems! Thank you!
Np
You are not guaranteed to have possessed the pawn at begin play.
What I done wrong here
what I've trying to do is that it's do the FireWeapon Task but also run the sub tree at same time
if I set immediate it bugs out and the sequence there sticks on the move to location
if I set delayed it obvs does the sequence and then fires the paralel task
Is the fire task returning immediately?
Your service to find a move to location is not going to find one by the time the move to task starts. Services start when the branch below starts and the EQS doesn't return immediately. You need to use an EQS task to find the first location and then a service to update it.
oh
thats kind of make sense then cause if I use the delayed for the paralel then it works fine like the move to location and then wait
having immdiate at the min is not letting the move to location move on wait, but you've explained why thats happening
Delayed isn't always going to work. The EQS is time sliced, so if you have a bunch of AI using it, then it might take a bit to finish.
so could I remove the service completly you think and just do a task for eqs ?
Does the target move? If so, then you need the service on the move to task to update it as well as the EQS task.
Why are you messing around with "states" btw? IE - AIState.
BT is better used as a priority selector. So behaviors that take the highest priority are the furthest left. And you gate that stuff with decorators.
so the target does move yeah but tbf I wasn't going to have it redo the EQS maybe unless the player can't be seen or something like that
what you mean I'm not messing around with States I removed that and moved it to the AI Controller
I already tried to explain that hah.
and I made adjustments haha
Looks like you're still using it
so it's literally just a gate to stop it going into that unless the Enum is Combat
in terms of setting it etc thats being done outside of the BT
Yes. So you're still treating it as a state machine pretty much
I'm so sorry but I literally don't understand what I'm doing which isn't right
from most of stuff I've seen this is literally what I've learnt in terms of ways to block going into that branch
as well as other ways
You can literally just remove this decorator and only use the "Can See player" or w/e to gate this behavior
so that won't just work
Then, depending on the priority of the behavior, you arrange it in the tree appropriately.
can't rely on simply can see player to protect AI going into bits
Lots of tutorials show this way of forcing the BT into being a state machine, doesn't mean it's right or even good.
Obviously I don't the exact specifics of your project or requirements. But right now, you're not using the BT correctly.
okay so what other way would you suggest I gate the entry into that then
obvs if I remove the Enum thing
The crux of the issue is that you are gating behavior based on state. Which means you are using both a logic state machine & BT
but I'm confused here then cause how else will I gate stuff
While, not wrong in of itself (you can certainly combine multiple AI designs)
if I remove the enum
It's how you're doing it
By using other decorators to gate it?
IE - "does have ammo" or "is within range", etc...
well can see player but obvs can't soley rely on that
right I get you know
and I'll be honest I will prob do stuff like that
further down the line
There isn't any way is there to like have two brances going at same time ?
like I know the parallel allows a main task and then other stuff but I'm thinking it might not work well for this situation
I'll be working enum out the situation as well now I got a better understanding but yeah any ideas on this one
would it be good idea for it to like run another behavior ?
like Weapon Behavior or that just going to far where it's not needed
What are you trying to achieve by running two in parallel?
What behavior are you looking for? Not how you are trying to achieve it, but what is the AI supposed to do?
well currently I have a fire weapon function which if they have no ammo will reload the weapon
Obvs with that does have ammo there it don't call the fire weapon cause the reload isn't happening to allow fire weapon to happen
I could use a service maybe to check if weapon has ammo but
if you mean the sequence to the right, that is the moving enemy changing it's position
Also - why do you have a custom move to location task? What wasn't working with the built in one?
Depending on how the logic works I don't know why you would need to have parallel for shooting/reloading and moving
If it's possible for the character to do both at the same time, then you could let it
There was some stuff i added to it initally so made my own
I to be fair may return to the inbuilt one to be honest as slowly I'm using less of the stuff I added
so thats what it was doing
as in the fire weapon was reloading if it needed
but obvs with whats been mentioned above about moving away from using the Enum for a gate I'm finding the function will need to be seperate
like in the BT
I feel like when I query the Navigation System with Agent Properties, they are being ignored, as I am getting nav points that collide with that supplied radius? what am I doing wrong? here is the sample colde: ```ANavigationData* navData = navSystem->MainNavData;
FNavAgentProperties AgentProperties;
AgentProperties.AgentRadius = 250.0f; // Adjust based on your agent's size
AgentProperties.AgentHeight = 150.0f; // Adjust based on your agent's size
FPathFindingQuery query;
query.StartLocation = GetActorLocation();
query.EndLocation = final_loc;
query.QueryFilter = navSystem->CreateDefaultQueryFilterCopy();
query.NavData = navData;
query.SetNavAgentProperties(AgentProperties);
query.NavData = navSystem->GetNavDataForProps(AgentProperties);
FPathFindingResult result;
result = navSystem->FindPathSync(query);``` Any ideas what I'm doing wrong here?
That isn't what I asked. What is the behavior you are looking for? Not how you want to/have it implemented. You are asking for help to structure it, but I can't help you unless I know what you are trying to accomplish.
sorry, so the behavior is the AI moves to points given by EQS and if has ammo but obvs can see player fires the weapon
also if they have no ammo they retreat to a location which is in cover whilst reloading
So the AI shoots at the target. Reloads when it is out of ammo. Tries to find a location to shoot at. Shooting while moving, if it can. What else does it need to do?
for this type of AI it would also need to investigate so when loosing sight theres a percentage for it going to last seen location to investigate.
@uneven cloud Curiousity question - so, I use decorators as a simple bool check in like 99% of scenarios, IE - the bb key valid one or w/e it's called. What's the most interesting way you've utilized a decorator outside of that?
I've got that bit already on a branch of screen which is higer priorty then roaming but under priorty to the combat stuff which is what I'm putting as my container as it were
I use a lot of BB key decorators as well, but also use my own which directly checks for things.
Give me a bit and I can mock something up.
no worries, appreciated. It might solve this issue I have with the Parallel
I also use a lot of decorators that access actors directly, but I think the most "interesting" use I've had is ensuring that when a branch of the BT exits, the actor goes into a certain state
Although I've not really decided whether that would be more of a service thing
I put that as a service, but only for clarity
A vast majority of the time, I'm just smoothbrain about it and like "bb key is valid" and don't even think about what else I could do with them đ
Because we are using a utility/BT hybrid a lot of things are driven by the utility state. So it sets a lot of the BB keys.
Yeah, I've seen some use cases of decorators being what provides the score to a utility system
That's not how I'm doing it, but that is a valid way to do things.
This is where I would start with the structure.
what would the update location service be out of interest ?
EQS service. The target moves, so you should update the AIs move to location as the target moves.
ar right okay got you
Guessing that would be a service on the move to cover task ?
Now for the more important question - what program did you use to whip that up?
That is really purrty
Miro.
Yes.
and the code within that bassicaly be same as what my EQS is doing or not ?
I could have made it prettier, but I'm a bit lazy this morning.
it shows what it needs to haha
I know you prefer to use a service to update the location during the move to task - but is there a particular reason instead of relying on the Observe BB value for the Move To node? I use the latter and it has worked out fine for me personally.
Just curious if there is some gotcha that I am unaware of or some edge case, etc...
Probably? Depends on what your EQS is doing.
As opposed to what? You need to update the BB for observing the blackboard change. I put the service only where it's needed. Higher up and it's running when it doesn't need to be.
You can put a generator on the left to get the current move to location to validate it. So you aren't always generating a lot of points.
In the Move To task, when you select to observe the BB value (or w/e that field is called) if the target actor is moving, it still correctly moves to the actor. So you'd have, in task order, "Find Location -> Move To (location) -> Wait". Or if you have the actor as the thing to move to, it'd just be "Move To (actor) -> Wait". Parenthesis represent the BB value btw.
And if either of those values change, Move To updates its target destination correctly (at least in my tests).
this in the BT graph or on the query EQS thing ?
EQS - generators are EQS things
Moving directly to the actor is gross. It gives you really bad behaviors.
i just tried looking for generate but couldn't see one unless im blind
found it
Generator is a class used by the EQS, which you can make a new one.
So you mean like this ?
No. You need to make a custom one for the Move To Location
ohhh
found it and i'm guessing I simply take in the current location and spit out a new one or ?
you'll have to forgive me never made my own generator before
like ever haha never went into that area tbf
Sure. But my main question is...okay wait - I think I understand your flow now.
You need a service to update the target position because you pretty much always pick a location to go to (instead of Actor or location). And you use EQS to pick that location. Now, that location obviously won't change when the actor moves even though it is based on that actor. So you have to rerun the EQS to always have the most up-to-date location.
If you are moving to a location, you have to update the location somehow. I prefer updating using the EQS so they can be smart about it.
Right right
I fully processed the flow as I was typing my reclarification of the question đ
So what I doing in here ?
You can do frequent EQS with a bunch of AI. It's time sliced.
First of all you don't need it that fast. Human reaction time is slower than that. Otherwise it depends on what your EQS is doing.
Yeah, I know. My question was specifically on why Luthage prefers her setup. I know about all this stuff and how to use EQS and etc...
Always take the opportunity to poke the brain of a 10-year veteran đ
Then you need to turn on use acceleration for paths.
Faster updates is not even remotely needed. The zig zaging shouldn't be mimicked.
guys i use the node move to of ia and the IA does not move even when i setting up everything what is the cause of this?
i test with a cube and the cube just go to the ground and no move around anymore
yes
i press P to debug
yes
the cube moves one time
but my character does not
the cubes move to the ground and stop not move anymore maybe is the Z of vector?
the character i use character default the cube i simply create a pawn and append a movement component
the cube yes move to the point but him dont have a gravity
this 3 character even when i use one of them nothing happens
That depends entirely on how you set it up. You also need to tune the acceleration and declaration values. The default is really high.
the behavior tree is the most simple as possible
Use the visual logger to see what errors it is throwing.
oki
They don't move that far when decelerating. Don't over think and come up with problems that might not exist.
Wondering if anyone here has actually gotten the NavigationSystem findPath* methods to actually honor AgentRadius in its queries? looking at the source this does not seam possible (source code does not appear to honor the passed in values), rather it looks like the only AgentRadius supported is the one defined by the actual NavMesh (recast). NavMesh Modifiers, but I have not looked into that yet, as that doesn't seam useful for my usecase.
Does this not work? Trying to update the location while it's walking there in case there is a better location
Hello,
I'm using a detour crowd ai controller for my ai. I recently made some smaller ai spiders that I want other ai (including the spiders themselves) to be able to walk/path through, while retaining the detour logic for all others. Is this as simple as using a different ai controller base class or is there another method I should be going for?
I think thats the same as using the run query task isn't it ?
just wondering
No, query task is a task of its own, the service can run simultaneously as the task
If i run the query after move to, it will finish move to before running the task
arrr okay see I though the service task was like same as the task so you don't save anything doing the service task
But i am seeing what the issue is. The move to function doesn't look for a new updated location, and it doesn't seem to have an update function while it's running
It looks like I could SuspendCrowdSteering but that only works for the spiders themselves, other AI will still try to path around them.
Just don't use the crowd controller on them
The detour crowd controller registers them with the crowd system, if they aren't registered, then they won't be avoided
unfortunately changing the base class for my ai controller is a big lift at the moment, is there a way to unregister them from the crowd system?
Yes, but not sure if it's exposed to blueprints
You can register and unregister through the crowd manager https://zomgmoz.tv/unreal/Crowd-Avoidance/UCrowdManager
I guess it depends on how much code he's got in there :P
Anyone know best way to stop a behavior tree completly log not even have it run anything ?
currently trying to use Stop Logic function on the AI Controller but Behavior tree still appears to be running
So don't wait a second to update. That's not hard to tune.
The navigation system finds the best nav data to use based on the agent properties.
It shouldn't be but thats what you get for using a plugin off the marketplace. Theres a lot of casting to this specific controller for BT Tasks and EQS queries. Maybe I'm not thinking about it correctly but I would need 2 ai controller classes, one parented to the crowd controller and the other parented to a plain ai controller, and then replace all casts to an interface function or something.
I've made this function to unregister an actor from the crowd manager but I can't get a reference to the UCrowdManager class (Identifier "CrowdManager" is undefined)
void UMyFunctionLibrary::UnregisterActorFromCrowdManager(UObject* WorldContextObject, AActor* Actor)
{
UWorld* World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
UNavigationSystemV1* NavSystem = UNavigationSystemV1::GetCurrent(World);
if (NavSystem)
{
UCrowdManager* CrowdManager = NavSystem->GetCrowdManager();
if (CrowdManager)
{
CrowdManager->UnRegisterAgent(Actor);
}
}
}
Is there another import I need besides #include "NavigationSystem.h"?
In the move to node there is a check box for observe blackboard. You need to turn it on.
No you don't. The builtin crowd controller doesn't really do much. You can make a child AI controller class that adds those bits and inherits from your main one.
in blueprints?
any references to the "bits" it adds that I can replicate?
No. You posted code, so I assumed you knew enough C++ to do it.
The ai controller I'm using is in blueprints or I would
Gross
The crowd manager needs to be included
@uneven cloud For the Navigation system to use the best nav data based on AGent properties it needs to look at the agent properties...if you follow the the function, it doesnt actually look at the agent properties associated to the query!
Yes it does. There's a function called something like FindNavDataForProps.
I was having trouble finding the path but #include "Navigation/CrowdManager.h" seems to work. Now I'm stuck on UnregisterAgent which expects a ICrowdAgentInterface* as the argument. Is this expecting the character pawn to remove or the controller?
Controller.
How do I convert that to an ICrowdAgentInterface pointer?
You shouldn't need to
I get the compile error: argument of type "AActor *" is incompatible with parameter of type "const ICrowdAgentInterface from this line: CrowdManager->UnregisterAgent(Actor);
@uneven cloud The function is navSystem->GetNavDataForProps(AgentProperties); In my use case it ignores the AgentProperties entirely, apparnetly because my NavMesh fails this test: if (SupportedAgents.Num() <= 1) { return MainNavData; }
but regardless of that, the next logical call after that, is to perform the query with the AgentProperties, the problem is the findPathSync (never acctually refers to Query.AgentProperties that I could see).
Is there a config to flag the NavMesh to support multiple agents?
Because you don't have multiple nav data. You need to set them up in the project settings in the supported agents array.
Would it work if I just cast the actor? ICrowdAgentInterface* CrowdAgentInterface = Cast<ICrowdAgentInterface>(Actor);
I thought that it implements that interface, but I'm not sure. Looking things up.
You need to get the path following component from the controller. That's what implements the interface.
@uneven cloud ahh, I was not aware of the agents array đ thanx for that tid bit.
When performing the Query do you specify the 'Agent' by name?
and/potentially build out different NavMeshes based on the agent properties? like if the radius is significantly different?
You're welcome. It's weirdly hidden. Nav data creates a lot of data, so don't add to many. I usually bucket them into small, medium and large. You do have to make sure that the radius is > than your largest radius of the agent in that group. Not equal, but greater.
UPathFollowingComponent* PathFollowingComponent = PFC;
CrowdManager->UnregisterAgent(PathFollowingComponent);
Returns the same error
argument of type "PathFollowingComponent *" is incompatible with parameter of type "const ICrowdAgentInterface *"
The navigation system finds the best fit agent based on the agent settings and properties in the movement component. By default it uses the capsule radius and half height for the agent props. So you don't need to specify anything in the query.
Maybe I need the CrowdFollowingComponent?
iirc the controller is the crowd agent so you need to cast the controller to the interface
one of them certainly should be
According to the documentation it's the path following component.
@uneven cloud hrm, I have no 'movement' component atm, atm I'm simply err moving the agent myself based on the returned path. (since I need the agent to NOT snap its controlRotation).
oh, might be, been a while since I looked at it
Probably need to include the crowd path following component.
You can do that in the movement component. There's a rotation rate that smoothes it out. But if you really want to make your own, you have to make a movement component that derrives from the nav movement component.
RotationRate is only available on ACharacters I believe.
Oh it's a pawn?
yeah, a 'driving pawn', but I'm not using the built in vechicle stuff, not trying to simulate a car...
so for not, I'm primarilty looking for the path with a 'large enough' radius to ensure I can turn the vechicle
I'd still move that functionality over to a nav movement component or a pawn movement component.
The way you are doing it is going to need a lot of redoing a lot of work already built in to the engine
I'm still doing collisions tests during movement, and will fetch a new path if its hits a another pawn..thats was my reasoning, but I do think I likely need look into the DetourCrowdAvoidance stuff
Yeah, you really should avoid doing collision tests while navigating.
yeah, I think tomorrow I'm going to try and switch my test project and do some tests with the Crowdcontrol, but still not sure how that will work with my having to turn the actor.
If you have source, I'd look into how the CMC does the rotation rate. It works really well
I will take that into consideration đ
Ahh - another satisfied customer from Luthage
Straight holdin' down the fort in #gameplay-ai. Answering multiple people's questions/problems.
I think what has me a bit befuddled, If I have an Actor, and that actor has a AAIController on it, how does the AAIController know anything about the MovementComponent? Does it query the Actor for all components, searching for a UNavMovementComponent?
Indeed, shes holding multiple conversations at once đ
She*
I have a really wierd thing happening where my AI seems to continue out the task even though on Behavior Tree is clearly shows they should be doing something else
indeed, I'm learning new things đ
Can I flip these around ?
the Move to and the fire weapon so I can have a wait once it reaches the move to location before moving again ?
I got my function to compile and run but if I unregister the agent from the crowd manager the ai no longer moves đŤ¤
That's what I do all day at work. Doesn't add much effort to answer here as well.
The path following component caches off the movement component. So it does know about it.
still very much appreciated
This feels like a odd question, but..When I create an AIController in the UE editor, I see it comes with certain components, but I do not see a movementComponent by default (rather UNavMovementComponent) included, I also do not see a way to add a NavMovementComponent where does this actualy exist? (I see an InterpToMovement with a 'tag' see UMovementComponent)
You need to set up an observer abort on a decorator to abort out of a task.
Wait, PathFollowingComponent Caches of the MovementComponent (the one presumably added to the Actor?)
You can add a wait after the move to and use a simple parallel for shooting with it.
The movement component should be added to the pawn, not the controller.
Yes. That's how path following works. It moves the pawn via the movement component to follow the path.
Got it, u mentioned earlier (since I don't have a Character, even though maybe I shoudl just make my 'car' a character), that maybe I should use someting based off of UNavMovementComponent, but looks to me there is no way to add this directly in the UE editor? I suppose if I create a c++ class using that as the base, then I can add it....
ohhh so I could do this on the can see target then as thats gonne be the main thing for now which will stop it patrolling
So I can swtich them around then and stuff should work correctly still
Yeah, you need to add a C++ class. I don't think I would recommend making a car a character though.
what the wheels were legs? đ
What do you mean switch them around? That's not what I said.
well you can only have one thing from the pink tab
Characters use a capsule component as the base, which doesn't fit with a car.
mainly a task but from the grey tab you can have sequence etc
I would not make shooting a main task. So no, I didn't say you can switch them.
ok, I think I have the direction I need to start playing with custom Movement component attached to my actor, and controller by the AIController, đ thanks much for the pointers.
so how would I put a wait after the move to when you can only have one task from the pink tab on the parralel
It's a sequence. Find a location, move to (and shoot while moving), and wait (shoot while waiting).
you've thrown me off there
So this is what I have
the way I understand what your saying is have another parallel next to the one I have with wait as the pink and shoot the grey connection ?
Any ideas why UAITask_MoveTo::AIMoveTo would stop working after calling CrowdManager::UnregisterAgent for a DetourCrowdAIController?
Yes.
awsome I've done that
maybe I just thought having multiple Parallel node on one sequence was good idea
This is why I wasn't a fan of just using the same AI controller and unregistering. I don't think it'll work to have a crowd path following component and not use crowd path following.
Gotcha, I saw on the CrowdFollowingComponent there is GetCrowdAgentGroupsToIgnore, is that something I could utilize for this? Any docs/articles on how it works?
Have you tried Google?
at first glance and assuming from mikko's code examples in the engine it looks like a bitfield
groups are packed into single int32 and operating are done via bitwise operators
though its very late at night and have to sleep, have no opportunity to dive into codebase and confirm that
nevermind comments confirm it
That's where I started, great suggestion though
I'm just confused about how to set these exactly. It seems like you set the avoidanceGroup on the actor that you want to avoid (ie my spider controller), and set the groupsToIgnore on all other actors. I'm not really sure what "groups are packed into single int32" means exactly or how I should be setting what I would normally expect to be an array.
an integer is 4 bytes, so 32 bits
you can put values into each bit with c++
this is both because its more optimized (cache coherency on CPU) and easy way to see if something exists or not in C++ realm
it expects you to imagine each 32 bits as an element, i.e. a group
group 0 is A, group 1 is B etc.
there is a special syntax to interact with bitfields
but I expect there is a helper function in the engine to set and remove groups
tl;dr imagine that int32 as a static array that its size fixed to 32 and each element points to a group. You assign a group to detour agents and detour controller check if the bit you assigned exists within int32's bounds or not
this is a very fast operation to array lookup which is something like path following system should implement, thats why its not an array
Thank you for that explanation, I think I'm beginning to understand. I'll probably need to walk myself through a visual representation to fully grasp how that works so if you know of any resources I would appreciate it but I can probably find something on Google to help illustrate that at least.
I'll look for those helper functions too, good idea
i remember a completely random video visualize this for a few seconds... even though its not related directly đ
there was an YT channel analyzing AIs in games
dont recall its name
they have a half life 1 AI breakdown
where there mention this bitfields
and how they used in state machines etc
other than that random thing, not much that I remember
Thank you for responding, sorry for the late reply
So I just need to move it from begin play to another one, right?
I found it really helpful to draw it out when I was learning it. Each bit represents either a 1 or a 0. Where 1 is on and 0 is off. So 1 = 1. 2 = 10, 4 = 100, 8 = 1000, 16 = 10000. On up by the power of 2.
Since we are talking about an unsigned 32bit int 1 actually looks like this:
00000000 00000000 00000000 00000001
And 2 is:
00000000 00000000 00000000 00000010
Let's say I want to ignore group 1 and group 2. That would put a 1 in both the 2 and the 1 spot. Which looks like:
00000000 00000000 00000000 00000011
Technically that int now equals 3, but since it's a bit flag, we do bit checks on it instead.
Is the YouTube channel AI in Games?
Looking at it again, what is the object you are calling this? What is the owner?
I figured it was a typo.
BP_akila1 is the owner
Nah, I had misremembered the name.
it's BP for BP_Patrol, be a component
I take you are making your AI with states as components?
That's right, because I want it to be implemented in other AI, not just this Akila.
Your states really need to wait to start until the controller says it's OK to start (On Possess). I would recommend that the states also be on the controller and not the character.
Controller is the brain and does all the decision making and Character is the body that does the actions. It's a lot easier to do things if you keep the separation.
States also generally follow an interface of OnStartState, OnUpdateState and OnEndState. So your moving to should be in OnStartState.
Could you provide me with a reference or a video to learn this? I think because my knowledge is still limited, I am still confused about processing your answer.
Actually, the goal of what I am creating is if the player touches the trigger box, then the AI ââwill walk to the same trigger box.
I highly recommend going through the AI with Blueprints course on the learning library. It will go through all of the AI systems. Like what an AI controller is.
You can also Google a Finate State Machine if you want to keep going in that direction.
OK, thank you very much.
Have a nice day.
So after reading up on the CrowdFollowingComponent and realizing the Avoidance variables on the component are deprecated, I was led to using RVO and their avoidance system which includes the same GroupsToAvoid, GroupsToIgnore and AvoidanceGroup variables all on an interface inherited by the CharacterMovementComponent and included in blueprints. Works like a charm, thank you @uneven cloud and @celest python for your guidance.
Although after watching https://www.reddit.com/r/unrealengine/comments/9jdb8u/detour_crowd_ai_controller_and_rvo_avoidance/, I might like detour better with how it rotates the character so I may attempt to implement this on the detour controller in c++ as well
So yeah, I exposed these functions to blueprints and got it working for detour too:
void UMyFunctionLibrary::SetAvoidanceGroupForCrowd(UCrowdFollowingComponent* CFC, int32 GroupFlags)
{
CFC->SetAvoidanceGroup(GroupFlags);
}
void UMyFunctionLibrary::SetIgnoreGroupForCrowd(UCrowdFollowingComponent* CFC, int32 GroupFlags)
{
CFC->SetGroupsToIgnore(GroupFlags);
}
void UMyFunctionLibrary::SetGroupToAvoidForCrowd(UCrowdFollowingComponent* CFC, int32 GroupFlags)
{
CFC->SetGroupsToAvoid(GroupFlags);
}
FNavPathSharedPtr
this doesnt look correct
you should set int32 to BitMask on UFUNCTION meta
iirc
very likely, yeah
Good Morning all, trying to get my new AI Agent/Car working today. I have setup an Actor, AAIController, and UCarMovementComponent (extending UNavMovementComponent). I have verified, all 3 are created, and for now my car's eventgraph will drive to random point on the map at game start. I see: RequestDirectMove() being inovoked, and I can apply smooth rotation,a nd my cube rotates nicely. What has me a bit confused, is, should I also move the car here? (makes sense to me), but I'm also seeing that maybe movement component should be doing that already (well thats what chatgpt says)? even though it is clearly not moving, only my rotation is being applied, hence I'm guessing I should in fact be doing setActorLocation..yes?
which I guess is fine, I've already been doing this in tick, just makes me wonder what I'm really gaining vs just using the AI to get the path, and having my tick do the move/turn.
It still works but I think with this method you can only set one group, what would it look like with your method?
Hey! I'm working on navigation, my goal is to be able to add custom shapes (polygons) into the navmesh at runtime.
I am looking into nav modifier volumes/components, from reading the source code I get the impression that, in order to function properly, the brush has to be set in editor, I don't see an easy way to set it at runtime.
I think I can also set the area class for collision components, but those are limited to boxes, capsules etc.
I managed to do it, for the record:
The simplest way I found was to have an invisible static mesh component, whose static mesh has IsDynamicObstacle set to true, and then specifying a custom nav area. The static mesh component picks it up and modifies navigation accordingly. Very handy đĽł
I have a RecastNavMesh, if I set my Agent Radius to 5 it seems to correctly make a path inside it, but using dynamic runtime generation it always disappears. Any tips?
Hey! I'm trying to get a grasp on Behaviour Trees.
How do I interrupt a MoveTo? It seems to lock the Selector or Sequence until it has reached its destination.
En enemy generally needs to have a general destination, like a patrol route. But then, when it spots the player, it should chase the player. That's about what I'm trying to achieve.
I've tried achieving this with decorators, but it doesn't seem to be interrupting the moveto when it is already in progress. Is there a standard way of doing this?
Most tutorials I can find always allow the move to to finish. Usually by moving short distances at a time.
One way to do it is by setting the NotifyObserver to OnValueChange and ObservorAborts to Both on your decorator. Then you set your blackboard keys and whenever that value updates, it will check if it still matches and move on to the next decorator if not.
Which brings me to my issue, I'm trying to debug this EQS Query but am not sure where to start. Why would it be failing and looping like this? This works for some ai and not others.
Oooh! I didn't know you could do that. Giving it a try, thank you so much! đ
You need to create a supported agent setting in the project settings.
Use the visual logger to debug
I didn't know about that, thank you.
LogEQS (VeryVerbose) Executed EQS:
- Name: 'EQS_FindRandomLocation_RandomBest25Pct' (id=0, option=0),
- All Items: 0,
- ValidItems: 0
Does this mean it's not finding any valid locations?
As you can see it's not finding any items at all.
is there a way to work with behavior trees in c++ (im guessing the answer is no)
The answer is always yes
The engine is built with cpp
yay
Whether you should limit yourself to not having visual scripting is another story đ
true lol
hey guys, I'm currently trying out state tree with linked state and subtree. Since state tree can only have up to 8 active states and if I understood it correctly, using a linked state will cost an extra active state compared to simply duplicate the states in the subtree?
So I have a Behaviour tree and a blackboard, for my NPC, and i want the NPC's first action to be to move to location X. Indicated by a TargetPoint in the world. Now, since this is such a simple task, my idea was to just use a Move to and then use a blackboard key for the casino entrance. But how do i make that blackboard key correspond to a spesific actor in my world? Is that possible or am i going about this entire thing incorrectly?
my initial idea was to do something like this, but i still need to get a reference to that spesific actor in my world
Which object is this? The npc or the casino thing?
Does anyone know how to get the result enum from this node (On Move Finished result)? Or is the result only available from C++ and I have to make my own with multiple exec nodes for each result (Success, blocked, etc)?
Why do you need the exact result?
Why do you think it's not efficient?
BT stuff should not be in begin play as you are not guaranteed to have a pawn yet. Move that to On Possess.
I needed to know when AI was blocked and by what. I ended up creating a multicast delegate and using OnMoveBlockedBy from the PathFollowingComponent
that's in the AI controller that the NPC uses
getting all actors of tag instead of just having a reference to the object already just sounded really inefficient in my head, but now that i think of it, it might work out quite well
I mean, getting all actors is kinda overkill yeah, but you only have 1 actor of it so eh
Get all actors of class is fine in a lot of situations. Get all actors with tag not so much. While I haven't looked at what the code does exactly (don't bonk me Luthage!) - I'd imagine it pretty much just checks the bucket for Actors (so every actor in the world) and then checks each actor if it has the passed in tag
That would be my assumption also, but I don't think it should be worse than using get all actors since the tag comparison oughta be pretty cheap
although it does seem the fname based tags is a legacy feature and should be replaced by gameplaytags
It would be worse - iterating over potentially 10k actors is more expensive than iterating over 10
Ah true, if it doesn't have a class filter then definitely
I checked - that function doesn't have a class filter đ
do behaviour trees loop forever by default?
Yeah. Iirc there is a "single run" mode for them but I don't recall if that's available from BPs
Ait thanks!
The path following doesn't know what's blocking it. All it's checking is if the NPC hasn't moved in x seconds.
It kinda does if you implement the OnMoveBlockedBy interface đ. I did, and it works
It is also taking in a class. So if you are checking all actors, that's potentially bad. If you are checking all actors of a specific class that you have 5 of, not bad.
This is what I saw when I made my comment
I see no way to filter for actor class.
The one I was replying to is using a different node that does take in a class.
Ahhh
Get All Actors Of Class With Tag is the node.
Ah - I don't think I've even seen that node
It can be inefficient if you have a lot of actors of that class, but you have to get a reference to that actor somehow.
Does RunBehaviourTree reset the blackboard if the tree were already running?