#gameplay-ai
1 messages ยท Page 57 of 1
Hey guys. Any idea why RVO avoidance is not working with my npcs? I don't know what to try anymore, they keep bumping into each other and they get stuck. I can't get on with my game with the npcs like this
You're gonna need to show your RVO settings and more info
You can also try crowd avoidance, sometimes it works better
Ohh I didn't think about using GAS! thank you for the suggestion ^_^
Hey! I'm trying to get my head around Behaviour Tree by moving what I've already done to different tasks, but I've got a lot of component references. What's the best way to deal with that in a task?
Depends on what exactly you mean by component references, and what you are doing with them
For instance, I have a reference to a Rotating Movement that I enable or disable when needed, but if I simply copy/paste that in a task, it won't work cause there's no Rotating Movement component there, and I'm not sure how to get it from the Event Receive Execute AI
Cast the pawn you get from the receive execute
Of course... Why do I keep forgetting about these simple things? x) Thanks !
Anyone know why I can't use the Smart Object Subsystem in my Object Blueprint? I'm trying to allow my action class to access it so I can make a consideration for if it can find food.
Okay so I might of solved it, I just need to make a function inside the AI's controller that then uses the subsystem to call Find Smart Objects :D
I believe you need to use an actor to access world subsystems. I don't think objects have references to the world, which is why it works in the AI controller.
Yeah - UObjects don't have a valid GetWorld() I believe.
Is there any difference when we set a location instead of Obj reference in the blackboard key of MoveTo Task?? im asking this because im seeing it and i wanted to know why both are acting differently
It does actually. So maybe the Outer just doesn't have a valid world.
Hi, I'm trying to figure out how I can structure this BT so that the AI doesn't try to find more Smart Objects in the tree after the node has already been executed.
The "Eat Food" task will sometimes fail which will then lead the AI back up to Find Food again which will make it continuously claim objects...I just want it to claim one and not be able to claim any others even if the Sequence fails after the first one. ๐ญ
Also to note, for some reason this fails execute but the smart object is still being used? I'm unsure if this is a bug or not but I dont know why it's failing.
Kind of this,. still dont know the issue though https://forums.unrealengine.com/t/move-to-and-use-smart-object-with-gameplay-behavior-always-returns-on-failed-but-everything-still-works/1382563/2
I have some updates on this. Inside the smart objectโs Gameplay Behavior class, inserting a delay anywhere before calling EndBehavior allows the "Move To and Use Smart Object with Gameplay Behavior" node (the one run by the BTTask, shown in my first post) to return Succeeded. I discovered this because I had changed my code for other reasons, m...
How does MoveTo Task works in Behavior Tree, Im updating the goal location of AI using a custom move to Task on the basis of a certain condition. AI is following player until the condition is true and when its true it will get a new goal location instead the default target location, but when the player is running straight the check doesnt get called and it doesnt get updated resulting the ai into continuosly follow player
Why are you using a custom MoveTo task when the native one can update its goal as well?
im updating some properties of the task at runtime
the scenario is this:
I have a defined radius and centre, in that area only AI can move and follow player, if the player goes outside that area the AI will stay at the border and shoot the player until its in AI's sight and if the player comes back in the area AI will start following
I highly doubt you need a custom MoveTo for that
what other method do u suggest?
All you need to do is change the native MoveTo's target from the Player to a point on the radius
yea
Sorry, to a point on the circle
its fine i got it
but u cant change the native move to
You can
they are locked?
This is the option you want to enable
Then your MoveTo will update its target location as the BB key changes
the BB Key is Actor-obj reference
So? Just change it to vector. Works for both actors and vectors
i cant keep the bb key as location cuz it makes the AI movement jittery
That's not a problem with the MoveTo then, something else is wrong
What is the Move To Task Node in the Behavior Tree in Unreal Engine 4
Source Files: https://github.com/MWadstein/wtf-hdi-files
jump to 4:50
I did, there is nothing related to what I'm talking about
Also that video is very old
Native MoveTo has changed since
but it was working like that for me...
and when i changed the BB key to object reference it follows smoothly
Maybe the tolerance here?
Might be worth playing around with
Could set it to 0 if you want maximum sensitivity
it doesnt go less than 1
this is how it behaves at 1 and location as BB key
and
this is how it behaves when obj ref as BB key
Don't really see much of a difference.
Fixing the jittering in both cases is not a responsibility of the AI, but of the movement component or animation to smooth it out.
I doubt you really want to react to every single miniscule change in position
i do need to check the distance of player from the defined centre
i want it to check it at every frame as long as the player is in sight
not only when the player is changing directions or stop moving
Oh you can do that, but that's different from the AI actually reacting to every miniscule change
oh how, i want to keep the object reference as BB key too
Have 2 BB entries, one for the "player", one for the MoveTo "location".
If player in radius: set "location" = "player.location"
If player out of radius: set "location" = closest point on circle
How often you tick that is up to you to decide. But the MoveTo certainly doesn't need to react to a change of 1cm for example.
Ideally you probably want the robot to stay on the circle and keep firing before it repositions, right?
If you update navigation with every change it will keep moving and perfectly trace the circle as your player moves
What would probably be better is to design both behaviors as separate behaviors, rather than handling everything in a single branch
u mean 2 BB task?
There are no BB tasks
What I mean is 2 branches in your BT: one for behavior while the player is in the sphere, the other for behavior while the player is outside
In order of priority
u mean two 2 separate task right? im sorry i meant BT Task
Well not just tasks, different behaviors/branches in your BT
But yes the MoveTo tasks would also be 2
Anyone know what the issue is to this?:0
Can't say yes to that because that tree makes no sense
You need to implement fallback behavior
Turn on use acceleration for paths in the movement component and adjust the acceleration speed. Also don't repath so often, give it a higher tolerance.
They're two different tools each with their strengths and weaknesses
How can i receive an update when my AI stops seeing my character?
on target perception updated gets called with successfully sensed set to false in this case
I don't think you can really say one has a pro over the other? What are the pros of using a hammer vs. a fork?
It entirely depends on the job you're intending to do with it.
Why is the NavMesh not including the ramp?
Probably too narrow. You can either widen it or use supported agents to make the agent radius smaller
Thanks... I did a bit of both and it seemed to help... ๐
Alright, for one of my smart objects I need a Box (Fbox)
For test, I managed to make it work by using my current actor's position.
My game is taking place in a shopping mall. I would like, when an NPC gets in front of a store, he looks for smart objects to interact with within the store.
My issue: How can I associate a particular box (or set of boxes) with an entry point to pass it to the action?
That is certainly a con of FSMs. For simple AI it works fine, but gets messy the more complicated the behavior gets. The main difference between a BT and FSM is that in a BT the transitions are not tied to the actions, which can allow for more flexibility.
Be careful with this advice. If the supported agent radius is too small, the NPC can get stuck.
You can use a volume to define the store and make a box from that instead of using the NPCs location.
What kind of volume? most volume have a use or purpose, while here I'd only be using it for the boundaries.
You should be able to just place a volume. If not a trigger volume with the collision turned off is fine.
Thx
Ah, right, it needs the capsule radius addendum?
In behavour tree i havea decorator witha veector variable i am using on value change to abort . when i change the value and it gets changed in bb the decorator doesnt abort . what should i do if i want it to abort and restart every time it changes ?
Just wondering, does anyone know a more optimal way to set this up?
I have a Smart Object Bed that the AI uses to rest, but since EndBehavior sets the SO free (causing other sleepy AI to use it while another is still using it), I decided to only EndBehavior after the AI has gotten the amount of rest it needs, and I'm afraid that using a Timer might mess not be the best way to set this up.
If anyone has any ideas please lmk! (clearing and invalidate timer node cannot be called here so I'm afraid the loop might keep going even after the AI is done using it?)
I figured a solution to my box fo shops. Is there an easy solution to know the value of the corner of my shop easily? or do I need to place a random thing there, copy/paste the location?
How can I setup a Blackboard key of type "FBox"?
Think you'd have to implement that yourself in c++
I used to do that for gameplay tags I think, let me see if I can find the ancient writings for that in my repo...
Don't send me back to C++ ๐ข It's dark down there
Yeah I'm sure there's a better way to go about it than this, there's a reason I stopped using it
Why do you have an FBox and not some actor volume?
I could? The reasoning is quite simple: I don't know.
The smart object request I learned about require a query box, which is a box value. So I tried to define a box.
If I can do the same with an actor volume, and escape C++ hell, I'm for it.
Do you have some doc on actor volumes and how to set them up?
Might have figured it out. I'll give it a try.
There's plenty volume actors that derive from AVolume that could be used here. Luthage mentioned ATriggerVolume earlier for example
There's also ALocationVolume but not sure how that works
Once placed in the level you can change their shape & dimensions. Then for your SO request you can get the bounding box of the volume, which is an FBox
Thanks. I think I figured it out, somewhat. But I do not understand why I cannot find it on my blackboard. I created the volume, created a key on my blackbox, but I cannot find it in my Behavior tree.
Didn't we have this talk before? ๐
You need to set & get variables via your blackboard using FBlackboardKeySelector, not by directly referencing objects in your behavior tree
E.g. you could find the closest TriggerVolume and put that in your blackboard
Then your task would just read that out
One day I will remember. But today is not that day it seems.
Next issue: How to turn a volume into a query box :p
With any SceneComponent you can access its bounds
SceneComponent->Bounds.GetBox()
Surely there's something similar for BP
Not that I can see
More options. None that seems to work.
Ultimately all I would need is the Min and max.
It gives me the center and the half size. So something like this should work?
Maybe? Sounds correct
Hello guys, I have a small problem, please, does anyone know, help me, I have 2 agents for a large and a small AI, and when I use the GetRandomLocationInNavigableRadius function, it constantly gives me values where the big bot cannot go, and because This is why AiMoveTo constantly fails, how can I make it find a random location where BIG ai can move, may be i should pass something to the GetRandonLocationInNavigableRadius function so can I tell it which navigation agent to take the random location from?
You could use different recast nameshes for each NPC size. In project setting you can create new recast navmeshes, based on the capsule radious of your character and then two recast navmeshes will be generated. Your agent based on its capsule size, will use the appropriate navmesh.
yes it is doing that already , i got 2 recast navmeshes , but this GetRandomLocationInNaviagableRadius is giviing me location from RecastNavmesh for Small NPC (locations are close to walls) and BIG NPC can't got there thats why AIMoveToAlways failing . I want GetRandomLocationInNaviagableRadius function give location for BIG NPCs
Yo folks! Currently Im working on simple AI that patrols area. Basically AI walks from A to B, then randomly select new point C, then walks from B to C etc. Everything works but I cannot figure how should I handle rotation of the AI towards new point. I was thinking about simple task that will calculate delta of the rotation between AI and destination point, then rotate AI via root motion animation and then proceed to walk. Does it make sense, or you have better idea?
Well, it works... And it doesnt. I have no damn clue why it doesn't work properly. I get a claim, but now I get an error somewhere else.
Hello, I have an EQS, it works fine but when I get very close to the AI, it does not execute the EQS, if I move a few steps away it executes correctly, does anyone know why this happens?
It's a bug in your code
Better idea. Use the built-in Rotate to Face BB entry
I don't know what I effed up, but I effed up hard. Lost an entire day of work and I gotta get back to my previous backup. Yay.
Source control
Ahh, great idea! Can I somehow bind proper animation to it? I really want to achieve smooth and natural rotation ๐
Rotation rate can be adjusted from the CMC if using a char
Idk about the animation part
I see, Ill ask on animation channel maybe. Thank you for help!
You aren't sending the nav data to use so it's using the main one.
is there a way to make an EQS test enabled or not (the checkbox on the left of the test) based on a query param?I know i can just set scoring factor to 0 but then it would waste resources computing the test for nothing
In state trees, can I only bind Task instance data properties from other tasks within the same state?
I'm trying to use an output param, as the input param of another task. But both tasks are in different states.
Doesn't seem to work
You can bind inputs to outputs of all parent state tasks. I think you can also bind to tasks in the same state, provided the task comes before the one you're trying to bind in.
You cannot bind across branches though
You can do stupid stuff like this
Alright. That seems to be the case. Thanks.
Also, are tasks executed in order? For example, if I set some data on the output on one task? Am I guaranteed to get the correct value on the next task, within the same state
As far as I could read in the documentation they claim that tasks are executed "in parallel", which is probably bs
So far I've only ever seen them execute in order. Nothing would work for me if that was not the case.
But no guarantees there
Yeah, I guess the EnterState, Tick, and ExitState would be called for each task one after the other.
I think the parallel thing is that it doesn't wait for the first task to send a completed status before begining the next one
Each State can have multiple Tasks, and all Tasks in a State run concurrently as long as the State remains active.
This part
Yeah I guess that makes sense
So you can't 100% rely on previous tasks having their outputs set up correctly as they might be running on tick or something
But, if any task returns a completed status, the entire state transitions, regardless of any other running tasks, right?
Yeah, I'd use child states to force an ordering
Yes, it seems so. I have yet to use that, ever. All of my tasks just return "Running" and I control the transitions via events
Or on tick if necessary
How do you process events? Just got into that but I'm not sure when or how to process the event
You just setup a transition like this
And then just call
/** Sends event to the running StateTree. */
void SendStateTreeEvent(const FGameplayTag Tag, const FConstStructView Payload = FConstStructView(), const FName Origin = FName());
To send an event. If the tags match, the transition will be triggered
That function is on the StateTreeComponent
I see.. There's no way to use the payload yet?
Oh sorry nevermind, this one is better:
/** Sends event to the running StateTree. */
UFUNCTION(BlueprintCallable, Category = "Gameplay|StateTree")
void SendStateTreeEvent(const FStateTreeEvent& Event);
I think this is deprecated?
Oh wait.. This is in the task, right?
StateTreeComponent
Ah, I see. I'm not using that. I'm running a custom implementation
Oh, I see. But I think you can still hook into that
Cause all it does is:
InstanceData.GetMutableEventQueue().SendEvent(this, Tag, Payload, Origin);
If you have a FStateTreeInstanceData then you can call that
Yeah, the Execution Context also has one
Oh really?
That seems like it would allow for some really neat eternal back-and-forth transitions if you start sending events from tasks...
Yeahh... I'm using it a bit and it kinda makes sense
Yes, but you'd have to make a custom test which is only available in C++.
Is it necessary that I always pass in an instance data type for my state tree tasks? I have tasks that don't have or need instance data
But, I get an error when trying to compile the state tree
my bad i forgot to switch selector with sequence
wdym by "dont repath so often", how to change that??
Have a higher tolerance before repathing. What that means depends on how you are doing it.
im not sure if im doing any repathing
Im just passing a vector value as location to a MoveTo Task in behavior tree
You wouldn't be seeing stuttering in the movement if you weren't.
oh, so how to fix that?
I literally already told you
but where is that setting...
is that in behavior tree or movement component?
its my first time hearing the repath term...
i did turn on the use acceleration for paths in movement component
Did you adjust the acceleration and deceleration values?
No. You should follow the instructions that I've told you several times now.
im asking how to do that...
They are variables in the movement component. Do you know how to change variables?
change variables as in? changing the values?
Yes it's changing the value of a variable. The default is set really high. I recommend starting with halving them to start.
max acceleration? you mean
Alright, I think I need some help. Basically, I have a blackboard key which contain a trigger volume. Then I use informations about this key to create a box and find a smart object inside (Green route). But not every places have a volume assigned and thus sometime the key is empty. In these cases, I have a backup solution that simply search around the character for a smart object (red route). Issue is that while it works, I repeatedly get a warning :
messageBlueprint Runtime Error: "Accessed None trying to read property K2Node_DynamicCast_AsTrigger_Volume". Node: Find Smart Objects Graph: EventGraph Function: Execute Ubergraph BTT Find Smart Objects Blueprint: BTT_FindSmartObjects
First of I get the warning not on the Cast but on the find smart object, which is weird because it still work. The object is found and the AI does the animation on it.
Second, How can I avoid the warning all together? It is a desired outcome that sometime the key is empty and it'll use the backup solution.
Also, it is now done.
Hi!
I'm struggling to get smooth movement through a maze for my AI controlled units. Any tips for what I can do to make it move with near-constant speed? As you can see the speed through the maze varies a lot.
I'm using DetourCrowdAIController, with a close-to basic NavMeshBoundsVolume.
(Also, sorry if this is the incorrect channel)
Not sure if that's it as I don't know how you set it up, check your character blueprint, in the details, find the Nav Movement and untick "Use acceleration for paths". It might be part of the issue.
I did indeed try that, but it did not change anything. I can confirm, if I change back to normal AIController, then the issue goes away. But I do indeed want the features of the detour controller, so I was hoping to use that
have you tried adding in a "Is Valid" node. that should get rid of the warning.
Like this? The warning still happens.
strange, all accessed none I find that fixes. You could try seeing if the controlled pawn is valid, that might be the issue.
But if that doesn't fix it then sorry I'm out of ideas.
That's unfortunate because I wanted to do it with one of the built-in tests, guess I'll use score factor 0 or create a different query without the test and alternate. Thx btw!
Hello fellas, anyone ever worked with "StateTrees" instead of "BehaviorTrees"?
Question: How can I manipulate a variable's value in a StateTree-Evaluator through a StateTree-Task?
What I have done so far: I created an evaluator with an output-variable, created a task with an input-variable, bound these variable through the task and finally tried to manipulate the value of that variable through my task.
Main problem: When I print out the value of both variables (in the evaluator via Tick-Event and in the Task via StateEnter-Event, after the change of value) the value is always "unchanged" in the next print-cycle...but why? It is as if the change doesn't reach the evaluator's variable. And what's even mor confusing, the variable's value in the Task also resets without even leaving the task's state!!!! What's going on here?!
what is this used for in AI perception hearing sense config? theres not much info about it in the documentation...
Hello ! Is there a way to drive the MaxSpeed / MaxAcceleration of an AI thanks to a curve float?
I'm not sure if i can do that without breaking the whole logic
Can someone help with this? I don't have or need an instance data for the task, but it still asks for one
Hi guys, trying to figure out something with smart object and AI. My goal is to have an AI actor to also be a smart object that would dynamically move with the actor. I've only find one topic in UE forums talking about this : https://forums.unrealengine.com/t/smartobject-not-being-moved/786766 and didn't find any solution yet.
Iโm having a stab at using smart objects but it seems like they are not moving? Am i missing a setting or is this intended? To clarify what i mean by moving: If you put a smart object on an NPC that moves around you will see the smart object component stay in place.
Anyone got experience with this ?
If you have access to unreal gitlab, they implemented something for future release
We took the code in our unreal version to move SO at runtime
@wise sluice Is it also available on the engine github ?
doesn't the AIController posses the character/pawn before the character's BeginPlay?
or only after?
It's usually after afaik, use On Possessed
or maybe it was just called Possessed
Either way, both the pawn and the controller have functions you can override for when they possess something or are possessed by something
I made a new character class but GetController() returns null, not only at BeginPlay but also later (like many seconds later). So I guess I must be doing something stupid somewhere (but the Controller class in the BP is set to the default AIController)
found it, I was just missing Auto Posses on Spawned.... sigh...
I encountered it!
Many many times ... ๐
But i don't know why even setting the option back to "Static" and restarting the engine keep the invalid data
Hello, is there anyone who has experience with "StateTree"?
Hello! I've some experience but I still pretty inexperimented since it's pretty new
Well, do you know if it is possible to change the value of a variable in an StateTree-Evaluator through a StateTree-Task?
As i understood, StateTree-Evaluators are similar to the BehaviorTree's BlackBoard. But somehow, no matter what i try, i cannot change the value in the Evaluator through a Task... Have you ever done something like that?
all in all it looks somehow like this:
I FIGURED THE ISSUE.
There was ONE interest spot that I shouldn't have placed. It was at the wrong place, too far away from any smart objects. So when the backup solution of "look around you" triggered, it found nothing at all. Causing the error messages.
Is there a way to get/set a state tree parameter from a task?
Anyone have any ideas?:0 I'm wondering if I can just set the object as claimed without having to use it
C++ navmesh PSA: don't use ARecastNavMesh::GetPolyEdges to see what nodes it's edges lead to. Use ARecastNavMesh::GetPolyNeighbors instead.
The problem: if there is a straight for edge that's connected to 2 different nodes, GetPolyEdges will report it as leading to only one of those 2 nodes.
Like on this picture, where edge 2 of node 53 is reported as leading to node 40 (dark purple number), completely ignoring its bigger part that leads to node 38
GetPolyNeighbors will also report navlinks
ARecastNavMesh::GetPolyEdges is only usable for checking whether edge is connected to any node at all, rather than being a wall
You can "get" the value of a parameter by binding the parameter to the Evaluator/Task. At least this might be possible. As for the "set" i am not sure right now. I will try this out now by myself, maybe you brought me the solution to my problem!
Ok i tried it out. I can "read" the value but not "write".
People talk about this on the web too and say that parameters can only be read, not wrote into...
unfortunately, this problem also remains for evaluator-variables which can be read (and manipulated within the evaluator itself) but not wrote into through binding...
the only solution i cam across was to reference to your Actor (which you defined under context in statetree), cast it and manipulate the data in there.
I'm not using the default StateTreeComponent, I'm rolling a custom implememtation
I don't think they're meant to be manipulated.
Yes i don't think that too
How do you expose evaluator data
What is your goal with this?
I'm running it on Flecs, which is an ECS like Mass. Most entities don't have actors, so I can't use the component
Putting them into an "Output" Category and then "bind" them to any task/conditioN/evaluator/etc.
Ohh, I see
Do you have any tasks where you don't set an Instance data type?
Uh, what do you mean with "set an instance data type"?
If I pass nullptr to this, I get an error in my state tree
Well currently I am doing Blueprint only regarding StateTree.
Ohh I see.
Hmmm
Effectively i had the same issue
But Evaluator doesn't have parameters, it fetch data from external source
So if you modify the source, you modify the variable and you can do it in task ๐ค
But yeah it's not a reference OR it is readonly. When it's bound to your task and you modify it will be modified inside your task but not in the evaluator
Since you are developing in C++ I can recommend you look into the Github of "Epic Games"'s UnrealEngine sourcecode. The plugin should be there and maybe also how they instantiated the Task.
But to get access into their project on github, you need to signup first (it's a simple and fast process, no worries): https://github.com/EpicGames/Signup
I have source access
The thing is that in Mass, the Task could modify the fragment (equivalent or your component)
In theory
I've checked the issue. It's in the state street compilation. Seems there's no way to do without it.
Exactly what I need to know! As long as it is not an bug, I can continue my work! Thank you
Yeah, that's what I ended up doing
I modify the component in flecs
In the end, the task will modify a fragment linked to a specific entity thanks to its handle
But yeah same issue than with classic Statetree and parameters, evaluators. You can only modify external source.
Yep. I was hoping to use a generic Move To task that takes in a location as an input param.
But I'd have to create a specialized GoToCover task that gets the location from the Fragment
Hmmm you can have an output on your task no?
THanks to instanceData
USTRUCT()
struct CURIOSITY_API FMassNavmeshFindRandomLocationInstanceData
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, Category = Parameter)
float m_fMinRadius = 1000.0f;
UPROPERTY(EditAnywhere, Category = Parameter)
float m_fMaxRadius = 1500.0f;
UPROPERTY(EditAnywhere, Category = Parameter)
FVector m_vSpecificOrigin = FVector::ZeroVector;
UPROPERTY(EditAnywhere, Category = Output)
FVector m_vTargetLocation = FVector::ZeroVector;
};
I find the cover location in a sibling state, so I can't bind to it in the Move To task
You can only bind from tasks on the same state or in a parent state
Why the move task is not a child of your find ?
Cause it constantly runs the Find task, which I don't want
That's normal
It enters inside it, find something and stay idle but Mass StateTree doesn't tick so it's not an issue
I don't want that behavior. Find, then go to cover on success. Stop trying to find
Remember that I'm not using mass
Ah yes ๐ฆ
My state trees are tickiny
oh
Actually I think Mass state trees tick. Cause some tasks have tick behaviour
I can assure you it doesn't tick
They have tick
But they just tick on need
It needs a "Wakeup" signal
to tick and sleep once the states got executed
Yeah, I did notice that the tick is called in a signal, not a processor
I'd dig into how it works. But that's not a solution for my problem anyways.
I'll just use the specialised move to cover task
Are smart object a problem for performances when not in use? I have quite a few of them (a bunch of "options", most of which will be unused at any time) and I am worried about the performance impact.
Like, I use them as spots where NPCs can go and "pose" (so rather simple things), but it's for a shopping mall, and there is eventually going to be 5~15 spots per shop... With room for 36 shops. and about 30NPCs moving around between the shops. Not sure I'm going to populate everything, but that's still easily a couple of hundred spots.
You're trying to use an invalid reference
Meaning? I know that sometime SearchArea is empty, but that is by design.
Am I missing?
It has nothing to do with the search area. You are trying to reference something that is invalid. Hence the error that it accessed none.
Yep, figured that one out.
#gameplay-ai message
Any perf concerns should be profiled, not guessed at.
Anyone knows why it's red under the character and how to solve it? (since it appears that the navigation is not identifying it correctly)
Anyone knowledgeable in the Smart Object plugin know the different between using the Mark Smart Object as Occupied node and using the Use Smart Object with Gameplaybehavior node?
has anyone had problem that having ai move to node when they walk causes tons of draw calls? they keep for around 50 seconds after AI and characters are deleted
hello everyone , i got an issue , please help , sometimes anim montage doesn't get played but strangely "Blend out" or "Interrupted" never got called , (On video when Boss attacks second time , nothing got played) , why it misht happed , what is the issue please help , i provieded code as well
Something is affecting the navigation
What do the different names of the functions sound like they do?
From reading an article I found, apparently they both just mark it as occupied but I don't see any further information. I'll have to look at the c++ to see what functions they're calling exactly
Still having trouble with this question, since I wanna be able to End Behavior manually but unsure how
is there any way i can compare two int variables in the conditional loop decorator of the behavior tree??
The function names tell you what they do. One marks it as occupied. The other uses it.
The other function that uses the SO also marks it as occupied within the function but i'm not sure, which is why I was wondering If i change how I have the AI use it by just marking it as occupied and unmarking it whenever I want to. Because when I use the function that uses the SO, it waits for the "end behavior" node before finishing execute, but end behavior marks the SO as free so I dont want to have to use it if possible
Yo, Im playing around with StateTree and I cant figure out how enter conditions works. I made simple setup that only uses built in functions. Basically State 1 has condition that is always true, so State 1_1 will be always fired. Then I want to make transition to the State 2. State 2 has condition that is always false. As far as I understand StateTree after Enter Condition is failed should go to the next state (State 3 in this case, bcs Enter Condition for State 2 failed) but it's jsut stacked after failed condition. Any ideas?
Is there an official reason why https://github.com/EpicGames/UnrealEngine/pull/2246 hasn't been integrated yet?
(apart from being outdated, it works perfectly fine when updated to new base code)
Something that was last updated 8 years ago is probably long forgotten by anyone and is just rotting in the list
There are like one line PRs which aren't getting merged so this seems to be just the standard way these operate unless you happen to get an Epic employee's attention who wants to merge it for some reason
hey guys any ideas on this ?
ive set sight as dominant sense yet, when the AI has first player in sight and second player makes a sound the AI switches the target from first player to second player
This depends on how your own code handles it
Perception system doesn't have a concept of a "target". It just perceives stuff.
im lost in the behavior tree... i kept the task that AI will do when he sees a player on the left of the BT
I mean, they still actively recommend it to people in UDN threads
when they run into the issue
I'm tempted to push an updated PR, give credit and see if they accept this time
Really, that's pretty weird lol
Must be one of these where nobody wants to take responsibility for it
anyone familiar with StateTree ? i dont understand Input,Output, Context
how do we set the result of a Task (FindActorRandom) to parameters value ?
In BPs you set the category of some variable in your ST task as Output, and assign a value to it
in C++ same but you use InstanceData
i wrote custom behavior tree system in blueprint from scratch for simplicity
๐ค
So you reinvented the wheel, in BP, because you didn't want to learn the basics of the current one?
Why not just make a state machine at this point?
Then possess it with an AI controller
What do you need an AI tool for on a playable character?
Yes
watch this guy's tutorials, I think they're easy to follow and pretty decent: https://www.youtube.com/mrkosiej
yeah that's the ideal case for unpossessing and repossessing with AI/player controllers
way less work than reinventing BTs
You need to figure out why the montage is failing.
guys i have problem with an ai in game my ai always tries to go from corner of nav mesh which causes the ai to get stuck somrtimes how can i fix that please help thanks the video is given as well i know ai tries to take always the shortest path initially but how can i undo that and environment is not that big has a lot of objects in it so what can i do to fix it
Does your nav mesh agent settings actually fit the NPC's capsule?
yeah i added the capsule radius know as capsule radius however i have two ai in the game this is how i added the info in it picture below
idk what up with ai
why it dont go from middle
where there is nav mesh
Is your nav agent radius > the capsule radius?
hello, i am a new UE5 user and I am deciding whether to use box collisions or ray casting/line casting, to detect other vehicles on a race track for my AI vehicle, some people keep saying casting lines/rays is better, but i just lack the knowledge right now to know why, so which one would be better and why? ๐ฎ
How do I set the world direction for an enemy just like setting the world direction for the player? I am trying to make a 2d, top-down game.
try #ue5-general
Ok, thanks!
Ray casting is significantly better for performance.
What do you mean by setting the world direction?
so essentially i have to cast rays 360 degrees around the car every tick and calculate the positions of cars nearby, then figure if there is room to overtake without colliding with anything
Or you could cheat and just check which cars are nearby and how close because you can just get a list of every single car and having this and a vector distance check is probably cheaper
I recall seeing something about racing game AI's on the Game AI Pro website also, maybe worth checking that
yeah there seems to be driver san francisco AI pathing article
but i try to avoid cheating, i have my AI currently driving using the same controls as the player would
i want the collision detection work similarly as well, or close to it i guess, but will see, i am very new at this
You're just making your life harder :)
You certainly could make it so the AI has a "cone of vision" or something, in other words, ignore all the cars that aren't within some angle in front of it for example
but at least I don't really see any point in using a linetrace for tracking a set of known objects
Of course once you've determined one of the cars is potentially in the way, you could use a linetrace to check if it seems like it would be useful in some fashion
My assumption here is also that you don't have like.. a thousand other cars
not yet, but then this would assume i would get every cars location on every car, and calculate, which cars are in the way and which arent
feels like doing lots of calculations on things that are irrelevant to current situation, especially when the car is driving alone and rest of the pack is somewhere far away
but cone of vision would not be enough, the detection should be i think, around the car in every direction, because if you want to start overtaking, you want to check to sides as well, if there is a car also... but if all clear and overtake can take place, then i guess it would start spawning spline dynamically around the car in front, so it would just increase speed and follow "overtake" spline, which, ideally would then be calculated on the fly depending what information is returned by ray casts
Hey!
How can I hide from AI perception?
I want to make it so that the player can hide in a closet, and not be detected there
For the 2d sprite character, I have to where it tracks the world direction, which determines which way is up and which way is down. If I move the character in a direction, it changes the sprite based on the direction it is going. I want to do the same thing for the enemy sprite, but I can't find the correct node or component for it.
I was looking for a node but I couldn't find it
I mean 2d might be problematic but did the orient rotation to movement I mentioned work?
I mean if you rly want to go full out, you can just use AI Perception at that point
Give it a 360 cone and a radius and youโve got your detection
Not sure itโs worth going that route for a racing game tho
How else would you make the cars not crash into eachother, overtake, defend etc.
Also drive around obstacles
Is there a way to get an Actor's Smart object component and get the handles or slots from it instead of using Find Smart Objects to get the Request Result?
For context, I have an AI i can command to eat something, which is an actor set at the BT Target with a smart object component on it, but cannot figure out how to claim the object first before using it. The only thing I see that grabs the slots from the SO, is the Find Smart Objects node that comes from the subsystem :(
Hey All - I'm trying to get my AI to see a deadbody. It sees other AI (alive) and the Player fine, but on my Deadbody blueprint Actor it doesn't recognize it. I've added the AIPerceptionStimuliSource and set it up as follows (pic). Is there anything else I need to do?
Iirc itโs a height thing
Perception works at eye level by default if I rmbr Luthageโs words correctly
Or was it capsule height? Either way, it wonโt see stuff on the ground out of the box I believe
Thanks. I did wonder that, but when it's a pawn actor it works fine, even on the ground. I also tried putting my dead body actor on a platform at eye level but no dice so far.
Odd. Did you try using the Ai debugger to see what happens at runtime?
Yeah, it doesn't see it at all. My actor just has a static mesh but I've set the visibility trace channel to block and I have query and physics on.
Itโs not a pawn tho?
No, just an actor. Does it only work with pawns?
I canโt recall rn, and I donโt want to give you more bad info ๐
No worries, I'll keep playing around. I'll try parenting it to a pawn and see if that makes a difference
Ok, I think I've found the solution. I'm using Gameplay Tags and my player and AI characters inherit from a C++ class that implements the GamePlayTagAssetInterface. I don't believe this is available in blueprints, so I'll just have a base C++ actor that implements the GameplayTagAssetInterface so my Dead Body can get registered. Pretty crazy this isn't exposed to blueprints but hey ho.
The orient didn't work. Still rotates when going towards the character.
Yeah ik, had to expose it myself but not hard to do thankfully
Can someone explain to me how "SpawnAI from class" conceptually works? Like, when does the BehaviorTree which can be defined in "SpawnAi from class" starts to run??? I am asking because I get an error telling me there is no BlackBoard found which I clearly did define in my BehaviorTree!
All it does it is ensures an AI controller is always spawned with the pawn
It runs the behavior tree immediately also
But what is with the BlackBoard in the AiController? Why is it "none"?
I thought, the moment a BehaviorTree gets active the defined BlackBoard in it is instanciated too, but it seems it does not in the case of "SpawnAI from class"
Ah here it is... until now, I tried to set a BB-Value via "Event BeginPlay" or "Event OnPosses", in both cases the BB is none.
But now that I tried to set a BB-Value via "Tick", it is existent...
That is why I need to know the conceptual aspect of "Spawn AI from class". I want to now when BT and BB gets active so that I know "when" I can manipulate the values in the BB-Variables. Can anyone tell me that?
I looked at the code for it, it just spawns the controller and immediately calls RunBehaviorTree on it
That's likely to run before BeginPlay I think in that case
Hmm interesting and strange at the same time.
Anyway, I found something useful in my case, an event called "Event OnUsingBlackBoard"!
Basically, what I needed was a method to set some BB-Values after the NPC/Ai got spawned into the world. The OnUsingBlackBoard-Event is exacty what I needed
Edit: The OnUsingBlackBoard-Event is found in the AiController
Pawns are auto registered as perception stimuli but actors need to be done manually. Not sure if you can do this in BP.
Can't you use OnPossess for this?
I've tried OnPosses as well as BeginPlay, but in both cases the BlackBoard in the AiController is "none". Only after discovering "OnUsingBlackBoard"-Event I was able to set/change a value for a BB-Variable
Where do you run the blackboard then?
Run the blacbkoard? YOu mean the BehaviorTree, do you?
Are you swapping out blackboards at runtime or using the same one per bt?
Oh yes I am using the same one defined in the BehaviorTree (!).
Though there is a way to set/change the BlackBoard for a BehaviorTree at runtime too, but I haven't tried that yet.
Yeah I run the BT at OnPossess so that would be the time to interface with BT or BB.
But if you manipulate BB keys exclusively using BT tasks, you won't need to worry about any of this
Seems legit. I also did "Run BT" on "OnPosses"-Event before. That was when I placed my NPC in World instead of spawning them.
UE differs between "spawning" and "placing" NPCs/AIs in world by defining a value for the "Auto Posses"-Property of the NPC's BP.
Sure but not sure what difference that makes for your case. In both situations, the controller possesses the pawn, the OnPossess function is called and the BT initialised.
The order in which "the engine" triggers OnPosses and BeginPlay for the BP and AiController differs between placing and spawning.
I already forgot in which order, it was something like OnPosses of an AiController gets suddenly triggered before BeginPlay of the BP or something like that.
I am not entirely sure what happened there within the engine, but switching from "place in world" to "spawn" suddenly lead to many errors.
Petition to Epic Games to make State Tree task instance data optional
Not every task needs instance data and its annoying to create an empty struct for the task.
I'm just going to create a dedicated FEmptyInstanceData. But, I'm not happy doing so!!!
You need to turn off use control rotation on the character
The BT does not trigger begin play or on possess. Understanding the actor lifecycle is incredibly important. https://dev.epicgames.com/documentation/en-us/unreal-engine/unreal-engine-actor-lifecycle?application_version=5.2
It's not a good idea to use Spawn AI From Class, because you don't have access to when the BT is set up. It happens after on possess using that node. Just set the controller to be created when spawned and placed in world, run the BT in the controller's on possess and then set whatever BB keys you want.
yeah by "BT" i meant "engine"
I already looked into that but that diagram doesn't show the difference between the "spawned" and "placed" actor, or at least I cannot see it in that diagram
"t's not a good idea to use Spawn AI From Class":
But what is "spawn Ai from class" then?
One side says load map, which is the flow for placed in world.
What do you mean what is it? It's a function.
I mean, what is it's usecase, since you say using the function is a bad idea
It's a function that is to make spawning AI "easier", but has unintended consequences.
Ah, like, compared to "Spawn actor from class" I cannot set variables before the actor gets added to the world via the "exposed" variables?
So using "spawn ai" function does set some limits?
Are there even other consequences? I am curious!
Not sure. I don't use it because you don't have control over the flow.
How do you "spawn"...or..."use" an NPC/Ai? What would be your workflow?
Do you use "Spawn Actor" instead?
I'll try that.
It solved the rotating sprite issue, but the enemy's viewcone only faces right and the sprite is still not using the correct directional sprites. It only uses the right facing sprite and occasionally flashes the left facing sprite(usually when going to a stop or bumping into something).
Epic has considered your petition and decided they do not care ๐
Nevermind, I fixed it by setting the sprite transform rotation to world instead of relative. Still doesn't fix the sprite issue, but the view cone can move now!
Same old story ๐
Yeah, Iโve had issues with Spawn AI from class as well, it hasโฆsome limitations
how can i make the target on ai move as the player without using get player character
using a ref of the player doesnt work
I'm using the OpenAI API plugin with the UE https://www.unrealengine.com/marketplace/en-US/product/complete-openai-api-plugin. Specifically, I'm using computer vision calls from the perspective of the agent, and having it call BT behaviors based on what it sees. But, for the life of me, I cannot figure out how to change the model (I want to change from vision preview to gpt4o). Has anybody worked with this? https://www.instagram.com/p/C7F4M6hRg0a/ <-- that's it working.
although your context seems UE AI related, it seems you're looking for GPT related answers, for which #generative-ai might be better
It's a hybrid ML-gameAI system, but yes I'll post down there.
how exactly you pass condition to distance comparer?
Its quite annoying that cant get it hooked with what I want. Like position and such
I can't pass values into Transition?
nope its exactly equal
hello everyone. im very intersted in smart objects (especially with 5.4 update) but all the learning reseources i can find are a bit jank. i was wodnering does anyone have any recommended learning resource for them ?
It needs to be greater than or it won't pick the right one.
okay gotcha
What distance comparer?
StateTree conditions
problem is mostly with passing values to statetree
can't bind values easily
Is there a way to make an AI not always go real close to the the edge of the nav mesh? I have a chaos vehicle which I programmed a follow system into, but the spline it generates for pathfinding is made stupidly close to the edge of the road, causing it to go offroad and get stuck (As I disabled nav generation on the landscape).
I found a workaround by making a premade spline and using that instead. It works okay
canu tell how much bigger i make it in nav mesh setting so i could work properly how much value
i mean
Can visualize the path of AI when using AIMoveTo?
Found ai.debug.DrawPaths
I have multiple NPCs generated on startup, how can I select on of them in simulate and only follow a particular task for him and not for everyone? If I place a breakpoint, it trigger for all of them.
ima having this issue whenever the robot run towrads me , the task itself is not finishing execution as a failureor success idk why is this happening stuck on it for 3 hours now .
Hi, why do my RecastNavMesh settings does not save? I change agent radius and it does work, but after restart of ue it just goes to default, even in project settings i have set them to my param and it does not work and always sets to 35 radius
@golden orbit are you editing it in the level or in project settings? If in level, it will overwrite those settings with the ones from project settings whenever the navmesh is rebuilt
Hi guys! I have an AI animal in my game and I want this ai to run away when it sees the player. I have 2 tasks one of them finds the location to run away and the other one is moves to AI to that location but when the player sprinting the ai enemy freezing for a little little amout of time because finding run away location is working all the time how am I gonna add a interval time to task
As u said, in my project settings i have set it to my params, but it does nothing
So the values from project settings are not being reflected into the navmesh in the level or?
Does it also not work if you delete the recast navmesh actor and run Build->Build paths?
That's bad ๐ฆ
I would check in the navigation mesh settings page of project settings to be sure it's set up correctly, and maybe try configuring a specific agent type as I vaguely recall it might have these settings effectively duplicated for agent types and a "generic" settings page
where i can config agents? And what does it mean?
An agent is something that can move along the navmesh... it's in the navigation mesh or navigation system settings
Yep, and then?
Try rebuilding paths and see if it gets the settings from there or not :)
Oh nice, yeah the settings are sometimes a bit confusing
Yeah, i would never found it xD
Got a question about Learning Agents, Is it a good idea to train an AI for multiple different vehicles instead of the same vehicle?
One vehicle type is a fast, sporty one while the other is slower and more designed for offroading
Hey did anyone have this issue where the AI is not moving to a location even tho the nav mesh is there?
In the video you can see that the Actors stop moving in certain areas. This only happens after some buildings are placed. The Nav Mesh displays correctly green for the are but they won't go there. Any idea what the issue could be? There is also no Collision there when i order unit beyond this area they will walk over it.
Visual logger and some of the vis log nodes can help you debug
I am not an expert in Reinforced Learning, but judging by common sense I may assume that yes, it's better to use different vehicles as different agents to train different models. At least with a current version of LearningAgents in UE. The more your vehicles differ in terms of input/desired result interaction, the better exclusive models will work. For example, your sport car can performs more efficiently on track, whereas your offroad vehicle is obviously better off road. The input/reward will differ for them, so will differ the trained models.
It just needs to be greater than. So if your capsule radius is 40, the agent radius needs to be at least 41.
Looks like it never gets close enough to stop.
You can't select one of them in simulate and follow them, unless you add that functionality. You can use the gameplay debugger or the visual logger to debug one AI at a time though.
There is a way, tho a bit hacky and not necessarily reliable ๐
But yeah it involves using the gameplay debugger/BT screen
If you select an actor in the outliner at runtime before opening the debugger you tend to get that one to be viewed. Similar with the BT itself
Why is there no dropdown for AIPerceptionStimuliSource? In Unreal Engine 4, you would have an option called Register Source or whatever and it would be like Sight, Hearing, etc and you could drop that down and there be more options, but there doesn't seem to be a dropdown now
Nevermind, I needed to put AIPerception on a BP and its under there
@misty wharf sorry for the ping again but do you know about how exactly to pass values to condition in state tree?
Sometimes they hit and other times they dont
doesn't seems to take values from evaluator
only from Tasks
I mean I want to do simple distance check to "stop" my character
Should I be using pawn sensing or AI perception or just collision spheres and logic for a pretty basic player/enemy interaction: at a certain distance enemy faces player, a little closer triggers magic/ranged attack if the mob is either of those types and chase in the case of them being melee type until finally at melee distance triggers engage in melee combat...
Thatโs not necessarily โbasic interactionโ. Either way, pawn sensing was replaced by AI perception so you should prly use the latter if youโre going that route.
im having an issue with the ai not seeing the client and only seeing the server
what could be the solution to this problem
Hey guys,
Anyone really familiar with the AI Perception System ?
I'm trying to setup a component on an AI Pawn, the goal is to have 2 senses - say AI_Sight, with 2 different ranges. Then my AI should react differently depending on the sense triggered through a State Tree Component via event tags (1 event would be flee and the other alert for example).
I'm currently struggling to find a way to differentiate my 2 senses in my State Tree Evaluator. What I tried to do was to set a bool variable that will toggle an Event Tag then send it to the State Tree. But it clearly doesn't work for more than 2 different events. Any Idea how I could do that ?
this is what my BP look like
I'm feeling I cannot even have 2 sense configs for the same sense, and that doing all of this via CPP might be the better option from what I've read (I'll also need to setup a AI_Team sense)
I have some other concerns, while trying to dissociate the 2 different states (flee and alert) through 2 different senses (alert will be sent from AI_Sight while flee will be sent through AI_Hearing) It seems that my stimuli source cannot register more than one sense as source. See debugger :
Hearing doesn't have any querier
Even weirder. Unregistering my player pawn to sight and it still shows as a querier (even after rebuilding the project)
You can have multiple different senses configured, but for a singular sense like sight, if you want multiple configurations you need two perception components
Not querier, queries. Hearing is not an "active" sense which performs queries on tick. It only reacts when you trigger it via sound events for the sense
Sight sense does "queries" on tick via line tracing to check LOS
Not 100% sure but aren't conditions mostly for enter/exit? Not sure if they're meant to function like decorators would be used for in BT's, so maybe you should put the distance check into the task
saved me on that one ! :))) Thanks a bunch
I was trying to have multiple sense configs and indeed it wasn't working at all, having multiple components is indeed the right thing to do
what? Then how do I make enter/exit conditions then?
enter/exit conditions are evaluated when states finish
and it needs to find which state to activate next
What do you mean seeing the client? The AI systems are only on the server.
Am I misunderstanding On targetPerception Forgotten? I am trying to check if an NPC sees the player. The beginning is fine, but the "On Target Perception Forgotten" doesn't work as I thought it would. How can I check if an NPC no longer sees the player?
In target perception updated, check the successfully sensed value. This will be false when sight is lost
Bottom one?
I've managed to create a "Random Selector", custom Composite Node for Behavior Trees.
So if anyone is trying hard to create one, here is the code:
https://dev.epicgames.com/community/learning/tutorials/8JL3/unreal-engine-random-selector-behavior-tree-custom-composite-node
Yep
Hey guys, I set up my AI controller correctly, put AIPerceptionStimuliSource on my character BP, and put AIPerception on my AIController, (or the other way around idk) and made a behavior tree with a task to chase the player if the IsPlayerSeen bool is set, so in the AI controller, I set it up where it set that bool on sensed, but the AI doesn't move. I added debug prints to the sense so it does output, it does see me, but the ai doesn't move
I did put a nav mesh bounds volume in too
why is my ai tweaking literally i have the most basic code: move to player and ip ass in player correctly and whatnot. and istg these guys do not wanna turn they fricking shuffle backwards walk
Pls help me
my logic:
Right I read back through your original description of the problem. How are you asking the character to move? Is it the AI Move To node?
It's the Move to location node one minute
I'll show you
This is how my behavior tree is set up
My AI controller
My BP
@tough tulip
Right gotcha. Well you are not checking if your GetRandomReachablePointInRadius node is actually returning a reachable location.
Right, upon seeing the result we can take the next step
It says no
It says false?
I put in a branch with a print string for true and a print string for false
false, yes
Right, a good tip is that you can plug the boolean directly into the string field of the print string
It will automatically convert the boolean to a string
Right, have you tried increasing the range to 500?
Okay, I changed the node to GetRandomLocation in Navigatable Radius and now it's displaying true
Right, and is your AI now moving?
No
.
Okay in order to simplify this, please use the node called "AI Move To" instead of the Move To Location node
Then based off that, you can drag off the request failed and add a print string to see if that is firing or not
Okay it's not firing
Right I see. one thing I do spot is that you want to change your set blackboard value in vector node to fire off the execution pin above the on success pin.
Right now it sets the blackboard value after it has succeeded the move to and arrived at the destination
So basically set the value before the move to?
Well no. The Move To is a latent node meaning that the On Success and On Fail nodes will execute at later times, not necessarily in the same frame as the node was called upon.
In this case you can place the set blackboard value in vector node before the move to node. But you could also drag off the execution pin above the On Success Pin, and then drag to the set blackboard value in vector node
Okay I did that, it's still not firing
Oh I see
You have your acceptance radius set to 500 in the AI Move To Node
But your range in your Get Random Location in Navigable Radius is also within 500
so your AI auto completes
because it is within the acceptance radius of the location you have requested
Set Acceptance Radius on your move to node to 10 for example
then it will start moving
Please share another screenshot of the code
hold on
I'm trying to now cast to the player and use the player's location as a destination
Right. But the AI is not the player character right?
And you are not simulating physics on the AI right?
tf do you mean
You think players are AI?
No i don't think players are AI. I am simply verifying what your setup is without having to understand your entire project
Okay, I'll go in detail
So, I have a blueprint character named BP_Freddy, which has AIPerception, I went in and configured the sense and turned on Detect Enemies, Neutrals, and Friendlies. Then I made an AIController that has a AIPerceptionStimuliSource, then I made a BT and BB
I made sure in my AIController to run my behavior tree, and the print string nodes in the BT tasks are firing so I know the BT is working
Just the AI is not moving
Back when I was using Unreal Engine 4, there was no hole in the nav mesh, I could just stick my character in the level and it moved
Hole? ๐ค
.
You need to turn off can ever affect navigation
It was off by default
now it's moving
That's what I needed okay
Glad to see it is working now
Thanks for your help Bandaro and others
i mean by not sensing the client
it only sense the server when it sees it but not the client
The server can't sense the client
so what is the a way to make the ai sense both server and the client
Because sensing on the server is all it needs.
The AI will chase the SERVER version of the actor it senses
yea thats whats happening but my question is there a way to make the ai chase the client too
That makes absolutely no sense
maybe idk how to explain it but ill show you a video
NPCs are server owned actors. The server is the authority for them and the client version is just a puppet
on the left side the ai sees the player but on the right side the client the ai wont see the player
if the problem cant be fixed because ai perception and behavior tree only works on the server then what could be a solution to it thats what im trying to figure out
Show how you're acquiring the target
It definitely works. Many games have shipped with it.
.
yea ive seen people use it but idk why its not working for me
before i used get player character but that obivously didnt work because then i would have to put in the player index which player
This code is hard to follow
yea i made a funtion to get array of the player
Why do you need that at all?
which one
A function to get the player array
i made it last night to see if it works
This looks like something Ryan Layley would do
yea some of it i got from him
i also added the ai perception stimuli source to the player
For the sight, you have it were if the Passed in Actor is == to the TargetPlayer, only then would you update the BB value. Why? Perception's entire job is to find the target player for you.
Why are you using the FindEnemy function at all?
Also, Run BT node should be in the possession event, not BeginPlay
i used the chase task in the blackboard and attack player
What does that have to do with the FindEnemy function?
You already have the target because you update the BB value
Just get it from the BB
That's its job
This part in your sight sense
Then in your task, you just read from that TargetActor key
so when the sight sense is sensed it should call to the target actor immediately?
It should just update the BB key
ok but what would be the target in the ai move to
Make a var in the task, make the type BB key selector. Make it public and then in the BT, select the key.
In the code, drag it out and call the Get Value as Object node, cast to actor and plug it in.
Any reason you're not using the built-in Move To task?
Because that can also just take a key and move to it
i added it in a task because i made it change the movement speed too
IE - what is the purpose of BT_Task_Chase existing?
Use a service to do that
You can put a service on the Attack Player sequence so when it enters that branch, you update the speed. And when it leaves that branch, you can revert that speed.
ok ill try it out and see
I am making a Five Nights At Freddy's game, since the enemies are animatronics, I want them to turn to me before they start moving towards me, how do I make this happen?
I also want them to play mechanical servo sounds as they turn
What have you tried?
nothing really, I don't know how to do this
Maybe a rotation node, wait 2 seconds, then move node will work
Are you using a behaviour tree?
I am
Rotate to face bb key task is built-in, adjust rotation speed from the CMC
Char movement component assuming youโre using a char
Now he's just not moving
Show code
Well thereโs no Move node lol
Yeah well the moveto is in a custom task
Ok, thereโs a BT version too
Only downside it has is you canโt change acceptance radius on the fly
Your rotation should probably happen after you find the location
Else the bb key will be empty
So wait, should I not have "find player" and ai move to in the same task?
This unfortunately does not work
In my task I cast to the player and get the actor location and set that as a value and pass in the key, and then I choose that key for Rotate to BB entry, but it doesn't rotate
I fixed it
Okay, so I have this
I noticed that when my character moves to be, he has to rotate to me again and move, I just want him to rotate to me the first time he sees me and then chase me, how can I do that?
works now precaite the help
your right about the branch if actor == target actor and find enemy its uselesss
Depends what you mean by โmy characterโ. Is this the player character or some other AI
AI
Make it use a different tree/subtree if you donโt want it to share the same behaviour as the other AI
Is it possible to bake a Nav Mesh into a Nav Area?
I have multiple nav meshes (for different agent radii) in my map. I would love to be able to bake the inner nav mesh into a nav area polygon.
This would hopefully allow my most nimble AI characters to move with nav filters where they avoided large open areas when pathing.
I guess a secondary question is can Nav Areas be anything other than box volumes?
and a thirdary question, can NavAgents change their Agent type at runtime?
How to mark character as enemy in AI Perception...i looked on the forum posts but they way too old and its hard to understand
Sorry Iโm not that experienced with C++ yet. virtual FGenericTeamId GetGenericTeamId() const override { return FGenericTeamId::NoTeam; } There is no build-in struct-member for Enemy, Player & Neutral. Does that mean we have to create those ourselves as well? Only FGenericTeamId::NoTeam is present. Also it gives me 496 errors:
Thereโs a pinned video on Behaviour Trees here that also covers AI Perception
got it thanks!
Hey y'all. Trying to learn about AI in UE and having a problem, my pawn does not really move even though the location is being picked from the grid. It has a separate AI Controller that runs the behavior tree.
I can see the location changing but it's happening constantly and does really continue to the 'wait' command. The possessed player does not move at all either
Do you have navmesh in this map?
No. I want it to move in a sphere
If you want the AI to do Move to task, you need navmesh anyway
I was told that if I want to have a planet and move pawns in there I need to use the EQS system because navmesh is only for flat surface
EQS has nothing to do with path finding. It is just basically generate one or a group of results basec on your EQS test
I've no idea how to do path finding on a planet, but you still need a method for AI to know how to find the way to the result you got from EQS
isn't the pathfinding task inside the EQS for that purpose?
Nope, EQS has nothing to do with path finding.
hey guys, a user posted that super weird AI teleporting behaviour which i have no clue yet what's going on. as you can see some AI falls from the sky whereas the other AI has its equipment teleporting to its body as it seems.
To give some context we are using world partition and the AI is set to spatial loading, although usually the entire map is loaded anyway (pretty small as of now), so this shouldn't have a big impact.
Furthermore the base mesh is the skm_manny_simple that has the materials set to hidden while all the cloth and gear are child components that use the leader pose node and use the leader bounds. The skeletal mesh is a skeletel mesh comp budgeted and we are using a custom AI optimization component that has different levels of optimization. the first one comes into play at 6000 units (cm) and has these values (though the AI here in this video are much closer so not sure if it is relevant).
I've also posted the base optimization settings for the mesh, very basic. Any help would be great! this bug is super weird.. maybe someone else has experienced something similar before
Perception doesn't know anything about your game's systems. You have to set it up yourself
For example, when the enemy gets killed, you could unregister it from perception. Or, you could have the AI bind to an event on the enemy which you broadcast when it gets killed so the AI can react accordingly
etc.
{
UBehaviorTreeComponent* BT= &OwnerComp;
BT->GetBlackboardComponent()->SetValueAsBool(FName("CanAttack?"), false);
UAbilitySystemComponent* ASC = UAbilitySystemBlueprintLibrary::GetAbilitySystemComponent(OwnerComp.GetAIOwner()->GetPawn());
if (!ASC)
{
return EBTNodeResult::Failed;
}
UClass* AbilityToActivate = BT->GetBlackboardComponent()->GetValueAsClass(FName("AbilityClass"));
if (!IsValid(AbilityToActivate))
{
UE_LOGFMT(LogChangerAI, Error, "Ability invalid.");
return EBTNodeResult::Failed;
}
int AbilityLevel = BT->GetBlackboardComponent()->GetValueAsInt(FName("AbilityLevel"));
ASC->OnAbilityEnded.AddWeakLambda(this, [this, ASC, BT](const FAbilityEndedData& Data)
{
ASC->OnAbilityEnded.RemoveAll(this);
UE_LOGFMT(LogChangerAI, Log, "Finished executing {0}.", Data.AbilityThatEnded->GetName());
FinishLatentTask(*BT, EBTNodeResult::Succeeded);
});
FGameplayAbilitySpec Spec = FGameplayAbilitySpec(AbilityToActivate, AbilityLevel);
const auto SpecHandle = ASC->GiveAbilityAndActivateOnce(Spec);
return EBTNodeResult::InProgress;
}``` Its crashing on FinishLatentTask(*BT, EBTNodeResult::Succeeded); am i doing something wrong? since this task is instanced and should be valid.
Hard to say. Check if this or BT is nullptr, that should give some ideas to start with at least
So we have some level variants and we have a dynamic nav mesh that should always update, also at the start of a level because some sublevels might be removed. When I simulate I can see it generating the nav mesh and then it just suddenly stops. The result of this is that an area that is blocked in another level variation, now has a gap there in the nav mesh. I'm not sure how reliable the simulation/nav mesh visualisation is, but to me it looks like it just stops generating the nav mesh at a certain distance from the center. Is this possible?
I don't remember off the top of my head, what does the function look like?
I mean what parameters does the function take?
Ah, are you using a stimuli source component or no?
Hm, ok not sure if this is actually exposed to blueprints in that case ๐ค
It's possible in C++ just fine though
Yeah the stimuli source allows you to make any arbitrary actor visible in the perception system.... pawns (eg. characters and such) get registered automatically with the system, so it's unnecessary on those as a result
You can place the stimuli source component on your pawns also - in that case you should be able to use that node to unregister them
When our player moves, the nav mesh is being updated. It's not creating a hole or anything (none of its component can affect the nav mesh), but it is regenerating. Why is that?
Every time you move the player the navmesh updates?
Or rather, it keeps updating as the player moves?
If that's the case then something in the player is set to affect navigation - it could be an actor you've attached to it or such also
whats the socially accepted way to destroy/stop AI on a pawn?
DeathEvent - i need to leave the mesh on the ground - i could do this in several different ways - but more importantly i need to:
1: StopLogic on the AIController/BehaviorTree
B: Destroy the AIController
42: just because i had to throw 42 in here....
I'm doing the following - BrainComponent is valid - but it still is executing the BTree....
BrainComponent->StopLogic("Death")
one thing i should add - this is comign from a delegate - is OWNERSHIP a problem here?
Hello, I have these two blackboards so that when the distance with the target is greater than 500 the AI โโteleports and when it is less, it walks, but regardless of the distance, only 1 is executed and it does not respect the blackboard condition, why does it happen this?
what kind of selector is it?
which?
Sequence tooltip - "if a child fails, then the sequence fails"
I assume you're fialing out on the first node tree probably... so the whole sequence fails.
The sequence is executed correctly, but it does not respect the blackboard, if the player is 200 away from the AI, he will teleport when the distance for him to teleport has to be 500
And sometimes, I'm 1000 away, and the AI โโwalks, not teleports
Okay so I need help if anyone can ping me here. Basically, I'm using behavior trees and AIController with AI perception, I want my AI to look at me when spotted, and then go into a rage (probably via another BT branch) so that way he doesn't break away from chasing me until I break sight. How can I do this?
Thereโs also option 3: destroy the pawn, replace it with a regular static mesh actor
please help me if anyone can
Right now, my AI rotates towards me and moves towards my position, waits 5 seconds and does the same thing
I want him to see me, rotate towards me, then go into a blind rage and chase me until either he gets me or he breaks sight from me
I have a situation where I am using a maze generator. Once generated, I expand a nav mesh over it and it is dynamic. Then I rebuild navigation.
I have a solid lag of about 10 seconds while it gets rebuilt.
The navmesh scale is around 50x80x1.
I tried to use navmesh invokers around the main character but for some reason it doesn't work at all.
Is there a way to mitigate or accelerate the navmesh gen?
This is my behavior Tree, what it does is: Whenever AI detects a sound it will first go to that location and do a random patrol at n number of points. The issue is when AI is running that part of behaviour tree where it goes to the sound location and does patrol search in that area, its not detecting new location, until its done running all tasks. I tried using on Value change on decorator but it doesnt work
this is the behaviour tree
Why would it abort if the value is still set?
to move to the new detected location
No, I mean technically the value hasnโt changed because youโre checking if something is set or not set.
Itโs still set unless youโre manually setting that key to nullptr
ohh...
then how can I make AI react to the new Sound Location
can I restart the whole behavior tree if it detects a new sound?
Im watching behaviour tree videos to understand more about it
You could stop logic and start it again, tho not sure thatโs ideal
Perhaps a service that checks if the new sound location is the same as the current one, and a Boolean decorator that checks its value?
Thereโs likely a better way, others might know
boolean decorator checks sound location?
No it checks true or false
A service can run an update the location and check if the location is the same as current one
So in case your sound still goes off at current location you donโt go aborting
But like I said, prly better ways
lemme try this, I have to create a custom service right? theres only Default Focus and Run EQS
Maybe even have the decorator observe the actual vector
Yeah you would need to create one
EQS is also a good idea
That BT video covers it
the one posted by unreal engine?
In this presentation, Epic's Paulo Souza uses Unreal Engine's built-in AI features to build smart enemy behaviors for a game with stealth-like mechanics.
By relying on the Gameplay Framework in Unreal, we're able to quickly create convincing AI using Behavior Trees. Behavior Trees are great for creating complex AI that can be presented in a way...
this one?
Just depends how complex you want to go ๐
Yeah
Hey there,
I'm currently trying to add a UPawnSensingComponent to an enemy character, but the editor keeps crashing (eventhough the compile worked well). Could someone point me to what im doing wrongly?
Declaration in headerfile:
UPROPERTY()
UPawnSensingComponent* SensingComponent;
Character constructor:
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
SensingComponent = CreateDefaultSubobject<UPawnSensingComponent>(TEXT("SensingComponent"));
SensingComponent->bWantsInitializeComponent = true;
SensingComponent->InitializeComponent();
if (SensingComponent->HasBeenInitialized())
{
SensingComponent->bOnlySensePlayers = true;
}
Pawn sensing was replaced by AI perception, so use that one insread
Unposses the AI controller
How do you iterate through the pathfinding result? Just need the list of FVectors.
This is the current code:
void ATestAiPathFindingActor::StartAiPathFinding(float NavMeshRadius, float AgentHeight, FVector TargetLocation)
{
ANavigationData* NavData = NavigationSubsystem->GetNavDataForProps(FNavAgentProperties(NavMeshRadius, AgentHeight), GetActorLocation());
FNavAgentProperties AgentProperties;
AgentProperties.AgentRadius = 550.0f;
AgentProperties.AgentHeight = 150.0f;
FPathFindingQuery query;
query.StartLocation = GetActorLocation();
query.EndLocation = TargetLocation;
query.QueryFilter = NavigationSubsystem->CreateDefaultQueryFilterCopy();
query.NavData = NavData;
query.SetNavAgentProperties(AgentProperties);
query.NavData = NavigationSubsystem->GetNavDataForProps(AgentProperties);
PathFindingResult = NavigationSubsystem->FindPathSync(query);
}
How can i set the Query Params of the property in a c++ class, actually from where i can set it?
@uneven cloud I'm experiencing a case where if the player runs into a moving AI with either a BTT move to or simple move to, that AI actor is pushed upwards. In my search, I see tons of responses to it but nothing definitive, yet you're #1 on the results.
I also followed a thread by the one and only everynone and it's not yet clear what causes this.
Would you have any tips on how to avoid it?
This is hte route I eventually went with - but it was a SkeletalMeshActor instead (ragdoll physics on a ACharacter class + skeletalmesh asset)
Thanks!
Hi. Is it possible to create Navigation Query Filter on fly? Imagine bot that changes its movement and area traversing abilities dynamically. Isn't that why filter class can have functions? I know that several filters can be made before hand, but it scales real quick with number of areas.
Never tried it, but if you just NewObject one maybe it'd work
IS there a way to overwrite a behavior tree? Say I have a parent tree that looks at you and moves forward, can you have a child tree for a child AIController that does something different while keeping the behavior for other AI?
You mean you want only the child to have a different BT and the parent to still keep the old one?
yes
How after object creation turn it into purple class, so ai and pathfinding can use it?
My bots have Run BT node on begin play. You can change it any time.
yeah but I want children AI Controllers
if I have a Run Behavior Tree node on the parent, and put the same nodes on the children controllers, I really don't think that will work
with different BTs
Put different node with different tree
Is this what you need?
Like this, lol. Now i have to find how to construct filter
Why my decorator is never executed?
I am using C++ and try to make it work with my current MassEntity setup.
But i found this code below which i will try to use.
TArray<FNavPathPoint> Points = PathFindingResult.Path->GetPathPoints();
for (const FNavPathPoint& Point : Points)
{
//Do whatever
Point.Location;
}
Ether way thanks for the response.
Looks like dynamic filter can be created only with c++. Will tinker with it later.
I'm not sure if this is the right forum. But my AI enemies lose navigation when reloaded in World Partition in 5.3.2. I know there was a collision issue with landscape components, but I turned off Spatially Loaded on the landscape stuff. But something is still making my NPCs randomly lose (and gain) navmesh connection on loading in. They will attack the player if close, but not move or chase, like if there was no navmesh. If I come back later after traveling, those same ai might work normally. If I reload in the area, they work fine. It's got to be the unloading and loading, but why? Any help would be awesome! If wrong channel, please redirect.
Nice will look into it
There's no "connection" to the nav mesh for them to gain or lose. Probably a problem with the nav mesh getting loaded. First I would verify the errors with navigation using the visual logger.
Is it the capsule that is causing the collision or the mesh? Something is going wrong with the collision resolution. Typically we add a push in the movement component in the on bumped functionality to control what happens when they run into each other.
you know what the fix was?
I was doing just about anything
I created a new collision channel called "enemy"
and set it up instead of pawn
somehow, SOMEHOW, it worked
I dunno if the default collision channels such as pawn are done someway or another but this is what worked....
I don't have the Navmesh bounds or recast set to be spatially loaded. Do you know why the navmesh would unload and reload? I thought only the stuff in the WP grid marked for Spatially Loaded unloaded and loaded.
By "connection" I meant that the AI could/couldn't see the navmesh. What you said makes sense, but I'm just trying to understand what is happening with a static navmesh in World Partition.
More likely that your meshes were blocking pawns and causing problems.
The navigation streaming isn't set up like other things in the world. The bounds is not the nav mesh. All it does is define where it will be built.
If the AI can't find the nav mesh, that means it doesn't exist. They directly use the navigation system for pathfinding. Like I said, you should start with finding out what the actual error is by using the visual logger. All of the navigation issues are logged there.
Does anyone know why my mass crowd AI's skin appears reddish from city sample crowds?
i thinks its cuz of lightning
I've created a variable of Blackboard key Selector in c++
UPROPERTY(EditAnywhere, Category = Blackboard)
FBlackboardKeySelector BlackboardKey;
and im trying to get its int value using this
void UBTDecorator_CustomLoop::OnNodeActivation(FBehaviorTreeSearchData& SearchData)
{
NumLoops = UBTFunctionLibrary::GetBlackboardValueAsInt(this, BlackboardKey);
Super::OnNodeActivation(SearchData);
}
But the value of the BlackboardKey is coming null always
i am also getting this everytime i build my project
Has anyone tried this in 5.4? Navmesh Generation for Large Worlds (Experimental)
How does it work? Do I need to enable something? ๐
Error: Ensure condition failed: ObservedKeyNames.Num() > 0 [File:D:\build\++UE5\Sync\Engine\Source\Runtime\AIModule\Private\BehaviorTree\Decorators\BTDecorator_BlueprintBase.cpp] [Line: 68]
Im getting this error everytime i build my project, i didnt used to get this error before today, doesn anyone know anything about it?
[2024.05.31-08.34.47:726][645]LogScript: Error: D:\build\++UE5\Sync\Engine\Source\Runtime\AIModule\Private\BehaviorTree\BTFunctionLibrary.cpp(41): Runtime Error: "ensureAsRuntimeWarning condition failed: (NodeOwner != nullptr) && (NodeOwner->GetClass()->HasAnyClassFlags(CLASS_CompiledFromBlueprint))"
[2024.05.31-08.34.47:726][645]LogScript: Error: Script Msg: ensureAsRuntimeWarning condition failed: (NodeOwner != nullptr) && (NodeOwner->GetClass()->HasAnyClassFlags(CLASS_CompiledFromBlueprint))
[2024.05.31-08.34.47:726][645]LogScript: Error: Script call stack:
[Empty] (FFrame::GetScriptCallstack() called from native code)
[2024.05.31-08.34.47:726][645]LogScript: Error: D:\build\++UE5\Sync\Engine\Source\Runtime\AIModule\Private\BehaviorTree\BTFunctionLibrary.cpp(44): Runtime Error: "ensureAsRuntimeWarning condition failed: OwnerComp != nullptr"
[2024.05.31-08.34.47:726][645]LogScript: Error: Script Msg: ensureAsRuntimeWarning condition failed: OwnerComp != nullptr
[2024.05.31-08.34.47:726][645]LogScript: Error: Script call stack:
[Empty] (FFrame::GetScriptCallstack() called from native code)
[2024.05.31-08.34.47:726][645]LogScript: Error: D:\build\++UE5\Sync\Engine\Source\Runtime\AIModule\Private\BehaviorTree\BTFunctionLibrary.cpp(52): Runtime Error: "ensureAsRuntimeWarning condition failed: BTComponent != nullptr"
[2024.05.31-08.34.47:726][645]LogScript: Error: Script Msg: ensureAsRuntimeWarning condition failed: BTComponent != nullptr
[2024.05.31-08.34.47:726][645]LogScript: Error: Script call stack:
Can happen if you have a decorator that is using Observer Aborts without any BlackboardKey
I will look into that
Is this what u are saying? Im using a custom decorator so it didnt had any BBkey
yes
@uneven cloud I find that unlikely since I set all physics volumes to ignore all channels/objects and same for the actual sk/sm. When doing hit checks it consistently only referred to the capsule collider root
will this work?
Potentially, yes
So to my understanding when the same behaviour tree asset is used, nodes are shared across all behaviour tree components, hence the need to Node memory. I am trying to find where this happens in the source code, but I am struggling a bit to understand how BehaviorTreeComponents are shared. My most fruitfull investigation showed that there is the UBehaviorTreeManager that keeps instances of loaded BehaviorTreeComponents, but I cannot find the part that handles the sharing capabilities. Any ideas ?
I'd suggest trying to trace where the instanced flag is being read. Maybe that will help you find where the choice between creating an instance or not is being made
There's a function you need to override. Initialize From Asset. Look at the BT task blackboard base to see what you need to do.
i need some help with BTTask - Ai Move To. When the AI enters this task is gets stuck and just stands there when only on success of finish execute is connected. When i connect regular exec pin, the AI wont even reach the destination. It just moves on to the next task. Any idea what to do?
This is the BP for the task.
This is the result when reg exec is connected.
AI never even traveled to the location. Just went on to the next task and consumed the object
and here i connected success only to finish execute and AI just stuck.
You really should use the built-in move to
Ai Move To only moves to an actor object
i just posted a picture of a BTTask where I do htat
and in that task I use built in Ai Move To
No. You are not. You are making your own move to BT task
I said you should use the built-in move to BT TASK
thats silly. Why would they allow people to make their own tasks if everyone is told to use built in
built in task does not work for my case as I want the actor to arrive at a random point around the object
Your BT task has several problems. First you aren't checking to see if you found a location. It's also returning immediately.
You are missing functionality from the built-in move to BT task like aborting the move and the ability to update the location.
This is incorrect.
what is incorrect?
That it can't do that. You can make a task to find a location, set it to the blackboard and use that for the move to
i see what you mean. I can try that. But I have a feeling is that the point I have that I calculate is reachable but not navigatable. It seems to be inside the mesh itself.
ended up being a collission issue. my meshes were set to block all and the destination not matter what approach I took was not navigatable. So making the meshes overlap, it is all working
both ways
Hey, quick question, how do I activate a Gameplay Ability from a StateTree Task (or a BTT I assume it would be the same) without an input tag, obviously for a bot.
Get a reference to the ASC and call activate
Found it, Thanks!
I got a question about nav mesh, we use Nav link to link the nav to each other, but does it need to be only done once, or does it need to be done and every possible connection?
Wherever you want the AI to โhopโ over a gap in the navmesh, you put a nav link
thanks for the reply, so any doorway or stairs etc?
Depends. You donโt always need to link something. For example, if a door slides out of the way, and you have the navmesh set to dynamic, it should fill in the gap automatically, provided itโs wide enough (supported agents and capsule radius come into play)
Iโve also used nav modifiers for when I want something to block or not block the AI on demand
And for stairs I think you generally want the navmesh to cover all the steps and just have your AI walk up on them
Hmmm I see, Where can I set the navmesh to dynamic?
Project settings. Be careful tho, you may need to ensure any moving actors have can ever affect navigation turned off so youโre not regenerating the mesh for no reason
@dense owl some stairs dont have navmesh on it, probably too narrow, but the nav link proxy added there fixes it
Fair enough, but does the AI jump over the stairs or walk over them?
walk down, the AI dont have any jump animations set up
Nice. It is also very likely that nav link proxies are cheaper than dynamic mesh perf wise so if that works, thatโs good
@dense owl nice! thank you, will use nav links at the other areas then
also this is the default navmesh generation, is there anything you think would be better?
I wouldnโt touch anything until you need to
Some settings in there can have intricate consequences
True, it works as is
@dense owl i don't suppose you know of any tutorials of AI being able to open doors?
I don't but I'm sure you can find some
Hopefully it's not too difficult to implement
I mean you can use timelines, animations, plenty of options
Hello there, is it possible to reference a BTTask within other BTTasks? I would like to implement an attack rotation. It seems really clunky if i have to always do
moveto -> rotateto -> attack etc for every single action, therefore I'd like to abstract it, but I cannot find out how to do that.
hey guys!! I am having some problems with how the AI controller is getting managed... actually I am trying to cache some controllers at the start of the play when the initial wave starts... and I want the controllers to stay in the game even after the pawn is destroyed... therefore, I overrid the Unpossess method and didnt call the base method... am not sure if thats how it should be done...
another thing is that when they are getting spawned, even the C++ version of it is also spawned, which I didnt really see with any other actors... is it normal??
The spawning is just like how we spawn normal actors:
You almost definitely should call Super::OnUnpossess and not doing so is very likely to lead to problems
If you're ever unsure of whether you should be calling the parent function, check what the implementation of the parent looks like. If there's any lines of code, chances are you need to call it or stuff will break
If you are spawning controllers yourself, have you turned off auto possess AI on the pawns? And if so, how are you spawning the pawns?
I mean even if I dont use it, it doesnt make a difference somehow, I was initially using the OnPawnDestroyed delegate for this
I don't recall what part destroys the controllers, but I would assume if you unpossess the controller when the pawn is being destroyed, that would avoid it from triggering the controller destroy logic
just checked and seems like the solution was to completely disable it... coz I initially set it to Place in World or Spawned
Yep, if you have it on the "spawned" setting it ends up spawning the controller for it when you spawn the pawn
aah!! the thing is that the destroy method for the pawn is being called on the pawn itself
Maybe breakpoint the EndPlay function in the AI controller to see where it gets called from, might help figure out what's the right way to prevent it
you are right on this... somehow unpossessing the pawn before destroying it indeed works!!!
thanks for the help mate!!!
๐
Alright, so I have two behavior trees with the same blackboard.The default tree simply check which state the NPC is in (idle, random travel or chasing player) and act appropriately.
I have a button, when pressed that change the state to Chasing player. It work and the NPC start chasing the player. Wonderful.
When I switch to the other behavior tree, using the same Blackboard, the key does nothing. It doesn't seem like the behavior tree's branch get aborted.
trying to have an ai to follow and attack a player but I want them to constantly follow them and never suddenly stop in place when they reach the ai move to, what is the way to do this
So EQS don't take into account agent radius?
If you want them the AI to slow down as they reach a waypoint and youโre using a char, turn on acceleration and deceleration for paths in the CMC
I think I figured part of my issue. Now part of the issue is fixed. But for some reason, it seems that when the NPC is walking toward a certain spot, it doesn't interrupt. I'm confident it changed AI tree as it changes speed, but it doesn't start moving toward the player. It finishes its travel toward the location first.
Alright, while the "Lock AILogic" seems to have fixed my behavior tree actually aborting, it doesn't seem like it actually abort the "Move to and Use Smart Object" though. It allow other nodes to run (example the one changing the movement speed) but it does not stop the movement. The NPC finishes it's movement and disregard the player.
And it does go into the correct part of the behavior tree, going to "chase player".
Anyone know how to interrupt the Move To and Use Smart ovject node?
Idk about smart objects but for stopping a MoveTo you can use StopMovement
Referencing BT tasks is a very very bad idea.
It doesn't make any sense to pool controllers. Just pool the NPCs.
I cant do that as the same controllers are responsible for spawning different enemy types
And sometimes they create them in batches specially when the enemy counts out numbers the controllers... like spawning random type of enemy for a given count
Hey All - Might be a silly question, but what's the benefit of Smart Objects? I watched a tutorial on them and they seem overly complicated vs having a custom BP and having the AI just look for a sphere overlap for the BP and calling an interface on it to claim it before moving towards it. I assume I must be missing something that makes Smart Objects much better??
They have nicer editing tools out of the box and support #mass and stuff like that
Of course if you think it isn't suitable for your usecase for whatever reason you can always implement it yourself, the basic idea isn't super complicated
Hi guys
i tried to make a simple patrolling AI that goes between patrol points and waits if that patrol point allows ai to wait. then i made a decorator to check if the current patrol point has allowed ai to wait (bool is true)
so if the bool is false i want BT to skip only wait node and continue to the next node which is increase path index
but when i set the bool to false, BT skips wait node and goes back to first node ignoring the increase path index node
how can i fix this
thanks in advance โค๏ธ
A decorator failure causes the whole subtree to count as failed, and as you're using a Sequence node, it stops looking for another node to execute on failure. In this particular case, you can probably add a Force Success decorator in addition to the custom one, which should make it simply skip that particular task if the custom decorator fails
thank you so much
I think I found what I needed. On the other hand, I need a bit of help to understand how something works. the "Move to and Use Smart Object" node has multiple handles. One that is the default, unnamed one, the on succeed, on Failed and On Move To Failed.
In my case, I used the On Succeeded and On Move to Failed. But Someone pointed out that the reason it doesn't end is because it's an Async Task.
Thus I want to understand how these multiple handle works together.
Am I correct that the first, unnamed handle start as soon as the Task Starts? It doesn't wait for the task to end, only to begin?
While On Succeed only trigger once the Task has run it's entire course?
Thus by saving the task I can call an End task on it if I abort?
The "unnamed" handle is the regular exec pin, it behaves the same as with non-latent nodes
And yes otherwise you are correct
Hey everyone!
Is the pinned course about Introduction to AI with blueprints still relevant for 5.4? Because I see it was done using UE4, and I don't know if its content is still useful or there are other practices or workflows that have changed over time.
This is the link: https://dev.epicgames.com/community/learning/courses/67R/unreal-engine-introduction-to-ai-with-blueprints/mX27/introduction-to-ai-with-blueprints
yes.
not much has changed in this area of the engine since
Thank you @dense owl, really appreciate it!
Hello, I have a weird issue with my AI nav walking. Anytime they get on any ledge, they refuse walking. I have got a screenshot showing an orange sphere which is the destination of the current path segment, and it's right on the same height as the AI regardless the slope. You can also see that the navgrid is correctly generated along the ground. Does anyone know why it might behave like that?
use visual logger to find out, speculation will only get you so far
open it. Start recording. Run the game. When you encounter the issue, stop. then click on the AI Controller for that AI, and go through the last few frames recorded. The log should tell you why the nav is failing
I ran it, and that's the first thing that is recorded related to the navigation
After that it creates two other entries saying OnSegmentFinshed. The fourth one says that it was aborted, most likely by my anti-stuck code
looking back at your video, the navmesh flickering is a bit concerning
are you using dynamic navmesh generation?
No, it should be static
I feel like flickering is due to the floor. It's fine on other maps
If it would regenerate the navmesh, I would imagine that those islands would change (since it's the only part flickering), but it doesn't since the path is the same, and it follows the same path segments
Hello, I made a 3rd person character follow the player, but I want them to float in air instead of walking, how do I do this? when I set gravity to 0, it stops moving
I want it to float up if I jump and float down when I fall
maybe you just pressed P after the video started ๐คท . I would try removing your anti-stuck code and debug again.
They only take place if the AI character doesn't move for 2~ seconds, so they will not affect it unless it's moving
I'll try running a fresh new AI with bare minimum of setup just to see whether the problem is on my end
Yeah, it seems to be. That's weird though since I'm using AIMoveTo with actor as the destination. I can't think of what can be in the way ๐ค
AI can get stuck in corners, sometimes increasing the capsule radius to make them fatter can help. Or using one of the avoidance methods (tho the latter is more for getting stuck in other pawns)
Capsule thickness doesn't seem to be the case. Just tried to make the radius be 5 on that working AI, and it still works
well now that you know it's something you're doing, you know where to start
One of the things that I noticed is that they walk as they should when their world static collision channel on the capsule is set to ignore
The last line in the debug information shows that
Then something is blocking them from moving.
will see
Hey anyone who uses State Trees + UE5.4 wondering if I can get some help. My State Tree Request Transition nodes are no longer working and I am wondering if anyone has experienced the same issue?
It happens on any ledge. One thing that I forgot to mention is that if I use walking, it works fine. It breaks on navmesh walking
Does the max slope on the movement component match the max slope in the agent settings for the navigation settings?
Hey,
This is like a message in a bottle right here but you never know.
I'm trying to use the AISense_Sight Perception in conjunction with the AISense_Team. Basically what I wanna have is :
- one target sights the player, gets a tag to enter the "alerted" state.
- this target then replicates the signal with AISense_Team to all targets in range so they get to the same "alerted" state.
When the player exits the range of a target it should also replicate the sense so any target loses the tag.
What I have now is somewhat working for the first part. In CPP i created this function : UFUNCTION( BlueprintCallable, Category = "AI|Perception", meta = ( WorldContext = "world_context_object" ) ) static void ReportTeamEvent( UObject * world_context_object, AActor * broadcaster, AActor * enemy, const FVector & last_know_location, float event_range, float passed_info_age, float strength ); that I can call from my BP (see pictures) . The propagation of the tag works fine, but the propagation of the "RemoveGameplayEffectFromOwnerWithHandle" is just not propagating properly. Checked the engine code and it seems the default engine wouldn't allow me to make it work that way.
So if anyone has an idea of what i could do/some workaround to this/etc... LMK!
I'm not quite sure what you mean that the engine wouldn't let you propagate some info to the others, there's nothing that stops you from doing this
I don't know if the team sense would be the one to use, but you could always just use a sphere overlap check to determine what AIs are within range and some custom interface for it
I'll need to check that out, but IIRC I haven't changed the default settings so it should be fine
yeah i was specifically implying that the engine wouldn't let me do this with AISense_Team
Ah right
Yeah I've not used the team sense so not really sure as to its capabilities, but I've done pretty much exactly what you're talking about via a sphere overlap :)
good to know
After some debug I found out an interesting thing in CMC code.
In my game I change the collision profile after 2 seconds after spawn from SpawnCollisionProfile (which is meant to ignore things around the spawnee) to default collision. However, CMC sets the response to world static and dynamic to ignore when navwalking it enabled.
So I suppose that I shouldn't touch those 2 collision channels. I guess navwalking makes use of some intelligent hacks to increase the performance of the movement, and I'm getting in the way like that, though I wonder how exactly it works. Hopefully someone can shed light on that part so that I don't have to dive too deep in CMC source code ๐
afaik NavWalking basically just locks it to the navmesh and doesn't do any kinds of other checks whatsoever
there's no gravity, etc., because the movement is literally locked to the navmesh
There is one issue that I have with that though that I still need to investigate more. Anytime my AI character jumps, it falls through the floor as the static world collisions are set to ignore. Reading the source code of the same function I just sent, it does this
if (DefaultCapsule)
{
UpdatedPrimitive->SetCollisionResponseToChannel(ECC_WorldStatic, DefaultCapsule->GetCollisionResponseToChannel(ECC_WorldStatic));
UpdatedPrimitive->SetCollisionResponseToChannel(ECC_WorldDynamic, DefaultCapsule->GetCollisionResponseToChannel(ECC_WorldDynamic));
}
which supposedly should set it to block as long as the default collision was block.
Now that I think twice, my default collision is set to ignore as it's assigned based on team during runtime. I think I can simply handle that in OnMovementMode changed
@misty wharf btw, we achieved it without collision sphere :)) still some tuning but it should work properly !
it's kindof a hack because you gotta make use of the signal strength of each of your sense stimulus to make it work but it works
Interesting approach... I kinda get the feeling that the team sense probably does a sphere overlap or something similar behind the scenes lol
nope, you should look it up in the engine
Ah yeah looks like it just iterates all listeners and does a distance check. Makes sense given it would have a list of them available
Fwiw, you can create your own senses also if you want to make a less hacky implementation of this :)
Yeah, it's not really the AISense_Team implementation that is problematic, it's more about the RefreshStimulus and ProcessStimuli functions in AIPerceptionComponent that were implemented in a way that we had to think differently x)
But yeah along the way it could be a good idea to implement our own sense if it proves useful
Yeah, seems it would be useful if you could pass f.ex. a FGameplayTag along with the sense event
I would be really shocked if it did a sphere overlap. That's the most expensive way to find nearby actors.
Anyone use that AI Flank To node thats recently free on marketplace?
The team sense always seemed like a half-finished thing to me so didn't think much about it lol
that's what we're currently doing manually indeed, we have a passive GA that sends a GE with tag depending on the perception changes
I used make noise with hearing perception for this, as if the enemy were really shouting out loud and only those who are close hear it.
What is the proper way to use Async Pathfinding?
I can i just use the FindPathSync on a custom thread?
And how do i know if the Async Pathfinding is done?
I got singel threaded pathfinding to work. But now i want to get Async pathfinding to work and then implement it into my MassEntity setup. I am a bit unsure were to start, have some functions which i plan to explore. And i dont see to many examples of Async pathfinding code.
Functions to explore:
FAsyncPathFindingQuery
TriggerAsyncQueries
DispatchAsyncQueriesResults
PerformAsyncQueries
This node AiMoveTo will call On Fail with Movement Result as "Blocked" when i set the movement speed of my Character to 0 for ish 5 seconds. Is there anywhere I can configure how long it should wait before calling On Fail with Blocked?
Specific events will change the movement speed of my AI Character, and during certain times, it will be 0 for longer and I would like it to not fail because of it.
iirc the path following component controls how fast it considers being blocked when no movement occurs but I don't recall whether those settings are configurable outside of C++
I see, well I do have a work-around, its not beautiful but it does the job for now. Maybe I'll convert it to C++ in the future. Thanks for the reply!
Is there some way to get a path from eqs instead of a single point?or more in general to get some path on different conditions than just the shortest without modifying the navmesh?
i have a logic/implementation question about using behavior trees, i have my vehicle AI written in AI controller right, every tick it calculates what it has to do, and depending on some conditions at the moment, it calcualtes steering, throttle and brakes using player inputs, since the conditions are becoming more and more complex, i figured I should start building a behavior tree for it, and my question is, should i put this basic driving logic to every behavior tree task file for every tick and calculate the conditions, based on the current task inside the task file, or should i keep this basic driving logic in the controller and just calcualte the inputs inside tasks and somehow feed the steering, throttle and brake data to the controller driving logic
ALL of the behavior tree tutorials i find, are for the built in character AI and they do not explain any logic and relation for self written AI and the behavior tree relation
so it's a little bit difficult for me to understand how should i go on about this
and literally all the vehicle AI tutorials i've found, do not use behavior trees