#gameplay-ai
1 messages · Page 58 of 1
yeah i suspected that
so basically i have to move many of my AI variables to blackboard
Anyone writing custom C++ BT tasks, I'm finding it tricky to use delegates to control tasks as it seems that both Node Memory and Owner Comps are a) only directly accessible when using task virtual functions and b) changeable such that memory addresses for the above objects are subject to change before task completion, so saving pointers during execute is inconsistent. For example, I have a callback to when my character changes state, but binding a task function disables being able to pass node memory around. How do people handle this?
So here's my Event graph. I'm trying to get A.I. walk from point A, to B, to C, and when it gets to D it stops how do it fix so it walks around the whole area in a loop
So I'm getting the impression services in the path to the current task don't run during the execution of a long task? But decorators in the path to that task are still being evaluated etc.?
Anyone here work with smart objects? I can't get any of the nodes related to tags to work. I am providing a valid slot handle/smart object handle, but it seems like these nodes just do nothing currently.
"Get Slot Tags" and "Get Instance Tags" always return nothing, even if I input the same slot handle I use to get the slot location, which does work, and required filtering via tag, so I know the slot handle is valid and has the tag, but using these nodes to print the actual tag(s) returns nothing
Use AI tasks for that.
What's an AI task? Google refers me to BT tasks only.
From forums
AI tasks are an extension of gameplay tasks and are mean as main communication layer between all sorts of logic sources (BT, FSM, level scripting, extermal-induced reactions, etc) and the AI entity itself. In 4.14 I’m going to flip the switch and BT tasks by default are going to spawn AI tasks instead of directly messing with AI agents’ internals. Both Paragon and Fortnite have been successfully using AI tasks for some time now, and Gameplay Tasks are also a super set of Ability Tasks used by Gameplay Abilities System
Ok, but I don't see how this solves the problem. The issue is that if you're managing behaviour with a BT, you can only end the task with a ref to the owning controller's UBehaviorTreeComponent, which generally can't be captured in bound delegates. So if you call an AI task from a BT task, you still have problems ending the initial task, as far as I can tell.
UBehaviorTreeComponent* OwnerComp = Cast<UBehaviorTreeComponent>(GetOuter());
This is the answer.
What type of optimization methods should I consider with mass AI?
Guys, AI pawn sense doesn't sees me through the wall on the first time. But when I get sight than ai always follows me. Only way to stop it is getting behind pawn sense. So just after chase starts the walls can't help, why?
I wathed few tutorials and this problem only happens with me. I just don't understand why that happens
If getting behind the ai wouldn't work. Than I would understand the problem, but the fact that walls won't help after first sight cracks me
Hey guys, silly question about State Trees.
I have an STT that outputs a vector (variable is set as output).
I want to grab as an input that variable in another STT that is not a child of the previous one. How can I do that ?
I'm always able to get the variable from one STT to another if the latter one is a child of the first STT but not if they are siblings
You can't. You can only bind values between tasks that are in child states, or if the tasks are within the same same state
So what are my alternatives ?
Global tasks or evaluators mostly I guess
Possibly extend the schema to support additional parameter values you can store
I have made a base AI I am satisfied with. How can I create offshoot of that AI? Like, make other AI that have the same base functions but with the option to override a function or event if I think it's necessary for the other AI? What is the clean way to do so?
Is there a way to debug the the sight sense for an AI ? Like, see the sight cone basically
Because when I tick show > senses in the viewport, it doesn't show anything
Gameplay Debugger should show some info for perception
I've used my STT to set a vector variable in my actor, this way i can always keep track of it. Not really satisfied with this option but the prototype is working fine
I didn't know this functionality. However I activated it, activated the perception debugging, and there's still nothing shown. I might have messed up my setup
if you are trying to handle a result of some logic (be that component or gameplay ability) in BTTask, i'd suggest you taking a look at brain messages features, i.e. in your UBTTask_MyTask::ExecuteTask you can call WaitForMessage and specify the tag of the message and later call it from whereever by using UBehaviorTreeComponent::HandleMessage(const FAIMessage& Message)
Interesting. I may circle back to this. For now, I just subscribe to delegate calls in the AI controller, which itself triggers a delegate that broadcasts a reference to its BTComp. From that you can get the AI controller through GetOwner() and get a ref to its Node Memory and so do pretty much anything you want. Cheers for the idea 🙂
Look at the BT task move to and how it uses the AI task move to.
Don't use systems that were depreciated in 2016.
No one, including Epic uses that old functionality anymore. They used to, but switched to using AI tasks.
I am trying to find ways to optimize my AI (heaps of zombies). If I was to unposses the AI controller, will that disable character movement/ticks? I am trying to disable far away AI and only enable the ones near the player.
Can someone explain whats happening here? the player is unable to lose sight of the AI and still it goes to the roaming, i still dont understand the issue
This is the behaviour tree of that AI, at first the player is not in sight so it is doing the task on the right most of the behaviour tree when it comes in sight it switches to the task in middle to follow the player. Now when player jumps even tho it didnt lost the sight AI goes back to roaming
the first video and the 2nd video are not same
I think it’s better to use level streaming for these things
What do you mean? Can you go into more detail/laymen's terms please?
Asynchronously loading and unloading levels during play to decrease memory usage and create seamless worlds.
You mean world partition? I already use that.
No it's not. Turning off AI when the player is not close enough is incredibly common.
anyone? i need help in this please
Turning off how? I thought you’d said level streaming does that but alas memory is not what it once was 😅
Never once said that. You turn off whatever you need.
Ok
Guess I thought if the object is unloaded by WPO/streaming there’s no way the AI that possesses it would be running, but every day is a lesson
You need to point at the AI you want to debug, if you're too far, it sometimes don't auto target the AI
Hello. I'm facing an issue with UE 5.4 I migrated my project and suddenly I get a crash / error saying that my nav mesh bounds are too large. I have a very large open world and want AI to work anywhere. So what I did in my old project is just place a massively huge navmesh bounds volume because that seemed to be the only way to have invokers be created around AI pawns. This never gave me any issues, until now in 5.4. So what is the alternative / better way to make AI work in a massively huge open world?
What I don't really understand is why the tooltip for "generate navigation only around navigation invokers" says "this will make the entire world navigable" yet it doesn't, because it only does when you still place a nav mesh bounds volume that you have to scale extremely large, which then results in the above error. So how does one truly enable open world navigation? The tooltip seems to be incorrect?
Ever find a solution to this? project wont compile because of the missing AIMODULE_API
Was wondering, can the default cost of NavAreas or the override cost of NavFilters be changed at runtime?
Basically it's a problem with Ur perception angle of view idk what's setting called it allows ai not to lose perception when players jump across ai
Idk what's setting called
I solved Async Pathfinding and got it to work so i will post my current solution. Is there any way which i can batch several pathfinding request?
it is not losing perception but the stimulus is getting expired
I have 3 doors. The player clicks on the door and has an ai walk the camera to the door. When I click on the left door, it walks straight. I am peprplexed
Hey, does ue5 support sharing of a behavior tree and blackboard across multiple agents? I am wondering how BTs can handle large number of entities all at once
Yes, ofc
You can also have subtrees if you want only certain branches to be shared (must have same blackboard tho)
But what i am missing (and remember that I have 1k actors), is that there is a BT assigned to an AIController whoch is assigned to my actor. And if I remember correctly, there is a ahed cap of 20/30 ai conteollers at a time.
So I sont understand how BTs can scale to those levels.
And it is totally okay of they are not, I kust want to make sure I am not developing something that is already supported 😀
When you’re talking thousands #mass might be a better option regardless
yes of course it would be my next attempt 🙂
Anyone able to figure out this out? #gameplay-ai message
I might have to use a different method if not, I’m stuck LOL
You can do this via C++, it's a bit fiddly though but possible
I have a problem, when my AI makes attacks, due to root motion, it often stays above my character and loses the vision sensor, therefore it enters the passive state
How can I prevent me from losing the character that is in focus when stop seeing him?
So, what's with the BT nodes API issue in UE5.4? I've updated my project from 5.3.2 and all of a sudden I get compilation error pointing to engine's nodes (I assume because I inherited them in some of my own BT nodes). I remember facing this issue when 5.4 only came out in preview and I rolled back to 5.3.2, but back then somewhat of a solution was to manually override all non-exposed methods (OnBecomeReleant. InitializeMemory, etc) just for the sake of it. Is there any better solution now?
so, uh, do I get it right that epics messed up BT nodes code, dragged it from 5.4 preview to 5.4 release, and 2 months in the problem isn't fixed in EGS engine version and nobody in epic isn't doing anything about it? 🙊
lol why
maybe it's too dark inside. jokes aside, maybe you have incoherent settings in CMC nav agent capsule shape settings, actual character capsule shape and the one in project settings in navmesh section which is used for generating navmesh?
You mentioned a lot of terms that I've never heard. lol
I'm sure nav mesh could be better since mine does its job but it's super bad looking
have you changed the NPCs capsule shape? perhaps made it bigger? also I'd recommend checking collisionon the doorframe and checking navmesh overall if NPC is even supposed to pass there
your navmesh is fine, NPC should be able to pass there
but incoherent nav agent (any AI that can walk on navmesh) can still be a problem, because navmesh generation takes it into account
Collisions seem sweet
The fact is that my AI can easily pass around the house without problems but sometimes he starts jittering stuck to doors or during patrol decides to walk against the wall
Like here the sphere shows the area where he should look aroun which is small but in-game he was walking towards the corner on the left
@keen crow nav mesh goes over objects sometimes like bed and chests.. AI still doesn't walk over them so it's fine but maybe it triggers some problems?
well, again, there can be several reasons why can AI's movement on navmesh look ugly, I can only suggest you check on some of the possible reasons, but giving you a 100% correct answer is just a matter of trial and errors in your project. so I would
- check that navmesh generation nav agent size, actual character capsule size and CMC size are coherent. If you didn't adjust any of those, you can ignore it, as default should work
- check that all relevant meshes have Can Ever Affect navigation set to true if they actually should
- Check that in your BT/ST it doesn't happen that AI is constantly switching destination or something
- Maybe you've enabled RVO in your NPC's CMC settings and set some big avoidance radius and hence your NPC is constantly trying to avoid player while it's path lies through the player
Character Capsule
One is its normal capsule, another is to trigger stuff when touched
What's CMC?
What is RVO?
How do I check that nevmesh generation nav agent size? Didn't you say that the nav mesh is fine?
character movement component
Reciprocal Velocity something something avoidance, it's a mechanism built in CMC (considered outdated) that allows NPCs to avoid other characters (or I guess any actor having velocity) when moving. It's known to produce errors in navigation because it doesn't take navmesh into considerations when it moves the nav agent a bit to the left or to the right to avoid obstacle, also in my experience it can introduce some jitter for the NPCs. CMC has a set of parameters for RVO, but AFAIR it's disabled by default
The navmesh looks fine but you must understand that navmesh is generated for a nav agent of some radius with some max step height and max step angle properties. You can have multiple nav agent types (small NPCs, big NPCs) and they could have different nav mesh. So it is possible that you have a default navmesh generation settings but for gameplay reasons you've made your NPC capsule bigger for whatever reason. Judging by your answers it's not the case but I'm just sharing my considerations on what I would have checked had I your problems
There's not RVO in my CMC.. Maybe because i'm in ue4?
I'm tweaking cell size and height and it is more good looking now even tho the ai can't climb the stairs anymore now. requires more tweaking.. so far it doesn't seem to be a huge improvement
it should be, just type in "avoid" in CMC details search bar
Okay I have it on false
well, then you can try either
- for testing purposes shrink the NPC's capsule component radius to half the size just to see if it starts to pass smoothly through narrow gaps after that. If so, maybe either tweak the navmesh generation properties or perhaps change the level design to widen those narrow parts
- if that doesn't help and if it happens not only in narrow paths but everywhere, then try to see if the AI is actually constantly changes final destination point, maybe you have multiple EQS services running at the same time and updating the same blackboard property or something
Boh.. I tweaked a bit.. I hope he won't get stuck when game will be released
I'm not at my computer but so figured I'd shoot message in here just for rough idea/direction.
Currently my fps grapple game uses a lot of NAV links to handle enemies jumping to the different platform.
Say I had two equal size platforms side by side, one raised higher. If I wanted to enemy to jump down/up when following player is there any easier/better way to handle this dynamically then just placing a bunch of NAV links around the platform?
Easier? Doubt it. Better? Maybe, but get the feeling it would be kinda complicated to set up in a way that works reliably the way you want. You could for example attempt to do some kind of custom test to determine whether the unreachable position where the player is was possible to reach via jumping or something. I think there was also some code in one of the published UT codebases that automatically placed navlinks so you don't need to manually do it
Yes, it is jacked up in 5.4 and it is fixed in 5.5 currently. It couldn't make the hotfix patches because it would mess up binary signatures (according to an ex-Epic employee)
5.4 seems to be the most broken release in a while...
fascinating
There’s a 5.5 on the branch? Neat
Anyone else experiencing behavior tree problems with 5.4? My enemies work fine in PIE but don't move around at all in the packaged game
When do you start the behavior tree?
I have 4 monsters placed in the level, not spawned. Single player. Is that the problem?
event begin play > run BT
ok thank you!
simple as this?
yes
thank you! I greatly appreciate it 🙂
interesting that it wasn't an issue when I used 5.3
It could have been an issue
You were just lucky to not encounter it
There is no guarantee that you'll have a Pawn when the controller's BeginPlay is ran.
I see... so the ai controller was loading before the pawn was
hmm I did another package build and same issue. Enemies doing idle animation but not walking around.
| might have solved this kinda
~~Hi, I'm trying to make a function that detects what's in a image (a cat, a dog, a car etc)
I've come through this thing called "neural network inference" the newer version is called "neural network engine", and some stuff have changed, the tutorials from 2 years ago are all outdated,
only tutorial I can find is this, https://dev.epicgames.com/community/learning/tutorials/34q9/unreal-engine-nne-quick-start-guide-5-3
but I've having trouble understand it, should I put the script in an actor or an object?
the old tutorial: https://www.youtube.com/watch?v=LX1w_etaftY
said I need to put the code in a "neuralNetwork" class, which doesn't exist in ue5.3.
why are there red lines under stuff like "INNERuntime" am I missing a dependency? am I missing an include, if so, what is this include.
hoping for directions.~~c
Learn about all the steps required to run a neural network on CPU inside Unreal Engine.
In this video we will show you how to setup a basic scene in Unreal Engine 5, add plugins and logic to run machine learning in your projects.
Unreal 5 Release Notes on the NNI Plugin: https://docs.unrealengine.com/5.0/unreal-engine-5-0-release-notes#neuralnetworkinference
Unreal 5 Setup: https://docs.unrealengine.com/5.0/installing-unreal-engin...
Delete the navmesh stuff and recreate it. That has been an issue I've seen in the past.
I'm having a bit of trouble with my nav mesh agent radius. I've changed it in my project settings, but it has no effect since I have a RecastNavMesh-default actor (which spawned by itself?) which changes the value. It doesn't seem to matter if I change the value on it since every time I restart UE it resets to a default value. How do I change this so the change sticks?
You need to create supported agents
Thank you
I have this problem. I asked about it before, and was also told to look at the VisLogger. Can't be sure since I don't know much about it, but I didn't seem to find any answers in there. IIRC, the log is too big to post here.
I mean, nobody seems to know anything about it anywhere on the interwebs. It happens randomly to only some of my AI, usually after going across my map in World Partition. Like you, it seems that the Navmesh is there, but some AI stop moving towards my Player and only attack when you get close (as if no Navmesh). On reload in the general area of the problem (from savegame actor), the same AI enemies or areas then work perfectly.
I've been struggling with this for months. My demo will be in NextFest this week, and I have to accept that this unwanted behavior can't be avoided at the moment, which is a bummer.
Thank you again- it was a Nav mesh problem!
I had this problem yesterday. I deleted and recreated my nav meshes, migrated only the levels I'm using to a new project, and then packaging worked
All navigation errors are logged to the visual logger.
Can also turn on log lognavigation verbose and log logpathfollowing verbose
For more detailed logs
Hi guys
I have couple questions about navigation's weird behavior. First of all why does ai doesn't choose the shortest path but hugs walls instead? Every time i use unreal navigation i get results as on first picture where car rides on the red path instead of blue. Is there easy way to change it? I really don't want to write my own local navigation because i already had to write my own global navigation using Dijksta.
Second thing is that agent radius parameter in recastnavmesh is always set to 35 in runtime even though i set it to another value in editor. It doesn't matter if i'm using regular navmesh but it does when i use "Generate navigation only around navigation invokers". When i use this option the radius around obstacles is always set to default value. Can i change it someway?
I don't know why it wouldn't follow the shortest path, never seen that happen, but check this for the agent radius issue https://zomgmoz.tv/unreal/Navigation-System/Configuring-navmesh-settings
Do you mean it should follow the blue path by default? I've seen many people asking about ai going too close to obstacles but haven't ever seen a solution.
It definitely should be following it at least on the left side
I've been already trying to set agent radius in project settings and it never worked.
Did you configure a supported agent?
It seems sometimes to be a bit inconsistent about which setting it follows and may require one
(or it might be I never paid enough attention to how I have configured it in my projects where I needed to do that lol)
I'm not sure what do you mean by configuring the agent. I did change it's radius in nav movement.
there is a setting called supported agents
Do you have any video where agent takes the shortest path instead of huging the walls? At this point i'm almost sure they do this every time
try adding one into that list if you don't have yet, and configure the radius there
I don't have videos of it but I've not noticed this behavior in any of my projects. I'm not using nav invokers or such though, so I don't know if it's some weird issue with them
Oh I've tried this already. The problem I have with this one is that when I use Supported agents my recastnavmesh disappears during runtime and navigation isn't calculated at all.
I've heard invokers are problematic but can't really say for sure since I've not used them myself 🤔
Tbh my issue with ai not taking the shortest path appears even when I'm not using nav invokers.
Thanks fpr your help anyway 🙂
Hello, I'm trying to write a move to task at the end of my "EnterState" Function in a C++ State tree task. I need to bind to the result of that task to return the correct value of EStateTreeRunStatus. However when I bind a lambda to the Path Following component's OnRequestFinished delegate I get compile errors. Is there a way to do this or am I stuck using the blueprint state tree tasks?
Okay nvm I found a good example of it in the "PlayContextualAnim state tree task
Here is video if you would like to know how it looks
It's just goes to the green ray, not the red ones
When it comes to the heuristic weight/scale, what effect does that have on navigating a path from point A to point B? What should the moving objects behavior be if the heuristic weight is zero versus one versus two and in between
how to cutomize FNavigationQueryFilter ? why the hell is there wrapper over wrapper ? i just want to override some functions for dtQueryFilter
🤔
Hey, I'm trying to use RegisterNavigationInvoker() for my player cause it's really suitable for my game design, but it doesn't seem to be working cause I don't see any Nav geometry rendering after pressing P in the editor, and my NPCs just stuck unable to do any pathfinding
Using a NavMeshBoundsVolume worked fine for me but I really want to switch to invokers
I call RegisterNavigationInvoker() in player's BeginPlay(), and UnregisterNavigationInvoker() in the EndPlay()
I also set bGenerateNavigationOnlyAroundNavigationInvokers to true
Don't know if that's all for the setup
You still need to have a bounds volume when using invokers. There's also an nav invoker component that should be used instead of doing it manually.
I'm recreating the AIMoveTo Blueprint Node in C++ here's the C++ code, however, the character is stationary, and when I look at the behavior tree which uses the C++ task, it is instantly calling and ending it repeatedly (specifically im tryna have the player wander so pick a random location within some radius and move there)
And here's the blueprint which I'm trying to recode (the blueprint works fine btw):
Me a couple hours later...
I was recommended to just derive from the BTTask_MoveTo so I did that, and I'm more lost than ever,
NodeMemory barely makes sense, apparently I'm supposed to make custom structs to store values?
I can make my own struct sure but when I look at the example MoveTo Code there's just way too much going on for me to understand.
Like one second the code uses NodeMemory and the next its like fk it we using the BlackboardCompoennt now
when i'm referencing the code ^ I mean like Unreal's "Tasks/AITask_MoveTo.h"
I don't understand why you aren't just separating this functionality into 2 different BT tasks. One to find a location and then just using the built-in move to. You're doing a lot of extra work to not even get the base functionality of the built-in task.
Id clash in non Game and non PIE world. This should be incredibly rare!
Does anyone have experience with hitting this ensure when using NavLinkProxy components in Level Instances?
And does it matter?
It started happening in 5.4 I believe.
For context, we have a door blueprint with a smart navlink component. This door is being used in level instances for houses.
// During PIE or game we just generate a new Id, this is most likely to be from a runtime (non editor placed) prefab like a level instance but could be from
// a legitimate but extremely unlikely Id clash after loading.
// If this occurs in EWorldType::Editor world it's a legitimate ID clash, currently we do not handle this edge case here as it should be incredibly unlikely to occur
// and we do not save changes when cooking or building paths running a commandlet etc.
This comment is above the ensure.
any luck finding the answer? My AI is also doing this weird behaviour from time to time.
Create 1 task that will set Reachable Point, and then with 2nd task MoveAi To that point.
somebody can help me with my AI Enemy? i took a project where i'm not the first dev so im lost with a dumb ai that dont even know whats happening
i can show the project tho
I have no idea. I don't have this problem in fresh project.
is it possible to attach the AI controller to a skeletal mesh component i have attached with the pawn instead of directly attaching the controller to pawn? Whenever the character is comes in sight of the AI the whole body turns to face it, I only want the skeletal mesh component(Head) to face the character
You can try using the Focus feature, iirc set focus or such. I recall with the appropriate settings you set focus to something and it only turns the head towards the focus target by default
There's nothing automatic that turns anything "when character comes in sight of the AI" so if you have logic there that turns the whole actor, then that's what's gonna happen
i have controller attached to pawn, and also passing the value of player's location in the set focal point function
try using one of the other focus priorities if it turns the whole actor
I'm fairly sure I used this in my project and it turned just the head but I don't recall the specifics
is there somewhere a BT and ST pros & cons ?
i find it very hard to find what would fit the best and whats the most "optimized" and "modular"
hi, did you solved it?
can you help me with this? I also try to have the AI flank the player 😅
Unless you're comfortable with C++ go with BT's. StateTrees are nice but they seem to be kinda heavily work in progress and have a few oddities here and there that you may have to work around or figure out from the code
i guess i'll go with BTs
but, what do you suggests if i want to stay in c++ zone ? i was planning to dev the tasks in c++ and use them in the BTs
You can write BT tasks just fine in C++
Although personally I find I often write them in BP's since there's often at least some latent actions occurring in them, and those are a bit less of a hassle to work with in BP's at least in my opinion
okay
regarding both of your suggestions
^
even if i do that, my issue is that I'm unsure how to make the ai move. Like the code seems to work but the actual actor ain't moving at all.
I've tried the deriving from the BTTask_MoveTo and doing it myself, the actor stays in place
Honestly - it is wild that your solution is to rewrite that instead of investigating why it isn't moving
Considering the thousands of games that have released with this exact setup (one task to find a point and another to move to it using the MoveTo task) - something is wrong with your setup
okay if i'm given an actor location
- target location
how do i move to that
like even if i do the setup ur recommending i still dunno how to get to that point
Store it as a BB key, then use the move to task and set the target to that key
Make sure you have a valid navmesh as well
None
and do i just pass in the default ownercomp and nodememory
It is a built in task with the engine
oh that one
okay just to confirm
are these accurate? if (moveResult == EPathFollowingRequestResult::AlreadyAtGoal) { return EBTNodeResult::Succeeded; } else if (moveResult == EPathFollowingRequestResult::RequestSuccessful) { return EBTNodeResult::InProgress; } else { return EBTNodeResult::Failed; }
Can you show your behavior tree? Did you try to debug it if it's even firing? You can look into Behavior Tree to see the flow.
and Wander is with that AiMoveTo node?
Do the setup that you've been told at least 3 times now.
ikik thats my old tree
can you please answer this
lol then show updated? xd
The snippet of code in a vacuum means nothing really.
This behavior tree Wander task is written in C++?
hmm
EBTNodeResult::Type result = Super::ExecuteTask(OwnerComp, NodeMemory);
if (moveResult == EPathFollowingRequestResult::AlreadyAtGoal) {
return EBTNodeResult::Succeeded;
}
else if (moveResult == EPathFollowingRequestResult::RequestSuccessful) {
return EBTNodeResult::InProgress;
}
else {
return EBTNodeResult::Failed;
}```
better?
im in a class that dervies from teh moveto
task
yeah i prefer C++ cuz i can interact pretty easily with other classes
You are doing absolutely useless work
ouch
Just do the setup you have been told
It's better to first create prototype that is working, and then translate it into C++ for example. Right now you have no idea what is wrong, if its the behavior tree setup, code or maybe you dont have even ai controlleron your pawn
Ok how do ik if i've reached the targetLocation so that I can choose a new random location to wander to?
EBTNodeResult::Type UBTTask_Wander::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
EBTNodeResult::Type result = Super::ExecuteTask(OwnerComp, NodeMemory);
if (moveResult == EPathFollowingRequestResult::AlreadyAtGoal) {
findNewTargetLocation();
return EBTNodeResult::Succeeded;
}
else if (moveResult == EPathFollowingRequestResult::RequestSuccessful) {
return EBTNodeResult::InProgress;
}
else {
return EBTNodeResult::Failed;
}
}```
All you have to do is provide a location or actor
No, you don't seem to know
Make the task to get a random navigable point in C++
If you want to use C++
Alright I did all that and my ai still aint moving
Do I need to setup player input component by creating the move, look, and jump bindings? Does the AI use those when moving around the level or does it use something else
and i have tried with both moveto and movedirectlyto
Use Move To
Do you have a nav mesh?
yeah ofc
uk how for player to move wasd u gotta setup player input?
does ai need me to setup wasd?
or does it use some other form of moving around
AI doesn't care about keyboard inputs or anything like that
It should work for navigation if it's a Character. If it isn't a Character, it needs to have a compatible movement component added to it
Why won't you put that Move To node task that is already built in and just check if it's the code problem or not first? xD It's 5 seconds
maybe your code is right and you didnt set something else
did you tell your npc to run behavior tree?
sir
thats
what i did!
yeah i did tell him to run behavior tree
i first trieed moveto
then movedirectlyto
both same result
show us code inside these nodes
and how are you setting black board key inside find new?
the blackboard key works fine like i see the value changing to a valid location
but here it is anyways
EBTNodeResult::Type UBTTask_FindNewWanderLocation::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
if (auto pawn = OwnerComp.GetAIOwner()->GetPawn()) {
if (AAIController* AIController = Cast<AAIController>(pawn->GetController())) {
FVector actorLocation = pawn->GetActorLocation();
auto navSystem = UNavigationSystemV1::GetNavigationSystem(GetWorld());
FNavLocation targetNavLocation;
navSystem->GetRandomPointInNavigableRadius(actorLocation, 10000, targetNavLocation);
OwnerComp.GetBlackboardComponent()->SetValueAsVector(GetSelectedBlackboardKey(), targetNavLocation.Location);
}
}
return EBTNodeResult::Succeeded;
}
2 things:
show me in Ai Controller on Begin Play your setup
run game, click P and do screenshot of your nav mesh, is it green where it should be?
yup everything green:
the guy getting scaled is the ai
and yes aibehavior is set in the blueprint
Try to lower Radius of points, maybe it's choosing some crazy number and cannot go there
maybe
you meanunreal's outputlog?
or like the visual studio output i get while building?
Tools->Debug->Visual Logger in UE
Press record, then play in editor so that the BT stuff runs. It should show a timeline of sorts about different events that occurred during the PIE session
If you then click on the events or use the time marker to move around, it should display more info
Did you set it so that the controller possess on spawn and on placement?
Also, don't run the BT on BeginPlay, do it on possession
yeah
That suggests it's attempting to move at least
yeah
I made a test blueprint function that uses Controlled Pawn i'll provide img of the workflow
When I play i get the below error
PIE: Error: Blueprint Runtime Error: "Accessed None trying to read property K2Node_Event_ControlledPawn". Node: AI MoveTo Graph: EventGraph Function: Execute Ubergraph Test BTTask Wander Blueprint: BTTask_Wander
we recieve Payload in statetree only in c++?
i've done all you said, i think, but uh the onpossessed and beginplay never run
Well that points to a different problem
yet somehow in the world I do see my controller just chilling in the center of the actor
oh wait
i dont nvm
it aint using my aicontroller
just the default one
You need to set it to use the correct controller
does this look right? tghis is my bp_aicontroller class defaults
cuz rn like everything seems to be working excep the behavior tree which never runs
Can anyone help me out with some issues im having with my AI
would be easier if it was in call to show properly what the issue is
Would be easier if you just described the issue and provided relevant screenshots if need be
I can describe it but showing screenshots will be hard as I need to show its movement in action
Effectively though while the AI moves it is like spam sensing and forgetting the player even when infront of them
and its causing the AI to freak out between patrolling and attacking in the behaviour tree
Have 0 clue what is causing this as ive done this type of AI tons in the past
Typical causes for this are something blocking the LOS, or the AI's movement logic making it turn enough to lose the player from its sight cone
If you've f.ex attached guns or other meshes into either character, they can also block the LOS trace
@misty wharf So does AIPerception only percieve the player and not attatched components?
Perception attempts to do a trace to the target actor, if it hits something before the target actor, it considers the target hidden. It doesn't check if the hit actor is attached to the desired target
Hmmm
Lemme screenshot some stuff in an attempt for you to assist lmao
cus im not really sure what is causing it to bug out
oh wait
hang on
On a controlled AI, where does the AI percieve from
if its a character
the AI Pawn is the top
and the bottom one is the player
Looking at it now I think it might be the static mesh on the character
as we used that instead of a skeletal mesh so we could avoid re-coding its basic movement stuff
It's possible. Try setting all the meshes to No Collide
Also, the collision channel for LOS checks is Visibility by default I think... it's configurable from project settings
ah okay
I didnt realise I could change that
thanks
Ill try them out
Yeah it was the mesh
such a stupid bug lmao
figred it out thanks
Look at is animation based which is what you should be using for just moving the head. Only pawns can be controlled by ai controllers and they are not "attached".
Why aren't you checking to see if you actually got a valid point?
The behavior tree should not be started in begin play. It should be in on possess.
Can someone explain to me like I'm 5 what "Services" are for and some examples of how or when to use them?
I can't understand them no matter how much I have read already.
by valid point I assume you mean the value is set.
So to answer that yeah I was troubleshooting then and hadn't implemented fukll functionality so no decorators.
Having finished troubleshooting, I have added a decorater that checks if the blackboard value is set
And the second point you are also correct I fixed that too
By valid point, I mean that the navigation system returns a valid random location. That function returns a bool. You should use it and have the task succeed or fail based on that.
yeah i didn't do that ill fix it rn
bool bSuccess = navSystem->GetRandomPointInNavigableRadius(actorLocation, searchRadius, targetNavLocation);
if (bSuccess) {
OwnerComp.GetBlackboardComponent()->SetValueAsVector(GetSelectedBlackboardKey(), targetNavLocation.Location);
return EBTNodeResult::Succeeded;
}
}
}
return EBTNodeResult::Failed;
perfect
Services are executed when the underlying branch is running. They have 2 main uses:
-
runs a tick on a set interval usually to update data. Such as updating targets.
-
Doing something when entering and/or existing that brach. Such as setting the movement speed to be used for that branch of the tree, like sprinting when chasing.
i know i've asked this before and i've been told its way too complicated but does any1
know how to, in a C++ BTTask, make the AI Move to some FVector location?
What do you mean?
bcuz i've been told just set the blackboard value in C++
and then in the behavior tree just use the built-in MoveTo and pass in the blackboard key location
what I want to do is do that in one step, in c++
this is one of my attempts:
EBTNodeResult::Type UBTTask_LessOldWander::ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
if (targetNavLocation.Location == FVector::ZeroVector) {
findNewTargetLocation(OwnerComp);
}
EBTNodeResult::Type moveResult = Super::ExecuteTask(OwnerComp, NodeMemory);
if (moveResult == EPathFollowingRequestResult::AlreadyAtGoal) {
//targetNavLocation.Location = FVector::ZeroVector;
return EBTNodeResult::Succeeded;
}
else if (moveResult == EPathFollowingRequestResult::RequestSuccessful) {
return EBTNodeResult::InProgress;
}
else {
//targetNavLocation.Location = FVector::ZeroVector;
return EBTNodeResult::Failed;
}
}
the guy doesn't move at all
oh u probably gonna need findNewTargetLocation too
void UBTTask_LessOldWander::findNewTargetLocation(UBehaviorTreeComponent& OwnerComp)
{
if (auto pawn = OwnerComp.GetAIOwner()->GetPawn()) {
if (AAIController* AIController = Cast<AAIController>(pawn->GetController())) {
FVector actorLocation = pawn->GetActorLocation();
auto navSystem = UNavigationSystemV1::GetNavigationSystem(GetWorld());
FNavLocation newTargetNavLocation;
navSystem->GetRandomPointInNavigableRadius(actorLocation, 10000, newTargetNavLocation);
targetNavLocation = newTargetNavLocation;
OwnerComp.GetBlackboardComponent()->SetValueAsVector(GetSelectedBlackboardKey(), targetNavLocation.Location);
}
}
}
I thought that by setting the blackboard value and then calling super the super would look at that blackboard val and go there, but it wont 😭
other option was using like NodeMemory but since I'm deriving from MoveTo and MoveTo has its own struct i dunno if its safe to overwrite it without ruining Super::ExecuteTask
If you don't set the BB key selector in the BT it will default to self. So that's what the base move to will use.
So it doesn't move because it's trying to move to itself
i dont think thats the problem
ignore the right side of the selector
that dont matter
I'm guessing its on the C++ end
don't see any1 succeeding to do this on the web either
There's absolutely no reason to do what you are trying to do
😭 thats what the other guy said
alr alr
ill stick with the basics ig
thanks for trying
calling the Look at function is only moving the head, I need my sight perception to follow the player too, but its only rotating when i use setfocus function but it also rotates the body
Then you need to override the pawn function that gets the view location and rotation. By default it uses the actor's rotation. I like to use a socket attached to the head and use that for the location and rotation.
by pawn function u mean the functions of AI perception??
No. It's a function on the pawn
which function are u talking about...?
this is what i'm doing currently
SetControlRotation(FMath::Lerp(GetControlRotation(),rotation , time / 0.1));
TurretPawn->Attachment->SetWorldRotation(FMath::Lerp(TurretPawn->Attachment->GetComponentRotation(), rotation, time / 0.1));
the second line is setting the head rotation, and this is in the controller and im calling it on the tick
When i set the world rotation of the head it works as i want but the cone of the AI perception doesnt rotate until i use the set control rotation
The function that I specifically said
;-;
the look at function?
No. Did you read my response at all?
u said to override the pawn function that gets the view location and rotation
What part of that don't you understand? I told you the function. That it's on the pawn.
i understood half of ur response, idk about the function on the pawn that gets the view location and rotation so i didnt get that part
Did you look at the pawn functions that you can override?
*/
virtual FRotator GetViewRotation() const;
/** Returns Pawn's eye location */
virtual FVector GetPawnViewLocation() const;
this u mean?
i was looking in the blueprints....my bad
Yes
so i have to override those functions and return the head's socket rotation and location?
Yes
Thanks it worked!
i want to check if a given position is navigable or not by the turret, i searched the internet and forums and found that there are two functions that does something similar to what i want, TestPathSync and ProjectPointToNavigation
but i couldnt figure out which one is the optimal? there are mixed opinions on the internet]
Project point only checks if the location is on the nav mesh. Test path checks that there is a path. If you use the hierarchical mode, it's a lot cheaper.
if (UNavigationSystemV1* NavSys = UNavigationSystemV1::GetCurrent(GetWorld()))
{
FPathFindingQuery Query;
Query.StartLocation = GetActorLocation();
Query.EndLocation = RadialSearchCentre;
if (NavSys->TestPathSync(Query, EPathFindingMode::Hierarchical))
{
if (GEngine) GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Emerald, FString::Printf(TEXT("Centre valid")));
}
else
{
if (GEngine) GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Emerald, FString::Printf(TEXT("Centre Invalid")));
RadialSearchCentre = GetActorLocation();
}
}
I tried this but it still prints centre valid even if theres no path
Thank you, that was super useful!
I dont want my AI to go to the location that has been blocked off and instead stay still, so far ive tried Test Path and FindPathSync but they all work the same as shown in the video. Is there anything else i need to setup like navmesh or that modified volume i used to block the path for AI?
How do I avoid the AI getting stuck with each other?
Like, I would like it to detect "hey, there is another actor in front of me, I should get another path".
Is there a way to mark a moveable actor as an obstacle in realtime?
I figured it out, I implemented Reciprocal Velocity Obstacles Avoidance, the results are kind of iffy, but it will do for now.
There’s also DetourCrowd AI as an alternative
Yeah, I saw it, but I thought that It could be a bit too much for what I need it for.
If I need the improvement, I'll implement it.
Thank you for the recommendation either way, I appreciate it!
You could grab the brain component off the AI Controller and call Stop Logic on it.
I am using unreal engine's MoveTo in my behavior tree, however, I want it so that even if the player is unreachable the ai will try to get as close as possible to the player. Right now, when the player goes to an unreachable place (still in nav mesh), the AI just stops.
Going back to this - I integrated GAS into my project yesterday. Took all of like, one day to integrate 😅. I spent last week learning it though. Was easy to integrate because my game's architecture was already like what GAS wanted. The main difference between my stuff and GAS is that I pretty much just had Abilities and Effects combined into one object.
I'd run an Environment Query with scoring test on Distance to weigh points closest to the Player and filter test out any points the AI can't pathfind to.
https://dev.epicgames.com/documentation/en-us/unreal-engine/eqs-node-reference-tests-in-unreal-engine
Describes how to use Tests within EQS to generate the "best" option.
You should debug that. Probably has to do with your query not completely set up or allowing partial paths.
how to setup the query?
it always returns true idk why, i even tried the blueprint node AI move to, its also returning success even when AI is blocked off
When using a UNavLinkComponent, are there any event callbacks for when a unit enters the link from either side? I know there's some sort of delegate called from an ANavLinkProxy. (when using smart links at least..)
I'm to the point of just spawning Link Proxies in begin play but this feels like functionality that should be inherent to the component version?
Do you know how to debug code? How to find the variables in a struct? How to search the code of examples of a function being used?
Only for smart links. Point links you can only access in C++ and need to add functionality for it in the pathfinding component
I see so smart link and bind to the OnSmartLinkReached delegate with an ANavLinkProxy is probably my best bet.
Ahh I see, smart links are designed exactly for performing extra logic anyway, can I not set up a smart link via a component though?
Seems to only be a feature on the actor proxy variant
You can, but I think you need to use C++.
You should however be able to make a nav link proxy to be your base class.
is there a simple way to check if some point is reachable by my AI? In C++ preferabbly
Is there a way I can tune the accuracy of pathfinding and pathfollowing?
I'm using the standard FindPathSync but with a custom pathfollowing algorithm, but the agents don't seem to follow the best path. They get to the desired location but take a longer route than I'd expect
bool UNavigationSystemV1::TestPathSync(FPathFindingQuery Query, EPathFindingMode::Type Mode, int32* NumVisitedNodes) const
for the numvisitednodes parameter what do i set that as? do i hardcode it or sdo something like this:
//while (!bSuccess) {
// val *= 100;
// bSuccess = TestPathSync(someparams..., val);
// // makingg sure no infinite loop
// if (val >= 999999.0f) {
// UE_LOG(LogTemp, Display, TEXT("inf loop we out FIXASAP"));
// }
//}
With hardcoding my game works fine, but I assume for larger distances to travel the AI will just stop moving? (correct me if i'm wrong. )
Using the loop, however, just makes my game freezes, I'm guessing TestPathSync takes hella cpu resources so looping that causes problems. Any suggestions on how to proceed?
Hey guys, I saw an interesting post somewhere about getting the tests for a specific EQS query in c++ and running them manually against an item from a previous query to determine if the query needs to run again or if the previous result is still valid, but I'm having trouble figuring out what's actually going on here.
I've got this far, but no idea how to actually check whether the test passed or whether passing in an FVector (CurrentMoveLocation) is going to work for the AddItemData call. Anyone done this before? I can't find the post now that was doing this.
It works fine but I think it still has some bugs in particular with the property binding system, but I think there are reasonably easy workarounds
The biggest "problem" with it is that some of its behaviors are not entirely self explanatory so it may take a bit of learning and digging to figure out why it does what it does
Given that you wrote your own pathing algorithm, only you can fix it. Are you not using A*?
Why aren't you just running the EQS with a generator on the left side that checks the validity?
because then i would have to add that generator to every different query, seemed cleaner to do a catch-all that just checks all the tests for whatever query you want to use
Let me clarify. I'm using custom pathfollowing, not the usual AI/PathFollowingComponent combo.
I'm taking the raw path generated from FindPathSync and moving the agent along it from point to point.
The problem is that sometimes the agent takes a long route around some obstacles instead of going through a gap that I made wide enough for it.
I don't know if there's any step I'm missing to find shortest path after generating the path to target. Or if its the path generated that isn't just optimal
Except usually you don't want to use every test to check if it's valid. You also have a lot more control over when to use it or not. And you're not having to do something weird to get if it passes.
well im only checking tests that filter (or filter and score), im not sure what scenario i would want to skip a test that does filtering
We use the EQS to find targets. The tests that are run first to check if a target is valid is different than the ones that are for picking a target. Because otherwise, they don't change targets in appropriate situations. For our location quarries, we don't test the path again, because the nav mesh isn't dynamic.
ah
you make a good point about path testing
i was only using this for specifically locations
Doing it manually just gives you so much more control
i guess so
FVector UBTTask_MyMoveTo::getClosestNavigablePoint(FVector targetLocation)
{
UNavigationSystemV1* navSystem = UNavigationSystemV1::GetCurrent(GetWorld());
if (!navSystem) return FVector::ZeroVector;
FNavLocation navLoc;
navSystem->ProjectPointToNavigation(targetLocation, navLoc);
return navLoc.Location;
}
I want to the ai to get as close as possible to the player bcuz rn if the player enters a closed like box or something in the level, the AI just freezes instead of reaching the outer edges of the box and stopping. Unfortunately, this function doesn't work
hey devs!! I am having some issues with the AI... so they are supposed to do the following things:
start at a position,
follow the spline
on reaching the last point, find a random point near the target
and Attack
in order to find a random point near the target, I am making use of EQS... but the problem is that they are trying to take the same spot despite trying to maintain a certain distance from each other... currently I am running the EQS only once... do I need to run it in loop until they find a suitable spot??
You aren't testing if the point is reachable. It's better to use the EQS for what you are trying to do anyway.
I'm not well-versed in EQS and from the videos i've seen its Blueprint-Based
thus trying to integrate between blueprint and c++ will be another hurdle id rataher not deal with
It's a data asset, not BP
any good tuts on it?
Yes. The intro to AI course in the learning library has a section on it.
is the learning library something on dev.epicgames.com?
You need better tests in your EQS. Use some dot product tests for smarter location picking. Also a distance test to the ally's destination.
The link is pinned in this channel
the third test is getting all the enemies and gets a location which is atleast 300 units away from them😐😐... but I will give it a shot with the dot product
That's the current location, right?
yes... I am aware that they always change after that run... so do I need to do the distance test at every iteration
I said you need to do a distance check on their destination.
how do I get their destination
as of yet I have only done tests from the querier... but didnt know we could do for others as well
Your putting the result of the EQS in the blackboard for the move to to use, right?
yes
so is it like asking... is any of these enemies are closest to that chosen destination?
if there is any.. than choose a different spot
I usually do it as "is this item within x distance of an ally" if yes, filter out
No
Using only cpp is just as bad as using only bp
Hello, how do I make a floating AI that follows the exact path the player was in a second a go?
like an actual precise copy of the locations
Has anyone run into issues with AI Move To getting verticality wrong before? I have an NPC set to walk to the pink sphere on the first floor using AI Move To (its acceptance radius is 10, same as the debug sphere's radius), but a fraction of the time the NPC will walk to that location on the 2nd floor instead of the 1st floor and say movement is complete (success)
Is the pink debug sphere your projected goal location?
Yes, it is the Destination param for AI MoveTo
Can anyone point me in the right direction? I have some movable actor obstacles in a level, and i would like them to obstruct the nav mesh as they are moved, so that the AIs dont try to walk across them. What's the right way to go about this? the first thing that comes to mind is to enable runtime generation on the navmesh, but maybe theres a cheaper way to do it?
yea
This is false.
yes
Here's a video. Normally the NPC runs straight through the door to go to the first floor (pink sphere target), but occasionally it stops right out front of the 2nd floor door (immediately above the pink sphere) rather than going to the first floor. It's rather concerning that the behavior isn't consistent
Are they things the AI can walk on? If not, I'd use modifiers only instead as it's significantly cheaper.
theyre basically these big cubes that can get pushed around the nav mesh, and the ai shouldnt try to go through them. by modifiers only, you mean project settings -> navmesh->dynamic modifiers only + dynamic obstacle checked on the actor
this is always returning true for me even when theres no path
am not sure if I am doing this right:
"allow partial path" is it true by default?
i searched about it and it seems like i need to set it false
Why are you doing a dot product with the ally current locations?
You can look at the struct and answer it for yourself
it is set as true and i set it to false now i need to call the TestPathSync function, idk whats the last parameter is in
bool UNavigationSystemV1::TestPathSync(FPathFindingQuery Query, EPathFindingMode::Type Mode, int32* NumVisitedNodes) const
FPathFindingQuery Query;
Query.StartLocation = Pawn->GetActorLocation();
Query.EndLocation = Origin;
Query.bAllowPartialPaths = false;
bool bIsNavigable = NavSys->TestPathSync(Query, EPathFindingMode::Hierarchical);
This is how i am doing
I do also use blueprint but only for animations / basic logic, its just I've seen videos of the crazy difference in performance between blueprint and c++ and for something like AI whose pathfinding is resource intensive, I think C++ would be the wiser choice
Did u fixed ur AI bug?
.
can u check this out?
not yet, im just gonna learn the EBQ thing and use that
can u pls ping me if u able to fix that issue? im facing similar issue its just i dont want my AI to move if the path doesnt exist and call a different function when that happens
but my AI keeps going there trying to reach that point
my ai just gives up
and stops moving
are you using like directlymoveto?
hvnt tested that
movedirectlyto
i want my AI to do that....
nah its simple move to
Yeah that’s fair.
weird
i fixed it, had to change some more variables in the FPathFindingQuery Struct and then do TestPathSync
yes
I tried this
using normal moveto
but found it easier just to call super::executeTask and see if that returned failed
oh
im testing path in another task
not in the move to
FPathFindingQuery Query;
Query.StartLocation = Pawn->GetActorLocation();
Query.EndLocation = Origin;
Query.bAllowPartialPaths = false;
Query.SetAllowPartialPaths(false);
Query.NavAgentProperties.AgentHeight = 80;
Query.NavAgentProperties.AgentRadius = 80;
Query.Owner = AIC;
const ANavigationData* NavData = AIC ? NavSys->GetNavDataForProps(AIC->GetNavAgentPropertiesRef(), AIC->GetNavAgentLocation()) : NULL;
Query.NavData = NavData;
DrawDebugSphere(GetWorld(), Query.StartLocation, 100, 12, FColor::Green, false, 10, 0, 3);
DrawDebugSphere(GetWorld(), Query.EndLocation, 100, 12, FColor::Red, false, 10, 0, 3);
bool bIsNavigable = NavSys->TestPathSync(Query, EPathFindingMode::Regular);
if (bIsNavigable)
{
if (GEngine) GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Emerald, FString::Printf(TEXT("Centre valid")));
}
else
{
if (GEngine) GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Emerald, FString::Printf(TEXT("Centre Invalid")));
Pawn->RadialSearchCentre = Pawn->GetActorLocation();
Origin = Pawn->GetActorLocation();
}
OwnerComp.GetBlackboardComponent()->SetValueAsVector(GetSelectedBlackboardKey(), Origin);
Pawn->bReachedCentre = true;
my goal is if fail, make the ai move to the closest navigable location in respect to target
ic
u mean like this?
earlied the test would be come true even when there was no path
yeah
exactly like that
my ai will follow me, except if I jump onto the blue box (img), because the blue box doesn't have a like nav mesh. So in that scenario I want to go to the closest green area
are u using custom move to?
You should use the agent properties instead of hard coding them for the query.
you mean in the editor?
No. In your code. You are hard coding the nav agent properties instead of just getting them from the AI.
how can i set nav agent properties?
if i dont set it it will get the default value
You are hard coding the height and radius for the nav agent properties. Then a couple of lines later you are getting the nav agent properties ref to get the nav data.
Instead you should get the nav agent properties first and set the Query.NavAgentProperties to that.
Also, in UE never use NULL. Use nullptr
i do that, but i copied that NavData line from the BT_DecoratorDoesPathExist class....i will pay attention to what im copying next time
I initially thought of letting them avoid the direction if there were any enemy in that direction but then I realised that wont be a viable choice as they will start avoiding the suitable spots behind them... so I removed it
When I use the Simple Move To BP node I get a missing component warning, anyone here know what would cause that?
What component does it say is missing?
It doesnt say.
Show your graph with the simple move to
Yeah, 1 sec
This is in a BT task right? What kind of pawn does the controller have? Does the pawn have a movement component?
Yeah it is a BT task, the pawn has a BPC_AI_GMC_Base_Grounded component added to it.
Does that inherit from a movement component of some type or is it just a plain actor component?
Yeah, it inherits from BPC AI GMC Base
Which I assume is a movement component, another team member sat this up so I cant be 100% sure.
Check what it inherits from then - For the MoveTo's to work, there needs to be something that is a movement component, this is typically something like Character Movement Component, Floating Pawn Movement Component, or other such builtin component type
Also can you paste the exact warning you got
Sure
If I use the custom task I get SimpleMove failed for AIC_Marine_C_0: missing components
If I use the built in MoveTo node I get: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x000000000000024e
/// Movement component intended for animate actors such as humans and animals. Typically organic movement is characterized by quick acceleration to a maximum
/// speed (where most of the movement happens) and quick deceleration to a stop again. Physical forces like air resistance are being ignored with this type of
/// movement due to their negligible influence. This implementation is not limited to bipeds or any particular collision shape.
UCLASS(ClassGroup = "Movement", BlueprintType, Blueprintable, meta = (BlueprintSpawnableComponent))
class GMCCORE_API UGMC_OrganicMovementCmp : public UGMC_MovementUtilityCmp, public IRVOAvoidanceInterface
```It does seem to inherit from a movement component.
Hmm based on the error message the problem is that your AI Controller is missing a path following component
I was wondering what causes it and looking at the source code, it outputs that exact error if it can't find a path following component from the controller
Give this a try: In your AI controller's BeginPlay, get the path following component and check if it's valid
This kind of smells like BP corruption
Alright, will do.
AIController.PathFollowingComponent is not blueprint visible (BlueprintReadOnly or BlueprintReadWrite). Please fix mark up or cease accessing as this will be made an error in a future release. Get PathFollowingComponent This is probably the issue yeah?
Nah, that just means the path following comp isn't something you'd normally be able to read in a BP graph
it's accessible via C++ just fine though
Hmmm... Well I cant check if is valid because of that.
Try using get component by class and set the class to path following component
Ok
It is valid alright.
That's peculiar 🤔
Can you show the graph you used to check the validity?
It's probably fine but just to double check because I'm not quite sure why it would be complaining about this
Yeah that's fine all right..
In your BT task, maybe do the same check there
also I think there should be a node called get path following component you can use
I m facing this weird bug in my AI sight Perception, it doesnt happen every time but sometimes when the Target detected by AI goes out of its lose sight radius, none of these functions gets called. Usually they do but only sometimes they dont give the call when target goes out of sight. I was unable to figure out the what causing that bug
Did it already, all were valid
Hmm, actually using GetPathFollowingComponent returns not valid in the task.
Oh, I wonder why does the get component by class return a valid result then 🤔
But in this case this does sound like blueprint corruption. I would try recreating the controller from scratch and see if that helps
Alright will do! Thanks!
Haven't encountered this, are you using any of the settings to control how quickly perception data is forgotten or such?
Maybe try setting it to 0 which is the default and see if it affects it at all
0 means never forgotten
the tooltip says
Yes that's what it says but that is the default
I've never had this problem and I've never changed it from the default, so it's worth a try :)
lemme try
Yeah this fixed it.
👍
have you tried adding prints into the perception updated to check that it isn't running or how did you determine it doesn't work?
This is the bug, as you can see when player goes inside the sight of AI, the head looks in that direction and then when it goes outside its still looking at the poistion where AI last seen the target and also theres a boolean variable in BlackBoard which i am changing when player is detected and player is lost "Player Detected" when AI goes out it should be false and true when its in sight, but here its staying true even when Target is outside and when i go inside and come out again it becomes false. Im changing the value on TargetPerceptionUpdated function and also on Perception updated function
Im making my AI look at player and follow Target whenever its detected but when i change the max age settings it doesnt work
Anyone has any idea as to why the nav mesh is generated like this in this ramp?
I do not envy that task
I'll basically paste these different commented groups into different Task Nodes
with my conditionals as decorators on branches
Will it work the new “500 Animations” Motion Matching sample with ai?
maybe its related to collision or try rebuilding paths?
AI and animation are two separate things
They rebuild automatically whenever something changes, and it keeps generating that way 
no i mean delete the recast thing in the outliner and then go to the build menu and click on build paths
im not sure if it it works
did u try it before?
Oh, no, I haven't, I will see if it works
It did ended up building the same way again 
Oh, I made the slope smaller (by increasing the ramp size in one axis) and it generated the mesh correctly.
Hey guys, not an ai specific issue but I'd like to know if anyone ever encountered issues with Level Sequences and Level Streaming.
Let's say I have LevelSequenceActors (that does some cosmetic transform changes on objects) in some streamed levels, and sometimes after getting streamed/unstreamed/streamed, the sequence is frozen, nothing moves anymore, no matter if I call Play manually or set is as Autoplay.
I could use some help, In UE4, the AI Perception fully STOPS sensing players its already sensed, if it detects a new player.
Ex: Player 1 gets sensed, AI moves to Player 1. If it spots player 2 it will NEVER be updated/sense Player 1 again, at all. It wont even trigger the Ai Perception
I've never seen that behavior. Are you sure they aren't sensed? As in checked the gameplay debugger? Or is there a bug with how you are selecting targets?
I can clip it if you want. I literally have a print string hooked up every time it'll update, and it straight up will stop firing
How are you selecting targets?
Wym selecting targets? Like detecting by affiliation? -- Or do you mean which sense? Itd be all affiliations, and by sight
How do they pick which target to attack?
Right now it's set up so whenever the perception is updated, and its a player, it'll go to that player. So based on what actor was last updated in its sight
But thats not necessarily the issue, the going to the player works fine. But I dont understand why the perception itself stops working
That's your problem. The updated event doesn't work like you are expecting. The perception doesn't stop working. I recommend using the EQS to select the target on an interval.
Ohhhh dang really?
Can't say I've ever ran into this issue either to be honest.
I didnt know that, thank you
I use On Target Perception Updated and run some logic based off that for my stuff currently.
Luthage's advice is still the better approach overall - but I'd still be interested in seeing your code
That's what I was doing, and it seemed like it works for singleplayer, but it gets funky when multiplayer is involved
My game is multiplayer as well
Interesting, could I maybe see how yours is set up? The On Target Perception, that is
No. Because I don't have the project opened. Show yours
Lemme fix it up a little, I had been gutting it a bit to try and figure it out
You don't get the updated event every time a target is sensed. It's only for new sensed targets. And losing sight of one doesn't trigger it. Just better to get all the sensed targets on an interval when you have multiple targets.
No.
Well the silver character is behind it. What do you mean the vision half angle isn't doing anything?
Can you show your sight sense settings
With that setting, it's not going to see anything behind it.
I may have a setting set where it forgets actors. I remember messing around with that.
Bro I swear this Unreal Engine is some wizardy shit. I cleared out all code in the actor, and rewrote it all. And now its functioning corretly? I didn't change or alter anything lmfao
Because it limits itself to 40 degrees on either side. So anything more it won't see.
That's just papa Tim smiling on you
I missed that you added that. Not sure what to tell you, I have never used that setting.
Has this ever happened to anyone?
After about 30 minutes, many of my artificial intelligences want to go to the same point, this causes them to get stuck and not try to look for a new point.
How can i fix this?
Any benefit to setting up UAIPerceptionComponent in AIController or AICharacter class?
Here is how ti would look in the AICharacter Class:
perception = CreateDefaultSubobject<UAIPerceptionComponent>(TEXT("PerceptionComp"));
UAISenseConfig_Sight* config = CreateDefaultSubobject<UAISenseConfig_Sight>(TEXT("SightSenseConfig"));
perception->ConfigureSense(*config);
perception->OnTargetPerceptionUpdated.AddDynamic(this, &AEnemyAICharacter::onSeeActor);
And this is how it would look in the AIController class:
if (UAISenseConfig_Sight* sightConfig = CreateDefaultSubobject<UAISenseConfig_Sight>(TEXT("Sight Config"))) {
SetPerceptionComponent(*CreateDefaultSubobject<UAIPerceptionComponent>(TEXT("Perception Component")));
auto perceptionComp = GetPerceptionComponent();
GetPerceptionComponent()->SetDominantSense(*sightConfig->GetSenseImplementation());
GetPerceptionComponent()->OnTargetPerceptionUpdated.AddDynamic(this, &AEnemyAIController::onActorDeteected);
}
backward offset and near clipping just increases the vision of AI by extending the vision cone slightly behind ur AI
the peripheral angle to 90
i use that too but im facing this bug
This one
generally AI perception should be added to controller only
cuz AI is the one controlling pawn, so the sight and all should be in controller only
and that way u wont need to add perception component in every AI u make
how can i activate my AI debugger tool right from the start?
throught code, is that possible?
So this is a yes, it will work? I set up previously an Ai, but motion matching require some stuff like a trajectory component on the BP_Char
If by AI you mean behavior trees or other such logic to control it, that will still work just fine. You may need to add the new component into your character of course but that's really an animation concern, not an AI concern specifically
thanks! I meaned that
Is it possible to get EQS Context be set as value from key from blackboard? RIght now I'm casting to get that info from AIC, but I would prefer to take it from blackboard.
You can get the blackboard from the AI controller
Found that, should I now cast to the Object and get actor or is there other way?
Yes you should cast the object to an actor
Thanks!
Does anyone know if this has changed?
Otherwise I'm doing something wrong. I have my main EnemyTree that is like this. The BB of the ClosestHostile tree inherits from the AIBase BB but still results as incompatible
Afaik it has not changed. I think the problem you're seeing is that you're using inheritance, when it specifically is unsupported for subtrees
so i need to have the same BB for each subtree i want to use?
The BBs used in subtrees must be 1 to 1 compatible with the parent BB, that is, they can't contain any keys that don't exist in the parent and vice versa
Yes
okay, that's a bit unconvenient
that means my BB will end up having a lot of keys
if i want to make a lot of subtrees
Keep in mind that you don't need to use the blackboard for everything imaginable
Your decorators or tasks can also access values directly in the pawn or controller if it's more convenient that way
yes, that's a good point, i'll keep that in mind. Probably will try to use the BB as a main source of information and see where this leads
thanks for the answer!
This problem is ai/cpp so if u dunno cpp just ignore:
At 2:10 in this video the narrator says we cannot define enemies neutrals or friendlies via blueprint. How would I do so in cpp? https://dev.epicgames.com/community/learning/courses/67R/unreal-engine-introduction-to-ai-with-blueprints/D0e/setting-up-ai-perception
question - I made a waypoint system for my enemies so they can patrol areas, but for some reason they keep stopping at the waypoint for a few seconds before moving to the next one - when I want them to just immediately move to the next point. Any idea why this is happening? Not sure if there is some default affecting this or not
I sort of got the logic behind that, but when I went to override / implement the GetTeamAttitudeTowards(const AActor& other) i am lost here is my bsed implementation bcuz the guides I found are creating like IDs and whatnot and like cuustom enums in the gamemode class:
ETeamAttitude::Type AEnemyAIController::GetTeamAttitudeTowards(const AActor& other) const
{
if (other.ActorHasTag("Player")) {
return ETeamAttitude::Hostile;
}
else if (other.ActorHasTag("AI")) {
return ETeamAttitude::Friendly;
}
else {
return ETeamAttitude::Neutral;
}
}
Show behavior tree
I have setup two callback functions, the first is called properly when the ai sees my player but the second, the forgotten, aint ever getting called. What am I missing?
perception->OnTargetPerceptionUpdated.AddDynamic(this, &AEnemyAIController::onActorDetected);
perception->OnTargetPerceptionForgotten.AddDynamic(this, &AEnemyAIController::onActorForgotten);
why is the ai never forgetting my player?
Here's my BP_AIController:
Enum team IDs are far better than using fnames.
There is no default affecting this. What is happening entirely depends on how you implemented this.
You need to turn on forget actors in the project settings.
I have navmesh / volumes in a bunch of my levels. They are set to Dynamic Modifiers Only. When I PIE, they work fine and the AI move around. But when I run through the start screen which calls OpenLevel(...), the navmesh isn't loaded in. Is there a way to have "static" (read: dynamic modifiers only) navmesh while still loading different levels?
Actually, caveat to the above... some levels work fine. So I must be messing something up in my settings for certain navmeshes...?
I started following along with this to try and learn behavior trees because lord knows it's hard to get a good video tutorial, but it seems like this is very outdated.
will that cause any serious issues if I follow along with it?
where would u suggest I create the enum, GamemodeBase ?
I would not recommend putting it in the game mode. You don't need to put it in an existing file.
I created the enum in AI Controller class
It is the best introduction to the AI systems.
That means you need to include the AI controller in more places. Not recommended either.
@uneven cloud can u pls take a look at this?
The perception updated events don't fire when most people expect them to. Such as losing sight. You need to debug it to see what is happening. We can't debug it for you based on a video.
usually they do fire when losing sight, is there any function in AIPerception OnActorForgotten?
You have to turn on actors being forgotten in the project settings for them to be forgotten.
i didnt do that
i will try this
I turned that on, but i cant see any function ```OnTargetPerceptionForgotten
nvm this function was added in 5.3, im using 5.0
I feel like that’s prly the worst minor version to use
Meh - people say that every version
I didn’t say current version is the worst to use
oh well..
Looks like state tree will be soon usable also for utility AI.
https://github.com/EpicGames/UnrealEngine/commit/0fa5fd8e366558ee5972e9808bcaae5c12ea557f
speaking of state trees, I know different tools work better for different jobs but what are people's opinions on state trees vs. behavior trees? I started learning behavior trees and the blackboard can get a bit clunky and I've heard state trees are better in that regard but I don't know what the tradeoffs are.
It seems like a decent system to me but not sure if it's inherently any better
There's some things with it like I'm not entirely sure how you're intended to do things like perform a latent action which results in some data and then use that data to choose what to do next or such
it's certainly possible to do it but some of it just feels a bit clunky so maybe I'm missing something
I haven't been sold on it yet personally
I still stick to BT or custom state machine
I'm still learning BT, quick question, what would be a simple approach to having an AI search for you after it loses sight of you for a short bit (like go to 3 different locations near where it last saw you or something?) I followed along with this to get started: https://dev.epicgames.com/community/learning/courses/67R/unreal-engine-introduction-to-ai-with-blueprints/D0e/setting-up-ai-perception
I'd use EQS to generate those spots and then iterate from there
So pick 3 random navigable points in X radius. Then just refine it from there
I haven't learned EQS yet, I was getting hung up on how to make the state tree trigger the searching for player after losing sight of them. If EQS will help I'll look into that section in the above documentation tutorial thing
I mean behavior tree
so like a separate task?
The most basic would be, far left side of the sequence (not the entire tree!) would be the Run EQS Query, then store the result in a BB key. Then use the Move To task to move to that position.
So like 2 nodes to get the most basic implementation working
so is it a completely new behavior tree?
But from there, you just iterate and add additional rules and all that
Doesn't have to be, but can be.
Then you can plug it in as a subtree in other BTs
For simplicity, I wouldn't bother though
I didn't know you could do more than one behavior tree, out of curiosity if you run a behavior tree inside a behavior tree will it temporarily stop the parent behavior tree?
and yeah just asking this part for curiosity
So right now I have it set up where on the left it chases player and on the right it patrols randomly, but the left chases part has a decorator that won't run it unless a condition of whether it sees the player is true, and when it runs it aborts the random patrol and what not. I'm not quite sure how to add something inbetween that process (conceptually inbetween) and still ahve the previous system work.
Where do i put this code to Team perception to work UAIPerceptionSystem::OnEvent<FAITeamStimulusEvent, FAITeamStimulusEvent::FSenseClass>(GetWorld(), FAITeamStimulusEvent(GetPawn(), InEnemy, InEnemy->GetActorLocation(), TeamEventRange));?
Put this "investigate" behavior in between the chasing sequence and the wandering sequence
BT's get evaluated left -> right
It is really a priority selector
alright
So the top most priority is chasing the player.
I think I get it, just need to set something up to track the player location while player is seen in a variable I suppose
You just need the last known location
Yeah, it's just a vector
When the player leaves sight, store the location where they left sight at
Then feed that into the EQS
That's the position you want to search around
alright, I'll watch the tutorial on EQS then
Once you have the basics working, it is easier to iterate and expand upon
thanks for all the help
Hey all!
I'm doing some tile/grid-based 8 way pathfinding on a custom Recast Nav Mesh in C++
Pathfinding works fine enough for 4-way, but when I allow 8-way directional movement, it's almost like the A* pathfinding prefers the diagonal neighbors, making the path result a little... unwieldy lol
I'm finding the path using the following:
EGraphAStarResult AStarResult = PathFinder.FindPath(StartIndex, EndIndex, FGridPathFilter(*GraphAStarNavMesh), PathIndices);
Any ideas how I might be able to solve this or how I can have neighboiurs that are not diagonal preferred?
Thanks in advance!
Is there a bug or trick to get AI Sight Perception working in a world partition level?
ime from writing a* algorithms by hand many times, whats probably happening is that it seems to prefer diagonals just because of the order of evaluation of the neighbor grid tiles, the diagonals in your test are probably more likely to be evaluated first, and since it seems your diagonal cost is the same as your cardinal cost, it gets picked and doesnt change since nothing has a better score
i would make diagonals cost more than 1
since in real physical space diagonals are further than cardinals anyway
This is true, they all have the same cost... and that makes perfect sense.
sorry for the late reply - I just have a Move to Location or Actor node on a newly made enemy actor. There is no behavior tree or anything - The only other function firing off is how it finds the next waypoint to move to (which is a for-loop going through an array). For whatever reason, it takes about 10 seconds for the enemy to realize it's within the acceptance radius
By using Unreal Engine's struct FGridPathFilter how can I assign a cost to neighbours?
I'm wondering if this is the right area...
struct FGridNavMeshPath : public FNavMeshPath
{
FORCEINLINE virtual double GetCostFromIndex(int32 PathPointIndex) const override
{
return CurrentPathCost;
}
FORCEINLINE virtual double GetLengthFromPosition(FVector SegmentStart, uint32 NextPathPointIndex) const override
{
// We exclude the starting point so -1
return PathPoints.Num() - 1;
}
double CurrentPathCost{ 0 };
};
AH i have never used it haha 😄 as i said from my own experience writing this sort of stuff from scratch, its what i've done in tactics games i've worked on (lamplighters league, battletech)
Nice...! That's exactly the type of game I'm working on but the approach so far has been using this method...
i'd start with maybe the path cost stuff, if you can find the place where the cost from one node to another is computed, you can add the additional diagonal cost there and it should straighten out your paths
i dont how recast handles corners over like open space but you also probably want to disallow diagonals in those cases too
in path solvers i've written i often do things like check for those literal corner cases over empty tiles so i can invalidate the diagonals haha
There is no bug or trick. It works the same way regardless of type of world.
You need to figure out what is happening by debugging instead of being OK with "for whatever reason".
I think I fixed it? the issue was I was targeting the waypoint actor, but when I target the waypoint's location... it's perfectly fine and there is no delay... I don't know why there is a delay for when you target an actor but whatever 🤷 it seems to be baked into Unreal as the same thing happens in a completely new project
also, the initial reason for me posting here was if someone else knew why this was happening - now I know I can bypass it by targeting the location, but I still have no idea why there is a 10 second delay when you target an actor and I have no idea how to adjust that time for whenever I need to target an actor (granted, I can likely just use some other pathfinding method, but it still would be nice to know if and how I can change that delay - but whatever 🤷 ) and yeah, i found several ways around the delay issue, but it feels like they are all "overly complicated" when there likely is just a single variable somewhere hidden in some Unreal submenu or code that would likely adjust it instead - why it's not included in the event node is beyond me
I've never seen a delay like that, so it's not inherent to UE.
So how could you have a small enough LLM to run in game, and where could you get one that isn't trained on copyrighted works etc.?
when having an AI chase a moving actor, like the player or another AI - it's pretty unnoticeable. I only found all this out when having my AI patrol waypoints - granted the tutorial I followed had them target the destination (they didn't say why) and I figured it'd be quicker to target the actor instead (plus possible future-proofing in case I want the WPs to move or something). The delay is on the Success, when the AI enters the Acceptance Radius, the delay starts ticking - so I assume it would allow for a target actor to escape the radius, but if the target actor is stationary, you will have an awkward moment of the AI just standing perfectly still for a few seconds before it realizes it succeeded. This is really the only code running (aside from finding the WPs but again, that's just a for-loop)
this is also the same blueprint used in my completely new scene, with nothing else being touched. So if there is something else at play, I genuinely have no idea what it could possibly be or how I could find it.
*also, possibly clarifying a potential misunderstanding - the delay is with the success node, the BP continues perfectly fine when linking something to the Exec node, it's just that I only need to know when the AI reached it's destination
Your assumption that it allows the target actor to escape is false. There is nothing in the code that is doing a delay.
my assumption is more on the part of the UE devs (as oppose to anything in-code) - other than that, I have no idea why there is a delay or why we can't adjust it
I ask because I'm seeing an issue where AI spawned in a world partition level do not have their sight perception working properly, even though sound is working fine. 🤔
Thanks for the sanity check
maybe the perception system isnt being activated at the proper time (on posses?)
There is nothing doing a delay. I'm not sure why you can't understand that. The code to go to an actor vs a location is identical after the initial set up and tracking the target. Neither of which adds a delay. The only reasons for what you are seeing is if the actor is blocking navigation and causing a perf issue, or collision is causing it to be blocked and can't get there.
fwiw i was wandering around the other day and saw that move to supports locations that move.. you can have it repath and move toward a location as it changes
The BT move to task does that
yeah
The tracking is different, because that is binding to changes to the blackboard.
nodnod
The first thing I would look into is if something invisible is blocking visibility collision channel, which you can turn on via the show menu.
How do you mean? Turning on collision or something else?
In the viewport there is a Show drop down menu. You can turn on show visibility collision to see what is blocking that collision channel.
Most of the sight perception issues is due to collision. The AI can't see something when it's visibility is blocked.
Looks neat. But not enough info in workflow and all that.
They don't look very smart
I always find it a bit dubious when people start talking about smart AI when it's about architecture. Done well, a FSM can make smart AI
I'm well aware of the differences between the architectures.
tyvm, it was indeed something like this.
yeah... "smart" ai in games is mostly about the design and player feel, the system that backs it is only in service to those things and the performance constraints
basically ime game ai is very subjective and its mostly a "soft" target as to how it feels to plyaers. Game ai is more or less about fulfilling a very different need from "being actually intelligent"
the goal is to be fun, rewarding, and make the player feel like they are awesome while still presenting a challange or puzzle
like look at the enemies in mario games, not very complex, except maybe boss behaviors, no one would argue that these games arent great and fun for many people, and i rarely hear players complain about "oh the ai is bad".. maybe simple yes, but for those games its exactly what they need
ime too players can react badly to actually tactically clever AI, they'll say they're cheating or the level spawned them in behind the player, etc etc etc.. as ai programmers in games, you fill a very weird kind of engineering role that works less on logic and reason and more on feel and subjectivity x_x
Figured it out, had to switch target base class to actor from object in blackboard. Kinda stupid I cant make AI look at an object with it
Can something like this be done in Tasks or should I rather create function in AI Controller for that?
You need to expose it and set public inside the task
Well… you’re doing it in a task so yes ? 🙂. Mind you, it might be better to keep the goal location function separate and use the built-in MoveTo task
Hmm, even if I want to move to couple of target locations? So I would have to create sequence with decorator that checks if path is set and iterates unless x is <, then it goes to the next BT node?
I let player set locations to which the unit will go. Something like patrolling.
I’ve done patrolling between 2 points before but can’t recall what I used, off the top of my head
If it’s more than patrolling between A and B, BT might not necessarily be the way to go, since you’re manually directing the AI rather than letting it follow a behaviour tree and make decisions based on what happens
The key here is that AI is already moving between 2 points from 1 to 2 and then back. And on top of that I want to let player add additional Path Points in between. This node going back looks funny, I’m not sure if that is proper way to hack “do while” , but it works 😄
Was just wondering if usually things like that are as functions inside BP of pawn or just as tasks.
IMO, if it’s predetermined behaviour, task is fine. But if you’re giving direct control to the user such as manually placing a number of path points, that may need to stay outside of it, even if it ultimately changes a BB key, from which the AI can path
But this is just what I think, this supposition could be entirely false, as Luthage likes to remind me 😅
If you put this functionality in the AI controller, then you need to add a bunch of things such as a delegate when it's ended.
You do have problems with your current implementation, such as not being able to abort it or handling failure.
Hey, would recommend the #generative-ai channel as there are people who are interested in LLMs and generative AI
Generally you won't find an LLM not trained on possibly copyrighted work because LLMs are pretrained on massive datasets which are impossible to properly filter
Unless you train your own (which takes an enormous amount of compute)
I think the best bet is using something like phi3 3B with 8 bit quantization (3GB of VRAM), should be able to run on a potato
Or llama3 8B Q4 (4GB of vram) for something beefier which still runs on a potato
Using GGUF converted models and embedding a GGML based inference backend like llama.cpp is I think your best bet
I basically Add Path Point and Remove Path Points (by Player Controller), from the Actor Component that is on the Unit. The task runs only when the Unit is generally set to ''Transport''. When there are no points, but unit is set to transport the task will just get finished without ''following path'', if there is point it will follow it first between already going from first point to second (like main objectives from building to building). I guess keeping in on task is fine?
Hey guys. With the "senses", (sight hearing etc.), is it possible to get all the actors in sight at any given moment (if so, how ?), or do I have to build list of actors myself ?
Also, I noticed that when starting the game, the actors in sight at the start of the game don't trigger the perception
get perceived actors or something along those lines should return a list of them
also I'm fairly sure that things immediately in sight should trigger perception 🤔
I'm currently trying to set it so that if the AI loses sight of the player it searches for them from by moving to three separate random locations in a reachable radius around the player. Two questions:
-
Does this structure work for that (as in will it stop chasing and start the selector that will be searching for the player when the target actor is unset and then abort that and resume chasing if it sees them?)
-
I can't quite figure out how to have EQS return more than one result, and have the result be a random selection from the list of possible locations. Suggestions?
but now that I look at it the parent one aborts when the target actor is unset so I probably need to make it not in the chase branch, however I also don't want it doing the searching for player constantly while it doesn't see them, so I'd need to find out how to make it only do the search both when the actor isn't set and only after it loses sight of the player and only once after that happens and allowing it again when it chases again.
I found the single random item from best% thing for run mode on the EQS but since it only returns one thing I imagine I'd need it to do a conditional loop or something but not sure how to make it only loop 3 times. My current thought process is I'd need it to loop until a blackboard boolean or other variable is unset, which maybe I could do a task that makes a value that starts at 3 go down by 1 each time it's run in the loop but also have the value reset when the loop finsihes...
if I run a task that has a variable that has a default value that changes during the task, will that variable's starting value reset to the default value when the task runs again?
sorry one more thing, but for some reason this new task I created is looking for target actor location and self actor even though the task doesn't even have those two blackboard keys in it. Really confused.
None of that changes what I said.
Why 3 random locations instead of the last seen location? The perception component has the last seen location. Getting a location near where the player actually is will look like the NPC is cheating.
The behavior when sight is lost should be a lower priority than chasing. Not higher.
There's already a loop decorator.
Hey @uneven cloud - would you mind if I DM you a question? Not specifically about UE per se.
Go for it
I wanted the AI to search 3 locations before giving up, I'm still struggling to figure out how to set it up, I can share a screenshot a bit later today
the general way most games seem to do this is:
- Move to last seen, play some look anim
- Use an EQS or something to find points near by that are "suspicious" aka maybe around a corner out of sight etc, Move to that location, play the "look anim"
- Repeat 2-3 (or however many times) or alternately wait for a time out, say when the perception age expires for example
- Drop searching and resume a lower priority behavior (patrol? random wander? etc)
pretty much how i've approached that problem for years 😄
EQS has been experimental since at least 2016 and hasn't really changed since
my goal was to do n number of patrol in r radius, the count for patrol and radius could be defined in BP, i used a conditional loop and BT Task to achieve this. I tried using EQS but with eqs i couldnt find how to make it dynamic
i setup my eqs to generate the patrol locations that out of Ai's sight
locations that r being blocked by sight
so if there wasnt any obstacle in its sight it wouldnt move
also i wanted to loop the eqs n times, the number of loop should be defined in BP
but i couldnt find a way to do that, i tried using custom bt decorator loop but didnt worked maybe i didnt properly set up but yea
@vivid fern did u encounter any issues like this in eqs and how did u solve it...
thanks and sorry for ping
i just threw EQS out there as a UE specific example, but you could easily have some other method to gather potential destinations and store them in the blackboard (or somewhere that you can access from your BT). Keep in mind im approaching this from a point where you might write your own tasks, or some c++
in my own little prototype, i just use the EQS query to generate a singular destination randomly from the top 25% results, then i just rerun the query every loop to find the next search location, based on the last sight location, so they will end up sticking around the last seen location, but moving around positions near by until some exit condition happens
(run out of search loops, or run out of time)
thats what i did, tho im just generating random reachable points
and assigning it to move to task
in a conditional loop
i just use a loop with a repeat count
Is there a way to place nav link proxy in a Blueprint?
or can you change the navlinkproxy position at runtime in the level?
I have not found any functions that let me change the point link positions at all
is there any way to make that repeat count to take the value from blueprint variable?
honestly didnt look, however if not could probably write a decorator that could
I tried creating a child class of the loop decorator...but i couldnt figure out
truthfully i'd probably derive just decorator but i've not looked at it
well...
i havent looked at the loop decorator's code so couldnt say one way or the other
looks like UBTDecorator_ConditionalLoop might be a good one to use, override the CalculateRawConditionValue function maybe
like i mentioned i havent tried but seems a good starting place ¯_(ツ)_/¯
seems like it already tracks blackboard keys tho
in unreal's environment query system, any one knows why there is "bTestQueriesUsingBreadth" option provided? What are the pros and cons of running query tests seperately before it all finishes?
i think i tried this too
yea rn im using the inbuilt Conditional Loop, it tracks a bool value
I think I've found solution to this problem. Parameter which changes this path is called "Heuristic Scale" and is located in RecastNavMesh. The lower you set it's value the more rounded path AI will choose. First picture shows path for 0.1 and second picture shows path for 99.
Path which will be chosen is shown by these shorter red lines on the bottom.
ah, interesting finding, I wonder why it's not happening to anyone else though. Gut feeling tells me it's the invokers
I think it's not invokers because I had the same problem with regular navigation. I've seen couple questions about the same topic but never found answer. I don't guarantee this is correct answer but tried this couple times and always worked.
okay, thx for sharing. I'll try it out in our project 🙂
I would really appreciate your feedback when you check if it works in your project
Is there anything I can use to put chatgpt inside UE5 where it can have a mesh and answer voice commands?
Probably but that seems like quite a fair amount of work
Hey thanks for this advice - worked on this today and had a lot of success... I owe you one 🙂
sweet glad it worked out
Why is it that my btservice (Update Plyaer Location) isn't calling OnCeaseRelevant when its turn is finished?
(Previously was on the right side and the service was ticking properly then, after switching to left side ticking stops but onceaserelevant never called)
Here's code if it helps:
{
NodeName = TEXT("Update Player Location");
bNotifyBecomeRelevant = true;
bNotifyCeaseRelevant = true;
}
void UBTService_UpdatePlayerLocation::OnBecomeRelevant(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
Super::OnBecomeRelevant(OwnerComp, NodeMemory);
auto blackBoardComp = OwnerComp.GetBlackboardComponent();
if (APawn* targetPawn = Cast<APawn>(blackBoardComp->GetValueAsObject(TEXT("targetPlayer")))) {
if (AHorrorGameCharacter* targetCharacter = Cast<AHorrorGameCharacter>(targetPawn)) {
UE_LOG(LogTemp, Display, TEXT("HasBecomeRelevant"));
targetCharacter->shakeCamera(60*60); // huge val (1hr)
}
}
}
void UBTService_UpdatePlayerLocation::OnCeaseRelevant(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory)
{
Super::OnCeaseRelevant(OwnerComp, NodeMemory);
auto blackBoardComp = OwnerComp.GetBlackboardComponent();
if (APawn* targetPawn = Cast<APawn>(blackBoardComp->GetValueAsObject(TEXT("targetPlayer")))) {
if (AHorrorGameCharacter* targetCharacter = Cast<AHorrorGameCharacter>(targetPawn)) {
UE_LOG(LogTemp, Display, TEXT("HasStoppedBeingRelevant"));
targetCharacter->shakeCamera(-1); // disabling camera shake
}
}
}
void UBTService_UpdatePlayerLocation::TickNode(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds)
{
Super::TickNode(OwnerComp, NodeMemory, DeltaSeconds);
UE_LOG(LogTemp, Display, TEXT("Tick"));
auto blackBoardComp = OwnerComp.GetBlackboardComponent();
if (APawn* targetPawn = Cast<APawn>(blackBoardComp->GetValueAsObject(TEXT("targetPlayer")))) {
blackBoardComp->SetValueAsVector(TEXT("targetPlayerLocation"), targetPawn->GetActorLocation());
}
}```
Hi! Does anyone have any ideas as to why my AI's path following state randomly goes to idle while its pathing? Basically it stops moving abruptly and I can't pinpoint why
What I've looked at so far
- Nav mesh covers whole area, its inconsistent regardless so it can sometimes path without issues
- Behavior tree is correct and still on the follow task
- Blackboard target is correct
it just seems like it randomly fails navigation and doesn't retry
yeah the path seemingly gets aborted and never tries to repath. This gets hit
What does the visual logger say? It typically has pretty good info about this stuff.
also is the player in a space where the ai cant build a path to?
like you go up a ramp, is it wide enough for the ai nav radius
it is, yes
but shouldnt it try and repath after going back into an area the AI can path to regardless?
hard to tell whats happening in your video tbh
It basically seems like it isnt trying to repath after failing once
you actually are right, it seems like the ramp isnt navigatable for the AI. But then after I leave the ramp back into navigatable area it doesnt repath
bWaitingForRepath gets set to false for some reason, meaning it doesn't try and repath
yeah it probably hits a fail state and gives up
you could probably do some kind of fall back: fist try to path, if it fails, try to find a nearby point to path to, else enter some kind of wait state until destination is reachable
you are using selector, and in behaviour tree its always left to rigth and top to bottom order of processing, so here in ur case the tree wont call the tick until the condition on left is not false.
try do a check of path, like if the path exist or not, if not abort the task, as the reason for the AI not recalculating the path as its still trying to go to an invalid path....
there might be one more issue here(not sure about that), that AI can't go on the ramp even if there is navmesh becasue of the capsule radius of the AI, sometimes you see navmesh in a certain AI, but depending upon the AI capsule size, that area might not be valid for the AI to travel....
I have a character with a sight sense. It properly detects other characters, but not a simple actor with a mesh (an apple). I ticked all the affiliation (neutral etc.). Why doesn't it sense my basic actor ?
Do you have stimuli on that apple?
Yes, I put an AIPerceptionStimuliSource. I check it as "auto register as source".
Woops, I didn't register it for the specific sense I wanted. Sorry, it's working now
Thanks for the hint
If I switch Behavior Trees on actor, does the previous blackboards values of that behavior tree that actor was running gets reseted or will they be ''remembered''?
basically each BT has it's own BB, if they get reseted on Behavior Tree switch then I probably need to use the same BB if I don't want the values to reset?
Hey guys, do you have any idea why my perception system might not work when spawning an actor through a custom subsystem ?
If I manually place the actor on my map, it will work fine but It won't work if the actors are spawned throughout the game
check this in class defaults
😦
It's kinda weird, I'm trying to compare both the placed in actor and spawned actor (comparing their AI_Controller and actor BP) and they both look indentical
Show the code you use to spawn it
heh :)
Bit of a noob question:
I've noticed that Decorator functions are pretty much a superset of Service's
Since Decorators can have a OnTick override and can change blackboard keys, when should a Service be used instead of a Decorator?
Good question, not really sure if there's a big distinction
I guess it's mostly a question of splitting it for clarity
The BB is reset.
How can I import chat gpt into my game so it can be inside my AI and respond to voice commands and see what I see in game?
maybe ask in #generative-ai ? otherwise, through a lot of work i imagine... game ai isnt the same thing as chat gpt fwiw
that's for posting ai generations
my guess is, using unreal engine source code and GPT API
anyways, is it just me who finds using blackboard AI with C++ useless? Ain't it easier to code it yourself since, unlike blueprint, it won't look like a mess
Incorrect
See channel description, Allora’s direction was the right one
i mean shoot your shot but after hours category is for stuff mostly unrelated to ue
Ig they had to put it somewhere. This channel is mainly for UE’s AI system, rather than what people call “AI” currently (GPTs)
what do you mean "using blackboard ai with c++ useless"
Yeah ik but im also saying that channel isn't for unreal engine stuff
what makes it more beneficial than just coding it myself
i guess the fact that its already there and integrated into the engine is a benefit, if you want a node graph for your nodes, its also already got that too
of course imo its pretty easy to write behavior trees from scratch too so i guess its whatever you feel like
It's not at all useless. Hard coding things isn't good practice.
The BB is how you data drive the BT.
Tbh I'm not entirely sure what does "blackboard AI with C++" even refer to specifically
If it's about behavior trees specifically, you certainly could write BT's in C++ also (although UE doesn't provide much of an API for it out of the box), but I don't really think it would be any less messy... it would just be harder to change
yeah mb i must've mixed them up
Every time I come back to look at GameplayBehavior_BehaviorTree it makes me wonder how exactly was this even intended to be used... It seems to be missing like 95% of the actual stuff that you would need for it to make any sense... lol
The BT it runs can't even get access to the smart object
And funnily enough if you google it, you find some stuff that relates to cheating in fortnite lol
Oh yeah and it's actually not even calling Super::Trigger which makes it look even more like some sloppy implementation that was never used for anything...
yeah this is more what my point was, what does that statement even mean haha
So I'm having a weird problem, for some reason when I remove the repetitive eqs query and add the one time one, it works, but like this it fails. Does anyone have any ideas? (Do ping me if you have a response please). Oh also if more context/screenshots are needed, I can 100% provide some
What does the eqs service do? Get a new location at some interval?
What do you mean "it fails" as well?
Yes, and I mean it doesn't give me a "movelocation"
Also I won't be able to respond for a bit, thanks for the help!
Whats the eqs centered on? Is it possible its reference location isnt set
New tutorial for State Tree https://dev.epicgames.com/community/learning/tutorials/lwnR/unreal-engine-your-first-60-minutes-with-statetree From Epic
The EQS doesn't immediately return, so you don't have a valid move to location. I recommend keeping the task and moving the service to the move to task, so that it only updates while the AI is moving.
hi, does someone have any idea on how to make the AI climb the wall? the "move to" doesnt work....
Hi, what could be the reason for Rotate to face BB entry to not work?
- Animation is not set as** root motion**.
- CMC Used controlled desired rotation is set to true.
- It get's stuck at Rotate to face BB entry until AI faces at 0 angle player, anything but 0 angle will make the task stuck.
- Target is found, looking at visual logger it's set as focus.
I'm not sure what else could cause this.
Ok, found issue. AI Controller Tick was disabled.
Hey I'm trying to build an RTS prototype and I have a weird issue with forming a formation with units. the units sometimes move to the correct position and sometimes not exactly and they stop their movement in an offset. (usually the first time fails and the subsequent attempts work just fine on a button click). I'm stuck at this for like a week..
TArray<FVector> ARTS_PlayerController::CalculateRectangularFormation(int numUnits, int unitsPerRow, float unitSpacing, const FVector& Origin)
{
ensure(unitsPerRow != 0);
TArray<FVector> Positions;
Positions.Reserve(numUnits);
int row;
int col;
for (int i = 0; i < numUnits; ++i)
{
row = i / unitsPerRow;
col = i % unitsPerRow;
//
float unitX = col * unitSpacing;
float unitY = row * unitSpacing;
Positions.Emplace(FVector(unitX, unitY, 0.0f) + Origin);
}
return Positions;
}``` this is how I'm calculating the points, but it doesn't seem to be problem. I think it has something to do with AIController but I dunno what exactly..
these points are always forming a rectangle I have checked them
void ASoldierBase::MoveToLocation(const FVector& TargetLocation)
{
if (AAIController* AIController = Cast<AAIController>(GetController()))
{
FAIMoveRequest MoveRequest;
MoveRequest.SetUsePathfinding(true);
MoveRequest.SetGoalLocation(TargetLocation);
MoveRequest.SetAcceptanceRadius(1.f); // Adjust as needed
FNavPathSharedPtr NavPath;
AIController->MoveTo(MoveRequest, &NavPath);
}
}``` and this is how I'm moving each unit.
UAIBlueprintHelperLibrary::SimpleMoveToLocation(SpawnedSoldier->GetController(), GoalLocation);``` tried this one first and then used the one above. both behave the same way..
Here is a short video showing the problem, the first button click doesn't arrange the units properly.
the behavior is the same with other formations as well, Triangular, linear..
Gotcha, thanks!
Well that's a bit of a gotcha... Apparently calling PerceptionSystem->RegisterSource does... absolutely nothing unless you've previously registered sources with specific senses you want to register :P
Does anyone know why the rest of my blackboard variables don't appear in the MoveTo node?
Climbing a wall is not functionality that is in the engine by default and you need to add it. You need to break it down into 2 separate problems:
-
The AI needs to know that they can get from point A to B via climbing. The easiest way to do this is to use nav links.
-
The NPC character needs to do the actual climbing. This typically includes animation + implementing the movement. If using nav links, you can get notified when entering and exiting a climbing link. How that needs to be set up depends on if you are using C++ or BP
Move to only allows vectors or actor key types. You need to set your target key to an actor.
what do you mean "doesnt want to target the player"
wont attack? wont follow? are you storing the target?
im new to the ai stuff so i followed the tutorial in the documentation, any issues i had i found solutions for but this
it can see me, it updates when i enter its los, but it will not change the bool in the blackboard
im sure its a very outdated tutorial, i just cant find out whats going wrong here
before hand i hooked up a print string between each set value as bool which is this
i do have it set to neutral friendly and hostile
if i connect the print to tell me the bool coming out of the AND its false, which i assume is because of the player tag not working right
yes it is an actor tag not a component tag
even when i disable it tho, and it returns true, it still doesnt update any of the variables or start chasing
have you set a break point there to see what the value is?
anyone any idea about this ? I'm still stuck..