#gameplay-ai
1 messages Β· Page 65 of 1
Yeah, great, you can continue not knowing anything and sharing that with people. Cool
you're projecting a ton of things onto me that arent what im saying at all π
You're saying you got upset because someone pinged you when continuing a completely relevant conversation
I think you're reading this the wrong way Vaei and that is affecting how you're currently responding.
What is the right way to read it?
Because I actually don't understand this person
To me it reads that they're being upset over nothing and extremely rude in the process
I was trying to be helpful
im not upset about anything i just was saying you probably meant this forReddification
They didn't have a good answer and admitted it, why would someone not want to know for future use?
To the point where they actually call it out
Someone does. But all she said was that she didn't understand the ping. Which is fine.
I mean, I pinged them both
You're just projecting some kind of emotional thing on it when there isn't.
That's all
Yeah, I saw that.
If I were in their shoes I would not respond if I wasn't interested
Sure. And that is your prerogative. They chose to respond.
Right, but their response was extremely weird at best
Just chop it up as miscommunication. That's all really.
Why would I know that this random person on the internet has no interest
That is not a sane thing to assume on a server like this
i mean you pinged me i assumed you wanted an answer, as most ppl that ping do. Its fine tho. I was just trying to say i dont need this and that it was probably Reddification that needed it, or a place to start looking for his own solutions
I didn't ping you, I replied
Which happens to ping you if you don't turn it off
Which I'd only do if I knew you wouldn't be interested, and I'm not psychic
I pinged Reddification
Its such a non-issue that I don't understand getting weird about it and making it an issue
To be fair - you can also turn off pings on reply. The person who is doing a reply that is.
It wasn't an issue really. It turned into an issue
When she made her comment, you also could've just said "okay"
yeah the reply sender has the option not to send a ping
Which I acknowledged and addressed
Before either of you said it
the intent with my answer was to feel out what fit the game's design. Maybe pushing other ai out of the way isnt ideal for the game, maybe it is?maybe what they need are formations, there's a ton of ways this problem can be solved, but it needs context of the problem to really get a thorough answer out of it
Hey, anyone willing to help out with a basic behavior tree question?
I cant figure out why at times after it gets to "Switching state to Passive" sequence it starts to rapidly go between the first and second tasks in the sequence (Clear_Focus_BTT and SetMovementSpeed_BTT), but never touching the third/last option (Sequence)
what does the rest of the right most branches look like?
my guess would be that your decorator or move along patrol fails and it fails the sequence
are you trying to move between points that have proper navmesh below them?
I think so
might need to step through the execution here.. and see what the values of the keys of your tree are at each step.. visual logger can maybe also shed light on whats happening
You mean the values of my blackboard keys?
nod just make sure that everything is what you are expecting it to be for those decorators
then you will probably have to look at your tasks to make sure something isnt failing out improperly or like, not able to generate paths to move along
i switched only the position of the 1st and 2nd task (under the "switch state from passive" sequencer) and it seemed to not even move from root anymore (the arrow coming from top right is root)
have you tried stepping through the tree? using break points?
you can see the values of your blackboard that way too
Have not, how do i set breakpoints?
Hi, is there a way to Initialize StateTree asset from pawn like this?
AIController->GetBlackboardComponent()->InitializeBlackboard(*BehaviorTree->BlackboardAsset);
AIController->RunBehaviorTree(BehaviorTree);
Trying to avoid creating multiple AI controllers per enemy type π
right click on your node and click toggle or add breakpoint
ty
np!
thanks, i'll check it out
Can anyone help me out with making AI accurate to Half-Life 2's Combine Soldiers and/or Metro Cops? I tried something but I didnt get very far..
Yeah, you have an Initialize Component function in the State Tree Component IIRC
This library looks very interesting. You mention it's production tested etc. Any chance you can share names of games that use it? If not here, maybe in a PM?
We use our own solution but we're always looking for better options (if any)
I'd prefer not to share it in public in this context, I can DM but doesn't let me
@tawdry zephyr yeah, same. Sent you a friend request just so we can talk
Could not find the place where I can configure asset in runtime.
Found the answer, it seem nope, doing those things dynamically is not an option. Probably BT with optional dynamic state trees are a way to go. Thanks.
the ai keeps atacking whit this how do i stop it
I'm observing some weird stuff in vislog. Can it be, that the same controller is shared among multiple pawns in the same play session as if controlers were pooled? for example, in 4 consecutive ticks vislog shows that the same controler controls different pawns... wtf is going on? can it be somehow related to world partition? because I think it's the only thing that currently distinguishes my other test levels from the test level this problem appears in
Also i forgot to mention that I have about 30 npcs on level, but vislog only shows 5 AI controllers
Ok it does seem to be related to world partition, because when I disable it in world settings, vislog shows the correct amount of AI controllers, but what do I do with it? I never thought that AI controller can be shared between pawns when programmed the logic... π€
how do i change the animation of the ai
I don't think you can. You can extend the component, have an array with you trees + an array with their Instanced data (or a map with both), have a function call in tick component to tick that array of trees. You will need to Initialize (start) those trees. You will need to override start, stop, restart etc so they loop your map. In each of those functions you will need to create an execution context object using the tree in question and the Instanced data
This will give you the ability of adding/removing trees for said map at runtime
But you will face other problems, like the debugger not working properly (adding a track every time call FinishTask on a tree in the map), you will have to build logic for events, so you send them to the main tree or to a Mao-contained tree etc
I have logic that is data driven so, depending on the enemy, we use a main tree (the one the component will handle automatically) + different trees we add to that map based on the enemy capabilities
Answering this
And this
Both questions mean nothing to me (and I'm guessing most of us)
First one shows a random BP that sets a bool in a timer. So.... What's that doing?
The second gets a different answer: where? How? When? Tutorials maybe?
alr fix that one
It's better to do precise questions with data rather than "how do I develop ai"
i got and AI
i got the character that i want to use
and the animations for it
but idk how to change the one that i have for the new one
Ok... Do you know what the animation blueprint is?
What? Dw? I alr close? Sorry dude, but I don't understand what do you mean
"yes but don't know, I already closed Unreal"?
Try some kind of tutorial like this one (warning: I haven't seen it) to get some general sense, maybe even try stuff you learn there after watchign. If still nothing, come back with questions more precise
https://youtube.com/playlist?list=PLNwKK6OwH7eW1n49TW6-FmiZhqRn97cRy
βDonβt worry, I already closed Unrealβ
Heβs saying heβll work on it later
Aaaah dw... Don't worry...
Silly me.... Sorry, English is my second language
english isnt my second language and i cant really read it either so i wouldnt be too hard on yourself heh
hard to tell what was typo and what was intended words
Just looks like someone who has very little typing proficiency/speed
Rather than a language issue. But if you're not used to it it'll be hard to interpret
So is mine
Skill issue π
But yeah, Iβm used to some of these abbreviations
I have encountered some weird behaviour with the StateTree component, something seems off: I am ticking it manually, and it is ticking automatically as well (even if the component tick has been disabled).
I checked by removing my manual tick call, and it's still getting called from the TickTaskManager. Even the actor that has it attached has tick permanently disabled
oh its definitely internet slang, not typos or proficiency imo
have you looked at the call stack when it goes into the tick function? might shed some light on where it is coming from
I just found the issue, will leave it here just in case somebody runs into the same thing - The state tree component was a blueprint class, and even if C++ disabled the Tick when constructing the component, the Blueprint class had tick enabled, which was overriding the C++ setting. So mostly me forgetting there was a blueprint class associated xD
x_x
Hello everyone!
AI controller makes the shipping project freeze without crashing or any error. From what I have noticed, if I disable auto possess, this does not happen anymore. I use Unreal 5.4.4 with World Partition and the animals (AI) have is spatially loaded activated (if I disable the map it doesn't load anymore because I have a lot of animals)
I manually placed the animals on the map and do not use a spawn system
Even tough it's a shipping build, what happens if you run it attached to Visual Studio (or Rider)?
How do I do this?
Are you using any c++ at all in your project?
Form Visual Studio or Rider I mean
If you do, simply run the project with Shipping Game config
If you don't use c++ at all, it's gonna be more tricky. In that scenario, I would first run a development build or a test build to see if the same happens. Those two configurations produce logs and might give you some clues on what's going on
If the logs do not show up anything useful, you will need yo download the debugging symbols from the Epic Launcher, visual studio community, boot up your build and attach VS to it.
I converted to C++ with absolutely no game freezing related errors
Downloading deb symbol now
Absolutely nothing
If you are already using a c++ project I don't think you need the symbols? Not sure, I have always used the github repo, compiled the editor myself etc. Never used the market place vanilla editor
Here is the part where the game is freezing, the rest is from the forced closing from the task manager
Any other suggestions?
The pso's can take a long time to load (it's a famous hitching case in released unreal games) but that should be far from freezing the game.
Before force close, hit Pause in Visual Studio while the game is frozen. It should pause at whatever is doing. You can check the callstack for the main thread. If that doesn't show anything, check if there's any task job or thread doing anything. Might be something stuck in a thread and the main thread waiting for it
I noticed that if I delete all the animals from the map or if I change the setting from auto posses ai to disable this doesn't happen anymore, but I don't understand what could cause this bug
I try to put this setting suggested by the animal dev, maybe this is the cause
Until now, this setting is disabled for all characters, including the main character
does anyone know how to use a subtree in different BTs? When I make a subtree, it asks for the BB of one enemy but if I want to reuse it for another enemy, it will say BB is incompatible even though the same keys can be found in the other enemy's BB as well (plus some extra ones)
Absolutely nothing
But in that picture you are not attached to the running game
Does the bug only happen in shipping or can you repro it with a dev or test build too?
What I meant was:
- start a development or test build
- repro the bug where the game freezes
- if no ensure or check happens in VS while being attached, hit Pause in VS
asked both chat gpt and copilot and they both say it should be fine as long as the subtree's initial asigned BB has the same keys as the other BT's BB I put it in. But it still says incompatible.....
afaik the BB has to be the same
is that the only way?
All enemies sharing subtrees need to have 1 single common BB?
as far as I know yes
You can use inheritance in bb's if that helps you
the "Parent" property of the BB?
Yeah
So I would have 1 Base BB as a parent for all the enemies and they will have their own BBs inheriting from that, so sharing subtrees will work?
You can have a big tree, a general one, where you run subtrees (dynamic or static). The subtrees can use a child of the general tree BB. I think that should be a valid case
Yeah pretty much. I'm it 100% sure, but I think it could work
what is the difference between a dynamic and static subtree?
RunTree vs RunDynamicBehavior
sorry, could look this up myself instead of asking you...
In one you state which tree asset to run (static), in the other you assign a g.tag to the node, which you use to dynamically run a sub bt assigned at runtime
Imagine you have a data asset per ai that states which bt assets use for combat, idle, patrol etc
In your main tree, where you decide which of those states the AI will run, rather that having a specific bt asset set in the Run BT Combat Task (run subtree), you have a tag. That tag corresponds to the key for the combat tree in your data asset.
That way MeleeAI has a different bt for combat than SniperAI
But they both use the general tree to decide what to do
When the task combat runs, you use that g. Tag to grab from the data asset the right bt to run as sub tree, (melee combat bt, sniper combat bt)
Hmmm, interesing. So dynamic is used for when you have one main tree for all enemies. that is "overriding" the subtrees based on the tag.
Yeah, something like that. It allows you to be able to make your bt's data driven, which eases the way to reusability of bt's
do you recommend the approach of having one BT for all enemies or having separate ones for each enemy?
I guess it depends on whether enemies have a similar general behavior, right?
Yeah... Pretty much. Imagine you make a souls game or a game like The Division. Having separated trees for each type of enemy might be too much unnecessarily. Chances are that your melee enemies do more or less the same (mind bosses) things with small variations to make then different. The will be in idle or patrolling until they engage combat, then do whatever they do, which for melee might be "approach target and do X attack", while other melee does "approach running and then attack". Just to vary thet "running" part, it's silly yo have 2 different bt assets
Dumb example, but not too far from reality
In one game I was part of, all enemies used the same combat tree. Their specialities would come from which tree we run in the leaf selected. If they had a pistol, range approach (look for a nearby cover, go there, then shoot). If they had a baton, run to the player and hit it.
I see. Makes sense. Will give that a go, thank you so much!
It only happens in the shipping project
I can't reproduce it in another package (deb, development) or in the editor
Then try to attach to shipping. Better than nothing I guess
If you could build the editor and project yourself, you could change couple things to enable logs in shipping. Maybe that could help if attaching to the shipping build doesn't help either.
also, asked you in DM as well, what do you think is better between BT and ST?
For what I gather using st's and judging by how much you know of bt's... Stick to bt's for the time being. St's lack documentation and have core logic weirdness when not bugs. Maybe after 5.5 they will be better
I have already done this and there is nothing in the log related to that game freezing
But attach has nothing to do with the log. Attach will cause a breakpoint if a check or an ensure happens (I believe disabled in shipping). But what you can do is acutualky pause the build execution form VS and see where does it stop. Chances are that it will be the code running in loop that makes your build to stale and crash
And when your run the build in development, do you get warnings that might explain anything? Or ensures?
I would imagine that you have something that is prevented in builds that are not shipping followed by a log or something
It's rare one gets a crash like that in Shipping without warnings in a dev build
The only warnings are the ones when I pack and are mostly related to metahuman where it says that the asset was saved without a version
It also works perfectly in the editor and development
I use world partiton and have the animals set to is spatially loaded, I think something is happening here
I don't believe you don't get warnings at all while running the development build. Nobody is that good XD
I immediately package it for development and send you the log
Could be. Maybe you can do visual logging in shipping. I used to have a nasty bug once due to some initialization shit that happened. I figured it out because I tinted all AI's green when done, red before calling the bad function and yellow if I called but never finished. Got some yellow dudes in the gsme and could track from there
PITA but...
I'm talking about logs while running the dev build, not the packaging logs
You want to look at the logs generated in the Save folder of the build when you run it. Same thing that shows in the outputlog window when you PIE
Oh, ok, but when I test in package development, that bug does not happen and in the log there is also nothing related to a possible error for shipping
In your case I would look for info in the logs about the animals initialization process, the world partition etc
it seems to be a problem with auto possess, if it is disabled, that bug no longer happens even in shipping, but if it is set to something else, then that bug happens
Something is off and surely some warning is letting you know withiut you knowing
I will check, thank you very much for your help and for your time
You could also try disabling all the AI's logic and see if they spawn at least. If they are there brainless, you know it's something in the AI logic. If still happens, something with the way they spawn
No worries. Just procrastinating adult stuff to prepare the week ahead XD
I manually placed them on the map
Let us know if you figure out this one. Good luck
Sure, thank you very much
I strongly recommend using a spawning system, but there's nothing wrong with it. Chances are something that happens after spawning breaks things. And if not... You also know where to look
I will also consider using a spawn system if I can't find the cause of that bug
At least for now put the AI's in their own data layer and pack the game without it. To double check your game doesn't work due to ai spawning. Imagine you start the build without any ai and still get that problem
You were right, although it doesn't happen in the same way in shipping, it seems that there are some warnings in the development log
[2024.09.29-18.27.11:128][619]LogScript: Warning: Script Msg: Attempted to access index 0 from array 'Eyes_17_F352401649EBA276B93B75812EE4A429' of length 0 in '/Game/AnimX/_Common/Realistic/Structures/S_Styles_R.S_Styles_R'!
[2024.09.29-18.27.11:128][619]LogScript: Warning: Script call stack:
/Game/AnimX/_Common/Realistic/CompBP_Material_R_ANX.CompBP_Material_R_ANX_C.Set Materials <---
/Game/AnimX/_Common/Realistic/CompBP_Material_R_ANX.CompBP_Material_R_ANX_C.ExecuteUbergraph_CompBP_Material_R_ANX
/Game/AnimX/_Common/Realistic/CompBP_Material_R_ANX.CompBP_Material_R_ANX_C.ReceiveBeginPlay
[2024.09.29-18.27.11:128][619]LogScript: Warning: Script Msg: Attempted to access index 0 from array 'Size_21_469B8FF145D5C01BFA9F1CB2F6AD23AF' of length 0 in '/Game/AnimX/_Common/Realistic/Structures/S_Styles_R.S_Styles_R'!
[2024.09.29-18.27.11:128][619]LogScript: Warning: Script call stack:
/Game/AnimX/_Common/Realistic/CompBP_Material_R_ANX.CompBP_Material_R_ANX_C.Set Materials <---
/Game/AnimX/_Common/Realistic/CompBP_Material_R_ANX.CompBP_Material_R_ANX_C.ExecuteUbergraph_CompBP_Material_R_ANX
/Game/AnimX/_Common/Realistic/CompBP_Material_R_ANX.CompBP_Material_R_ANX_C.ReceiveBeginPlay
[2024.09.29-18.27.11:128][619]LogScript: Warning: Script Msg: Attempted to access index 0 from array 'SpeedMultiplier_40_1FA5DCA043F576EAF8A30FB0A6B993DA' of length 0 in '/Game/AnimX/_Common/Realistic/Structures/S_Styles_R.S_Styles_R'!
[2024.09.29-18.27.11:128][619]LogScript: Warning: Script call stack:
/Game/AnimX/_Common/Realistic/CompBP_Material_R_ANX.CompBP_Material_R_ANX_C.Set Materials <---
/Game/AnimX/_Common/Realistic/CompBP_Material_R_ANX.CompBP_Material_R_ANX_C.ExecuteUbergraph_CompBP_Material_R_ANX
/Game/AnimX/_Common/Realistic/CompBP_Material_R_ANX.CompBP_Material_R_ANX_C.ReceiveBeginPlay
[2024.09.29-18.27.12:591][620]LogScript: Warning: Runaway loop detected (over 5,000,000 iterations) - see log for stack trace
AIControllerBP_ANX_C /Game/Map/Map_Forest2/Generated/6E80ZK5UYOGS29LW4I66RA1RR.Map_Forest2:PersistentLevel.AIControllerBP_ANX_C_2147475358
Function /Game/AnimX/_Common/BP/AI/AIControllerBP_ANX.AIControllerBP_ANX_C:ExecuteUbergraph_AIControllerBP_ANX:05CD
Script call stack:
Function /Game/AnimX/_Common/BP/AI/AIControllerBP_ANX.AIControllerBP_ANX_C:ReceiveTick
Function /Game/AnimX/_Common/BP/AI/AIControllerBP_ANX.AIControllerBP_ANX_C:ExecuteUbergraph_AIControllerBP_ANX
[2024.09.29-18.27.12:591][620]LogScript: Warning: Script call stack:
Function /Game/AnimX/_Common/BP/AI/AIControllerBP_ANX.AIControllerBP_ANX_C:ReceiveTick
Function /Game/AnimX/_Common/BP/AI/AIControllerBP_ANX.AIControllerBP_ANX_C:ExecuteUbergraph_AIControllerBP_ANX
Runner loop, more than 5k iterations.
Game will crash after the limit is passed out of security
Now I was looking at that error π
Do you have any idea how I can solve that problem?
620]LogScript: Warning: Runaway loop detected (over 5,000,000 iterations) - see log for stack trace
AIControllerBP_ANX_C /Game/Map/Map_Forest2/Generated/6E80ZK5UYOGS29LW4I66RA1RR.Map_Forest2:PersistentLevel.AIControllerBP_ANX_C_2147475358
Function /Game/AnimX/_Common/BP/AI/AIControllerBP_ANX.AIControllerBP_ANX_C:ExecuteUbergraph_AIControllerBP_ANX:05CD
Without looking at your code no idea. Looks like soemthing you have un the AI controller BP.
Ah not 5k, but 5 millions
Do you have any form of do-while loop?
Maybe a recurrent call to soemthing?
Yeah that looks like an infinite loop. If the condition never changes, trapped forever
Honestly the animals (AI) are taken from the marketplace so I don't know their systems very well
That loop checkign for the AI state looks uber dangerous
If that state never changes....
I would add a counter in that loop and if it happens more than 1500 times, the skip it or something and tint the AI so you see some red dude looking ugly in your game
I would track where does the AI state change in that logic. Maybe in shipping is not happening
So where to change AI state seems to be the problem
I'll try to leave them on default, maybe that won't happen anymore, then I'll check as you say
I changed states to attack when hit and that bug in shipping doesn't happen anymore, thank you very much once again for your help and for your time! π
Glad you found it and happy to help
Hi! One question, has anybody tested performance differences between using State trees as an actor component, and State trees integrated with Mass?
We have Mass entities that are synced with Actors, and our current setup has State trees as actor components (was easier to setup). Performance is acceptable if we lower the tick rate, but I was wondering if the component has some overhead and we could maybe get any benefits by using the other approach (such as multithreading possibilities for tick etc)
Macros are either in StateTreeTrace.h (so StateTreeModule) or StateTreeExecutionContext.cpp (these one just wrap the ones from StateTreeTrace.h
In both case, they are surrounded with #if WITH_STATETREE_DEBUGGER
I will try to make it work and notice you
MassStateTree doesn't tick each frame, they tick each time the Mass Entity receive a specific Signal + you avoid cache miss by accessing StateTree split across your data
I can run multiple thousands of AI using MassTree on my project but it's not really designer friendly
^^^^ it pretty much has no regulartick.. i was running several thousand state trees using synced actors AND path findingat 60+ fps even
which is probably more non mass driven state trees could
@slow bobcat
In order to compile i had to add extra STATETREEMODULE_API in StateTreeTrace.h (i'm in 5.3 maybe it changed)
I successfully added my own log in StateTree debugger, now i need to understand the scope
same in ue5.4
how does it look like in the Debugger itself?
In our case, the state trees need to tick each frame (some tasks do at least) - so I guess it's less efficient that way and probs not very different from component?
Mass has tick as well but it is centralized on Processors
You won't have plenty of tasks ticking but one processor ticking for all your AIs
MassStateTree only need to change its current state when the processor finished their work for one specific entity
Yeah, that is true - I already aggregated ticks for that reason
With Mass you have aggregated ticks + multi threading and you avoid cache miss since the data is contiguous (aggregated by MassFragments/MassArchetype)
the multithreading would be awesome, dunno if the component supports that
thanks a lot for the input, I'll look into it
is there any docs or references on how to implement it?
I only could found about component setup
great, thanks!!!!!
Oh they exposed a new function to get the debug id
I had to change the scope of GetDebugInstanceId to public π€
I'll do a screenshot for how does it look
here it's in the transition scope
So you see the log are outside of any state/task
Hello, why does NavLink Reached run on all actors?
when the NavLink references are different
2 actor, different NavLinks
but if AI enters 1 of them, the signal goes to all of them :/
(from reference)
is this some kind of BUG?
I had to restart the Editor
weird
Been here myself last week trying to keep 2 trees running in parallel debug within the same execution context (so it doesn't add a new track whenever a task from the second tree finishes). Couldn't make it work, but epic gave me some advice. Will see
Maybe a dumb question but I am following 60 min tutorial for StateTrees and this basic setup is not working properly:
MoveTo task constantly fails, then sometimes characters start to move, then stuck again.
I was able to make it work by removing Success condition and adding Delay ask in Idle, but it feels like a hack.
Anyone know of a way to get a thread pulled path length? The methods the nav system exposes seem to skip it for perf reasons, but that means they sometimes give a value that's longer than expected/accurate
Find random location and move will run at the same time but that doesn't guarantee the random location will be ready when the move to calls. The first one calling FinishTask, will invoke the transitions.
I know... Mental.
Ideally you will leave the random location task as Running, then keep running hte move to until you have a random location to go to. Then start the actual move to and only finish it when you finish the movement.
That transition you have to success will trigger if you are returning anything but Running from any of the 2 tasks.
Isn't there a Lenght call in the FNavPath returned by the nav system when calculating a path?
I recall soemthing in those lines
Hmm first one triggers only onece on state enter like this
So no Finish task is being called, unless docs are outdated or missing something that has changed in 5.4 π
Ok, then that part is figured out, but you still have the other part. That logic above runs at the same time as the move to task. And the order is not guaranteed. You need to create something that will keep the move to task waiting for the random location to be set before the call to the movement logic
My guess is that you are falling into a case where moveto tried to move before the random location variable is set
I might be wrong though. It's important to know why the move to is actually failing, I'm just guessing
Thanks, will try to look into that. Strange that it was shown as an official example π
I can only see that it is marked as failed in debugger and is spamming state reevaluation
That example has some flaws, like the part where they suggest that you can disable a state so it doesn't evaluate unless you call an event to enter it. If a state is disabled, it doesn't work no matter what you do.
Set a breakpoint in your logic when you call finish task and check.
Either the move to logic is failing or you have some logic to fail the state before getting into moving
Strange thing is that if I remove conditions on transition like failed or success and let next state with delay to start - it will magicallt work as intended
Ummm so....
- get random
- move
- delay (wait)
The you see movement, no matter if failure or success?
That would indicate that the movement is indeed always triggered and the state fails (or succedes) due to other reasons
Then I think that you are triggering the finish task call without waiting for the actual movement.
- look for location
- move (you don't wait for the Movement to finish, you straight return success/failure)
- back to root, repeat
- override the move to order with a new one, effectively canceling the previous one, started the previous frame
Maybe you can show us the code of the move to task you use in that tree?
it is default one - comes with state tree
I think I found the reason
hm nope
seem only one case when RandomLocation was always called after Move
You can make move to a sub state of random location with a condition where Moveto will only enter once the random location is set
No that's the exit. Look at the enter order, it's fine
You will need yo figure out why the move to task returns a failure
The exit order makes sense
- random, then move
OK exit, evaluate towards the root.... Moveto, random
Then idle (next state)
Doesn't say why it failed when you expand MoveTo?
Seems you can still show info
Nope, only input parameters :/
Works in this setup
Maybe some race condition with assigning random location
Definitely
State trees are not production ready because of the this obscure shit happens all the time
Is that location valid? Within the nav mesh etc?
Is it reachable?
You are allowing partial paths but no idea if the move to task considers a partial path success or not (in case that location is within nav but not reachable from where the AI is)
it seems first location that comes is above floor
and all next ones are correct
as soon as actor moves for the first time + smooth sailing
Ah... Maybe you are not projecting the point on the nav etc
And you don't have conditions checkign the move to will be done under safe conditions (point actually projected on nav) etc etc
But in any case, mistery solved. Kinda.
Welcome to epic state trees, labeled experimental for a reason
Waaaaaai a second π arent they "GA" ? π
Ga? What do you mean?
General Availability - they are not marked as experimental it seems
Well... Seeing how much they are changing in 5.5, and how horribly bad is to debug them in any kind of build... I would ignore that ga tbh (I didn't know they weren't experimental anymore)
I saw there is a lot of changes for 5.5 but are they substantial or small fixes here and there? Seems most of prs fix some minor things
I looked just over it, saw the environment context was substancially changed. They are adding the utility approach too. Will see. I might have overreacted and panicked when checkign github.
I am confused a bit as I wanted to switch to ST from BT for large numbers of enemies and it just keeps on giving π
Debugged a bit more - seems something with NavData gives an actor coordinate as a random value and MoveTo Task fails. So it takes some time for NavData to become available. Why it is quite random - question. So we can rule out race condition in StateTree π
More of a conceptual question: to me it feels that BTs lean towards handling state on a blackboard and StateTrees rely on an Actor to store it state even though usage of parameters can be blackboard substitute (from C++ with mutable refs to parameters). Is this a correct assumption?
I personally use logic driver pro when I want FSM for AI instead of BT. There's a free version that's probably still better than state trees. It's well made
This I used for our previous game until St's rolled out and I replaced our LD fsm with St's. Our LD stuff was super simple so it was OK. It's replacing Bt's with St's what is a headache
If you figure out how to write to a global parameter using refs, please post it here. Nobody here seems to know how. The only way I could do was to expose things like this:
- a task reads a param (global/Evaluator)
- the task do its thing and stores a value in X component
- an Evaluator/global task reads the value in X component and exposes it copying it into a param
But there's no "task writes value in global param"
I tried different combinations and nothing worked
More info here
#gameplay-ai message
Im having a problem where a blackboard key keeps changing back to self actor despite being set. Has anyone else ran into this problem and if so, know how to fix it
Do you mean at runtime? While running the tree? Keys do not reset by themselves, they need to be set manually. There's something you can set so a bbk is shared among different trees, can't remember the name of the option. Wonder if you somehow enabled that and different trees are sharing oyur bbk
Curious why you'd change (downgrade?) from LD to ST
Not a downgrade, a different approach. We swapped because the goal is to depend as little as possible from third party plugins, specially if there's a plausible/usable tech provided by epic. The change worked very well because it was a simple usage (a layer controlling general states of ai)
Now... Replacing Bt's with ST's... That's a different thing.
Fair call. I understand not wanting to rely on third party especially if it's a long term project
Esp if epics alternatives meet your needs
Sometimes you even get lucky and epic buys the third party plugin you use (like what happened with Mutable)
Oh good god I still have nightmares about that things initialisation issues
Basically unusable in MP. Hope they fix it
yeah i couldnt figure it out, i was using it for a float variable so i just decided to set the variable in the btt for the time being
but thats not really a long term solution
Where/how are you setting the value in the bbk?
sounds like something is mistakenly setting this key tbh, either a node has the wrong key assigned, or some external (to the bt) thing is setting it like a bp or code .. or maybe some corrupt data got serialized and initializing it weirdly. Have you stepped through the code or bps that interact with the key?
Trying to figure out. I use ST for AI commander and it works great. For enemy AI it feels a bit cumbersome as you need events to make reactive transition, lots of properties on a controller/pawn. The upside is is that STs should in theory be a good fit for lots of dumb enemies (30-50) on screen.
they are pretty good for that, i used them to drive mass entities behavior and manage navmesh pathfinding for a few thousand entities
honestly would have been fun to bring that prototype to production, but the realities of the current industry climate caused us to change course
maybe in the future haha x_x
Dunno if 50 mobs justify going into mass yet. Want to iterate to get metrics first π
oh yeah our game was very focused on large herds so it was pretty warranted in that case
This default MoveTo is in StateTree looks like a mess π¦
AITask_MoveTo keeps reinitting task with flag Garbage
Yeah I don't think it's getting cleared in the exit State so if you return to that state after completion it'll still be there but ready to be trashed
Then it gets into the loop that task cannot activate
Found a root issue - I was starting logic in OnPosess, which for some reaon worked on one AI Controller, but not on another. Now I am doing it during BeginPlay of a Pawn and suddenly all movement is correct. Dunno if there is a proper primer on how to initialize all of this in C++?
I was setting the variable in the aic bc it was a static number but it wasnβt returning that number
It just kept returning 0
so I changed the number in btt
@slow bobcat
//InstanceData property decl:
UPROPERTY(EditAnywhere)
TStateTreePropertyRef<int32> RefToInt32;
// In Tick:
FInstanceDataType& InstanceData = Context.GetInstanceData(*this);
int32* MutableInt32Ptr = InstanceData.RefToInt32.GetMutablePtr(Context);
(*MutableInt32Ptr)++;
UE_LOG(LogTemp, Warning, TEXT("[%d]"), (*MutableInt32Ptr))
Seems to work this way, but I have opted for same approach as AnimBP - Global task to evaluate environment/owner properties (Some on enter/ some on tick) and then let states to act on it + some event when AI sense gets triggered to ensure we exit idle/roaming ASAP.
Wait.... Static? Then... There's your answer. Can you show us the declaration of your variable? Just to confirm you don't have a static bbk or something like that
Aaaah I see... Damn... Thanks dude. This is very helpful
sorry i just meant static in the sense of the word thats its not meant to be changing after i initially set it in the aic
its not a major problem but if i ever want to the btt for other actors id like to be able to set variables
I'm curious, can you show us how you declare your bbk (if it's in code) and where and how do you set its value that one time? If you want of course
yeah i deleted it just bc i couldnt get it to work but ill reset it up
Its the close attack key
everytime i click on the bts it reverts back to self actor
instead of close attack key
ive never seen it do that
and its only happening when i set the blackboard key selector to the "close attack distance key" if I set it to anything else it keeps the variable
i think i got it working, upon deleting everything connected to that variable restarting unreal and recreating it, i got it to work.
What's the event where all that is connected to?
You might just had a weird bug maybe?
An event begin play with a slight delay
Yeah
One question: is that property bound in the state tree?
Yep - you have to bind it for global task from parameters π
Got a really annoying issue with navigation meshes: I can't use static/prebuilt navigation in my project. The navigation mesh seems to disappear on play/simulate. Dynamic works fine though. Been pulling my hair out over the last day trying to figure this out!
Here's an example of editor->simulate for static generation:
And with dynamic generation, during simulate:
Odd. Try deleting and readding it?
yeah, tried a whole bunch of suggestions from forum posts and reddit; that was a very common fix π
Are you maybe somehow moving the landscape or the navmesh volume at runtime?
Iβve seen instances where peopleβs world wasnβt at 0,0,0 so it caused all kinds of issues
Do you have sub levels? If that's the case, you must have a nav mesh bounds volume in the persistent level. Otherwise, when the nav generates it will put the recast object in whatever sub level finds first during nav generation. Then, unless that sub level is loaded, you will not have any nav.
That or you might have done as suggested by NeoExcidius and have moved the recast object out of 0,0,0 after being generated
im making a tower defense game and adding automation to my turrets. Would it be cheaper to add AI sight to get the enemies or would it be better to just have an array of enemy references I could loop through and supply them to the turrets?
Im assuming AI sight is way more expensive?
Your own logic would definitely be cheaper especially if you plan on having a ton of actors
https://zomgmoz.tv/unreal/State-Tree/ @misty wharf This is invaluable, mate. Thanks.
π
I'm getting the type " does not match type X error with Output binding, though. Do you know if that's fixed?
//.h
USTRUCT()
struct FSelectNextPatrolPointTaskInstanceData
{
GENERATED_BODY()
UPROPERTY(VisibleAnywhere, Category = Output)
FVector Destination;
};
//.cpp inside EnterState
FInstanceDataType& InstanceData = Context.GetInstanceData(*this);
...
InstanceData.Destination = Patroller->GetNextPatrolPoint()->GetActorLocation();
Are you binding to a property of something else? Like, Actor->Location or something?
I'm binding that directly into MoveTask's target destination. Also tried with Actor.
Hm I recall this would usually occur if you were binding to a property of something instead of binding directly to the value (eg. Actor->Location vs. having Location directly as a vector to bind to)
It might just be an UI level issue though if it's what I think it is, and it might work despite the nag
Ok, thanks, I'll check that!
Argh, a full rebuild fixed it.
thanks
Trying to wrap my head around a problem, that probably has been already solved, but cant find any specific solutions:
I want to run EQS query in a state to find attack location. As EQS query is a latent action I start it on enter state and when it is completed, set it to output parameter. Thing that I am trying to understand how to pass this output to next state and if OnComplete is suitable here. Here are tow options I am trying to setup:
If SelectLocation and MoveToLocation are on a same level I cant use output parameters in latter
One solution I can come up with is to store results of a query on a pawn or controller, but I would like to avoid such dependencies as much as possible
Also a question about StateTree instancing. Does every controller get its own instance of a state tree and all the parameters are fully isolated?
The way I solve this pattern:
- your task needs an Out parameter to which the next (waiting) task will bind.
- it also will have a Control Variable (more on this later)
- start the latent action on enter. Here is where binding to delegates happen. OnEnter returns Running if you successfully launched your latent action, Failure if not.
- have a member in your class that you want to check (it can be a bool, an array of query results, a string... Your pick). By default that member is null/empty. Let's call his a control variable. Reset your control variable on enter before launching the latent action
- have a callback function for when the latent action finishes. Once you get the callback, write the value of your control variable (this is also a good time to unbind from your delegate).
- while this happens, your task is Ticking. Tick checks the control variable. If set, apply values needed in your output variable (to which you will bind in the next task) and return Success. This will finish the task and jump to the next (and trigger transitions). If not set, return running and keep waiting for the latent action to finish.
- your next state "should" be a substate (this you already have)
Once you return success, the bindable parameter will be available for the next state.
Careful when doing this in a Global Task: returning success from a global task STOPS THE TREE AS IT WAS FINISHED.
One main problem you will face and the reason of the control variable: most delegates you will use are made for you by epic (like the eqs). Your callback function will not retrieve as a function param the execution context of the tree, so you can't really do much there in terms of Tree Flow. That's why I use the control variable and handle things in tick, because there you have the context to do stuff
Yes. This is controlled by the fact that each instance of the state tree component has its own data and context usage
Hmm, so I will have to have some sort of the state on an actor anyway right?
Hmm maybe different approach - what if I make a combined task, like MoveTo but MoveToEqsLocation, that will run a task and then will start a move task as a part of a single state, so they can feed one another?
AFAIK there is an AITask to run EQS
Or have this data as a part of something like CombatComponent as it is needed anyway to feed EQS with active target via context π€
As valid as anything else. We tend to merge functionality now and then if we see we always use things together
This doesn't have a straight answer. It will depend on your games's architecture
I mean I can run a task, and when it completes, set something like NextAttackPositionLocation and then next state can take it and do a moveto
But merging them probably would be cleaner - Like TacticalMoveTo π
More or less what I was suggesting. I'm sure you will find the best solution for your project
Yep, seems like a solution. Would love to see more out of the box toys for statetree though π
Hi, why are nav modifiers not working on UE5.4 ? I've set runtime generation to modifiers only and I added a nav modifier component to my DoorBP but the nav mesh doesnt get updated with the movement of the door
Afaik the β dynamic - nav modifier onlyβ is for when you change the modifier class or add/delete a modifier at runtime, not make dynamic holes in the mesh for something that already exists but is moving
Yeah i found a youtube video it is a bit strange how this works with rotating meshes and why some things are not working. But I found a way.
For everyone with this problem...To update the nav mesh along with the rotation of a mesh you can add and attach a box collision to the mesh. Set it to dynamic obstacle with area class to NavArea_Null and you should disable can ever affect navigation on the mesh. After thats it is working as a dynamic nav modifier
Anyone using state trees successfully for more advanced AI? I looked into State Trees recently and saw they are getting more updates in 5.5, but am kind of unsure, and there aren't many resources out there.
I am working on a systemic AI with pattern of life behaviors, more complex than your average combat driven AI. I was having luck with implementing this using BTs until the number of branches got sufficiently complex and then it became difficult to understand. I dabled with executing sub-trees, but the problem remains, just more obfuscated.
I like State Trees because they are simply easier to understand and I believe could be used like a hierarchical planner, where the ST selects a task and then as sort of a hybrid can executes BTs for more complex individual behaviors, which are easier to implement there.
This is a high level blockout of how I need my AI to function, and would appreciate any feedback, suggestions you may have.
Note: colors below have to do with NPC types, green if they have military training, etc.
I've never heard of pattern of life behavior, what is it?
I guess it is like the NPC has his time table to do actions out of combat. Just my understanding
Correct, systemic behaviors and goals, for example some of the highest goals are to simply survive, eat, work and sleep. Far away from the player these behaviors will be part of a simplified background simulation, but can also be observed up close.
Smart Objects and Mass are a really big step forward for Unreal, but it looks like State Trees (which obviously don't just apply to NPC AI) seem to be quite early and from what few examples I can gather they are very much not ready for production yet.
Mass is also quite technically complex, so not as usable for most developers without a team
We do have complex ai. In the lines of what you are doing. We have a state tree to decide on a very high level (idle, Caution which is your search, Found which is your move I guess, Combat, Patrol etc), each state runs a different bt where we actually handle the meat and vines of each. We also have several state trees running in parallel (not suported until 5.5 but we have our own implementation since months ago, we couldn't wait) where we check for other things (ie: do some special behavior, react to something etc). Those send events to the main tree to jump into special states that can only be accessed by events. We dynamically set the bt to run in each case within that special state.
My advice is to combine state trees and bt's. For example, your patrol. In our case Patrol would be a sate like yours, but anything under it would be in a patrol BT (look for target, find patrol point etc etc). The ugly part? You need to invent how to run a bt from the state trees (not difficult since you have direct communication with the AI controller)
You also can use sub trees if that helps to simplify things
I think you still can do it with smart objects and state trees without mass indeed.
Hi Bruno π That's exactly what my research told me would work best based on several papers and GDC talks, and it makes a lot of sense. Good to know at least someone else has tried it in UE5.
Is there any more specific info you can share on running BTs from the State Tree?
This is kind of where I started hitting some soft road blocks in terms of how to properly manage data, etc. Since BTs rely on BB, how do you properly tell the ST that a task is complete, etc?
I have not been able to find even a simple example of how to do this that makes a whole lot of sense, but maybe I'm missing something more simple here. It would be really great of anyone with more knowledge to put together a very simple example on GitHub or something, could be extremely benificial and maybe help shape how Epic improves State Trees going forward.
Mass would be for background NPCs that don't need to run the full state tree, for large world simulation stuff, but I'm not at that point yet π
There aren't any examples or support put of the box.
To run a bt you just need to call RunBehaviorTree from your BehaviorTreeComponent. It will tΓΊ in looped mode, which doesn't call the OnBehaviorTreeFinished, that you will need to handle manually by checking if you are pushing a new tree (different form the one before) and calling a callback to your state tree component. If you run the bt in single run mode (for this you need to copy/paste the code un RunBehaviorTree and change the flag passed, amazing this is not exposed), you can register to the engine's delegate for when the tree finishes, but theres a bad thing: single run bt's are not Instanced and the instance kept. The engine will create a new instance on run and destroy it on finsh. Careful with that, it's more expensive in cpu than one would think.
For the BB part I ended up doing a St Condition that can check values on the BB. Basically made a class that inherits from the interface that allows you interact with the BB. The class has a parameter for which BB to read from and which BBK to use (you can expose the bbk's in a BB, just check how the engine does it in their Blackboard decorator). Then, in your condition, have a parameter with is an Instanced pointer to that class. I can't share the code sorry, it's an in development project, nda and what not.
With those two pieces you can now run bt's or not from your St based on BB conditions
I might put something in a github as you mentioned. Just need to find the time
Thank you very much, that's really helpful, completely understand per your project. One last general question, besides the change(s) to run STs in parallel, did you have to make any critical changes to the engine in C++?
Honestly this might be really huge for the community especially if we could get some eyes on it. AI is one of the areas I think there is an extreme lack of resources and samples from Epic, and one I've been hoping the community steps up to fill. If you do find the time even to do even an extremely basic example project to share, I would be very interested in contributing to help flush it out more as a community resource. Please let me know if you do!
Ummm small stuff. Mostly making some function virtual, but you might not need to. I do have quite a bunch of custom logic
I would love to have a blog like the ones from Vori or Quoid Soler focused on AI, but I do too many things outside work I'm afraid. Will try to do a github repo. I already have some things up and public related to nav (bit outdated now), so that parts is done I guess
I'm not sure if this is the correct channel but does anyone have any ideas on how best to handle the nav mesh for areas like this? Characters can walk up the 'steps' and is wide enough but the nav mesh doesn't detect it. Any suggestions?
Any chance your nav volume is not reaching the upper part? Wonder if the stairs are translated into a slope in nav that is more angled than your limit
Does it change if you modify the altitud of the last step so it is like the first one?
The nav mesh volume is about 4m high so encapsulates the entire area.
I'm pretty sure the nav mesh resolution isn't enough to pick up details that small, try changing the cell size (Project settings>Navigation Mesh>Generation>Cell Size), but be careful to set it just as small as necessary.
From playing with the settings, I've only been able to have it generate on top of the blocks by decrease the agent radius which isn't ideal. :/
I think you need to treat this like a special navigable area with a nav link, I wouldn't expect a global nav mesh to be able to handle narrow surfaces by default which is why game metrics are usually quite a bit bigger then the real world. Either change your metrics, or adapt.
I thought that might have been the case. I did think about using nav links but not ideal. Thankfully this is just a test enviroment so trying to gauge pros and cons lol.
Itβs either too high or too narrow. For the first one you can try changing the step up size or just use a navlink as suggested. For the second you can create custom supported agents and reduce the agent radius (iirc the correct setting). You can find supported agent settings in project settings
It's fine. I just need to make sure, widths are at least 1.2m and I should be good. (Or avoid them altogether)
Is it somehow possible to set blackboard variables on a BT before it runs?
You can set the Blackboard variables themselves from the AICon with GetBlackboard iirc
thanks for your response. i checked and there is indeed a 'GetBlackboard' function. however its input is an actor, and its unclear to me how exactly i could use this to set a blackboard value on a BT that has not yet run. ive also realised there is a blackboard component, and so now im actually quite confused as to where blackboards actually live. my understanding was a BT has a blackboard assigned to it, and so to get a reference to the blackboard you would need to go thru the BT somehow. is this not the case?
in this image is basically what i wish to do... i am creating a BT from a soft class reference, and before it actually runs on the AIC i wish to set a blackboard variable. is that possible somehow? π€
You donβt set values on a BT. You set them on the blackboard.
yes sorry, this is what i wish to do. i just wish to set a blackboard value before the BT runs for the first time
by 'setting' a BT i mean i am assigning a new BT to run on the AIC at runtime
I donβt know why youβre so confused. Youβre showing unconnected nodes instead of actually connecting them and trying it out
i have tried it out. so you are saying this 'set value as vector' node should be after the run behaviour tree? this appears to not work as i presume by the time the blackboard value has been set the BT has already started running.
I see, thank you that seems to be a promising direction. i will see if i can get what i need with this
@dense owl
Hi, is there somebody that as played with statetree and smart object with the gameplay interaction plugin ?
I wanted to know if it's possible to get a reference to the gameplay interaction statetree to send a statetree event to him. I dont seem to find how to do it, so i was asking my self if it's even possible.
I haven't done anything with those in particular, but I vaguely recall these are kinda sorta possible, but you may need to create your own "use smart object" AI tasks which send the appropriate info into the behaviors etc. so they can communicate appropriately
How to trigger transition in state tree from a global task?
I want to interrupt whatever is going on in the tree.
I have a global task that sends an event, but it doesn't trigger a transition!
Hmm ok so i would need to do a little bit of c++.
I've found an alternative in me case wich consiste of stoping the use of the smartobject and then send the event to the ai controller state tree.
But thanks i will keep that in mind
you could put the on event transition on the root maybe ?
would it trigger if the current task is in mid tree?
it should i think but not sure
it seems to be working thanks, i will debug it to check if it triggers in the same loop or the next one
99% sure is the next. When you send an event it's added to the queue in the tree. The next time the execution context is created to tick your logic, the events are consumed
That said, the 1% doubt comes from a bit of code where they handle events triggered in between ticks as a by product of transitions happening
so in another word it is 99% executed on the same tick the event is received!
Hello, I've got some crows in my game that use MoveTo to walk around the map. I'm trying to make so that they wouldn't enter certain areas so that they don't get stuck.
I made a custom custom navigation filter I assigned to the DefaultNavigationFilterClass in the crow's AI controller. I also made a custom navigation area that would be treated as unreacheable by that filter, but I don't see to make it a thing.
In the navigation area I can only set the navigation cost which wouldn't help at all since I don't care about reaching a path a certain way: I don't want to consider certain areas at all. I can add a certain navigation area in the navigation query filter, and it has a flag IsExcluded which I thought means "don't consider me in your navigation", but apparently it means something else (the property comment doesn't specify anything).
I see that there are some navigation flags that I can play around with, but in the navigation area it says SupportedAgents All, and it doesn't allow to change it at all in the BPs.
So my question is -- does anyone know how to make a navigation area that would make a certain query filter treat it as unreachable, whereas others would not be affected at all as if the area is not even there?
An alternative solution is to put an invisible wall only those agents can bump into, but I would like not to
using excluded in the nav filter should make it so the area is not traversable when the filter is used
Oh, yeah, it actually does. For some reason it didn't work last time. Trying that again worked just fine, maybe I missed something last time π
What are people's opinions here about Behavior Trees vs State Trees? Which do you prefer and why? I personally prefer and have used BTs, but would like to see some more opinions.
Little state tree question.
Is a pointer to instance data reliable as long as the task is running?
I'm asking because I'm trying to set up a delegate callback from a tasks instance data but it seems to be corrupted when it's called. However in the tasks actual tick I see that my instance data is still there and valid
Yes. As far as you get your instance data pointer from the execution context object, all good.
I don't know how, but I'm guessing there's a way to get the instance data of a task externally. The state tree component has the instance data of the tree. I guess it's a matter of research how the execution context gets it
What it's not reliable is to store a pointer locally from the execution context instancedata, because the ex. Context is changed and destroyed constantly
Is anyone aware of any Unreal specific AI up rezzer?
I'm trying to reproduce a Blueprint from a 720P Youtube video tutorial.
Much of the text is illegible but I would imagine that any Unreal specific AI tool could easily 'sharpen' the text and make it legible.
Right channel for the BT questions, wrong channel for the ML upscaler video tools, and I seriously doubt unreal has anything like that. You never know, but not within their business model so far
Hm. If using states in a BT is just full stop a bad idea, I feel like I should be changing over to State Machines ASAP. Since even just trying to keep a grip on what unintended transitions a BT might spit out with its colliding priorities and considerations within a particular state, i.e. combat, feels like way more work than manually setting up every intended transition; at least I can see the end of that process.
Hi there, guys
Maybe someone had this problem before
I have a custom actor without MovementComponent
And when Im calling FindPathToLocationSynchronously it makes a path that is too close to the walls
Is there a way how to make an offset from the walls when calculating a path?
FindPathToLocationSynchronously takes a PathfindingContext where it gets the AgentRadius from, idk what kind of actor your actor is, but you'll need an object that implements INavAgentInterface like the NavMovementComponent. (Depending on the difference in size you may also need to define multiple agents in your project)
Thanks, just found it out in code too
Will try to add this interface to C++ class
Slightly simplified overview of how you go from NavMesh to NavPoints and a path to follow in a higher overview (of course some things differ in implementation but its nice if you have no idea)
Quick question, what is the equivalent of FThing& A in StateTree parameters? I want to pass a specific parameter to a task and let that task set a value to it
void MySTTask(FThing& x)
{
x = ...
}
I'm not sure about the question, but I think what you mean is having an Category = Input property inside the InstanceData that you then modify? I'm not entirely sure if modifying it is possible (using a reference there). But you can probably have another property with Category = Output bound to the same object which you then write to (equally I don't think this property is a reference either, but would need to look into it).
Hey!
I'm running a EQS query from BP (within a State Tree task). That EQS has a circle generator that uses data binding to get values from the query.
Well, it all works as expected with the circle radius using Set Named Parameter, but trying to set the number of points makes the editor freeze completely. I triple checked that the name of the parameter is correct. I'm guessing if that could be because the number of points is an integer and Set Named Parameter only accepts float, but then what could the solution be?
Thanks!
is going from behavior trees to state trees big perf gain if i have hundreds of npcs? or do they tick the same way and its just about structure/readability
ok seems they tick the same way xD
Turns out ST doesnt provide what I am looking for
Output variables are not for writeback
Maybe this helps
#gameplay-ai message
Anyone have experience fully implementing the orders-abilities project from Daedalic?
Has anyone ever made a spherical/planetary pathfinding for AI?
How is this different from the default path finding?
https://www.youtube.com/watch?v=ei2YR7UR9DE
Someone did this, apparently.
Test performed with nativize blueprint enabled containing pathfinding function blueprint
Test Pathfinding at event tick for stress test
The screen displays the time it takes to find the path in milliseconds
The pathfinder in the video is limited to water, but you can add and or remove any type of surface from the search
There is line trace suppo...
I am having a little bit of trouble with my nav mesh, im trying to have it be modified by specific actors, but every time i set an actor to be a modifier, while they are spawned in mid play, the take up a much larger portion of the nav mesh then they should. As you can see below the one on the left which was spawned mid game is nullifying a massive portion compared to the on the right. Does anyone know why this would be happening?
Hey! I must be missing something incredibly simple but I can't figure out what. I'm setting up a new very simple State Tree in a new project on 5.4.3 and the Delay Task is not playing at all. I've added a breakpoint in FStateTreeDelayTask::EnterState and it hit 5 times before any task, but there is no hit on FStateTreeDelayTask::Tick.
The State Tree is completely barebones:
In another project I originally had something like this:
but the behavior is the same (all states get called 5 times, then there are 5 MoveTo tasks on the AI Controller)
I assume default pathfinding always assumed Z down for gravity
I would assume you have another task in that state that's failing or succeeded immediately
Anyone have any experience or any talks/articles on attaching AI to combat areas (or any kind of "areas"). The goal would be to define where the AI is allowed to go, or prefers to go. At what point it should leash back to it's "home" or where it should be allowed to pick from for idle wandering.
I feel like a sphere or a circle would be the cheapest and popular solution for this. But I'm wondering if there's not a solution that supports more complex ideas like being able to define the inside of a building or even a certain floor of a 3 story building
But that's the weird thing, the MoveTo state has only a "Move to Location or Actor" on Enter State. It still fires up 5 times. I've found out it's because of this in FStateTreeExecutionContext::Tick:
// This helps event driven StateTrees to not require another event/tick to find a suitable state.
static constexpr int32 MaxIterations = 5;
for (int32 Iter = 0; Iter < MaxIterations; Iter++)```
I also realized the Delay Task in the old State Tree that worked fine in 5.3, but the Delay Task in that same State Tree does not work in 5.4. I guess is giving up on ST and going back to BT/BB's then? π¦
You can debug state trees with the visual logger to see where things are failing. There's also logs for what happens with your move request to see if they're failing or not
5.4 allow write back from c++ and 5.X ? will provide full support
All the tasks of a state are executed in parallel if any succeed or fail, it ends the state
Use the debugger to know which one is ending your state
And make sure the tasks that you want to run doesn't call finisTask, you could have a "run forever" parameter that prevent that
It's not multithreading tho (just sequential parallel)
Ah crap, I didn't scroll
Yeah, I read about it yesterday. But even the "original barebones" with a single task per state had the same behavior (executing 5 times, not executing the Delay Task). The MoveTo FinishTask should only run when the move to gameplay task finished, but with the AI debugger (" ' " on the viewport) I can see all 5 move to tasks queued up on the AI Controller.
You call finish task when the request failed or when the move ended
It's ok but it means your move to failed?
sure, but it always succeeded (the find random location radius is 6 meters around the character, and it's just an empty test map with a huge navmesh)
yes
Else check the visual Logger navigation
I was trying to debug it, but we can't change the engine, so it would be kind of useless anyway
You should investigate the move to code step by step to know what's happening
The visual Logger should show you navigation etror
I checked the logger, there were no navigation errors. On the ST debugger I get all 5 transitions:
besides it actually triggering the EnterState of all valid states 5 times (even though FinishTask is never run on the MoveToRandom state), it never triggers the transition to the Wait state:
5.5 will provide it
Your exit condition is false so it doesn't even enter in the next state and fallback to root
Hello there, in a state tree any idea how to transition from a state to either one or another ? I tried to set a transition with random threshold on 2 different other states, to no avail, as i've also tried to transition to a group and add an entry condition with a random threshold, same result. Could anyone give me a hand here ? (See pics for an idea of what I'm trying to do)
for UAITask_MoveTo, why are these not public -_-
They may have a getter
But you could also get a reference to the path following component and hook into those delegates.
Should be on the AIC
thank you that worked quite well as a test
void AZombiePawn::TrackPlayer()
{
TArray<AActor*> FoundPawns;
UGameplayStatics::GetAllActorsOfClass(GetWorld(), APlayerPawn::StaticClass(), FoundPawns);
MoveToTask = UAITask_MoveTo::AIMoveTo(GetController<AAIController>(), FVector::ZeroVector, FoundPawns[0], -1.0f, EAIOptionFlag::Default, EAIOptionFlag::Default, true, true, false, EAIOptionFlag::Default, EAIOptionFlag::Default);
if (UPathFollowingComponent* PathFollowingComponent = GetController()->FindComponentByClass<UPathFollowingComponent>())
{
PathFollowingComponent->OnRequestFinished.AddUObject(this, &AZombiePawn::MoveFinished);
UE_LOG(LogTemp, Warning, TEXT("Found path following component"));
}
MoveToTask->ConditionalPerformMove();
UE_LOG(LogTemp, Warning, TEXT("Tracking: %s"), *FoundPawns[0]->GetName());
}
void AZombiePawn::MoveFinished(FAIRequestID RequestId, const FPathFollowingResult& Result)
{
UE_LOG(LogTemp, Warning, TEXT("MoveFinished"));
FTimerHandle Handle;
GetWorldTimerManager().SetTimer(Handle, this, &AZombiePawn::TrackPlayer, 3.0f, false);
}
Because Epic hates reusing code
:p
That should have been a non-pinging one sorry :D
all good lol
We have this changed in the engine to make it public since the ancient times XD
Why not just subclass opposed to a full engine fork
I've had to PR a few things for AI but the AI team are really responsive so its not as painful as animation programming stuff
If you give them a clear use-case they'll generally accept exposing something
Good question. Think we have been dragging the change for so long that we forgot to check if it's needed anymore
Agreed. I don't mind doing PRs for AI team. Very responsive.
Hey All, I'm having some trouble with the default BP move to node when moving to a target that is also moving - since the moving actor is only observed at a fixed tick the resulting movement is somewhat stuttered. How should I go about resolving this? I first thought is to write a custom node that handles movement outside of pathfollowing if there is a direct path to the target (determined via a nav raycast). Is this a reasonable approach?
Is your problem that your AI is always behind following the target (as in "it never intercepts") or that it takes too long to react to correct course?
Not an issue with it getting to the right place, but choppy turning when the target is moving perpendicular to its current velocity
If you use a Behaviour Tree, I believe its built-in MoveTo and Focus nodes make for a smoother move to target
Thereβs also some turn rate and acceleration/deceleration options in the CMC that can help
I don't want to have the focus set in this case, since that would mean the NPC would face the target even in the event of the path being longer/ around corners ect. Setting it for the last portion would be okay though I guess, just need to poll that somewhere
Yeah, this is what fixed it for me before
I do have logic that focuses on the path if it's not in the last segment path. Once it engages with the last segment (direct line to the target), then focus on the target
Alright that seems reasonable. Where do you do this, Path following comp?
Yeah
Alright, great. Thanks for the help you two, appreciate it!
Good luck
Out of interest how would I path a ai to where it can sense if there's a blockage that it can move along it's path, say a door it can open ?
Would I just have it sense what's infront of it and when it sensing a blockage it can move to stuff to move it and then carry on or would have have to do additional stuff ?
Without thinking too much into it: maybe you can place a nav link in that door so the path calculates trough it. Then maybe a trigger that, on enter, will play the open animation. You will have to handle that pause in the path following tough. You can always call stop movement with the same trigger and re-path after the open animation
Wwll I was thinking could I do something like the ai senses in front of it and it it comes across an obstacle it does stuff stop moving to a goal and then try to continue after completed its action
I think nav link might be odd cause it'll slide on that
Not necessarily. The nav link will ensure that your path is calculated through the door but the movement will stop as soon as you get into the trigger
How to parametrize Smart Objects with gameplay behaviour? I using Smart Objects wit AI Behaviours (as per https://dev.epicgames.com/documentation/en-us/unreal-engine/smart-objects-in-unreal-engine---quick-start). I want for NPC's to look for random "Idle" object, go there and perform animation. I did that, by creating definition SO_Definition_Idle, assigned to smart objects, which references behaviour SO_Behaviour_PlayMontage. It works, but the montage played is "hard coded". I want designers to easily choose an idle animation, different for a chair, couch, bed etc. Is there an option to maybe expose the "animation" parameter of SO_Behaviour_PlayMontage to be editable in the level editor?
Hi everyone, I want to customize the NPC Path do you know where should I do this?
Use nav modifiers and give the AI a different nav filter
Guy behind state trees gave this talk at Unreal Fest Prague. He's not at Epic anymore, but the info still stands
https://www.youtube.com/watch?v=YEmq4kcblj4
In this presentation we'll have an in-depth look into what State Trees are, how they work and can benefit your work.
As we'll walk you through the UI, we'll showcase how efficient and flexible this tool can be for both designers and programmers. We'll cover the core functionality, useful features and of course the latest coming out in UE 5.4 and...
Hi @fathom sun if you mean NavMeshModifier and NavFilter, I am using both but what I want is to change the path NPC uses to navigate to the destination I want to modify the PathPoints, Do you know where should I look for?
Customize how? You can just get the path points as an array and change them if you feel like it
hi, is there any way to limit how far from an agent the navmesh generates vertically? there is an option to limit it horizontally, but i am making a level with multiple floors and its generating the navmesh for all 11 floors and its not really performing well
Thanks @misty wharf, That is exactly what I want, I tried to changing those points via PathFollowComponent But the character was not following the added points, I wonder to know where is the right place to do this?
Also the character doesn't follow modified points.
Check for a function calles PostProcessPath or something like that. That's a good place to do it
How to stop AI character stopping moving temporarily? AI blueprint logic is in AIController class based BP.
StopMovement
ty, tried it but it was something else that was causing problem π
What problem? You asked how to stop moving a character lol
Is there a way I can reposition the pawn sensing component?
Yeah. I think you're right. Just confused why there is both I guess.
Don't think I can change AI perception location either though, which gave me a problem when the feet of a character were obscure but the rest of them wasn't.
So I made a component or something with a transform and AI stimuli and attached it to that and made it detect parents that way too.
You can customize where the sight is traced to
GetPawnEyeViewPoint or something like that
does anyone have any knowledge on how to replicate Half-Life 2's combine or Metrocop AI using blueprints or c++ or anything?
You will need to define which behaviors does it have in game, what does it do, then design it
Maybe there's some video somewhere with a behaviors' analysis
Something like this, but for hl2
https://youtu.be/cOSCBMHGE18
A look inside the Half Life AI system, examining how it created smart and life-like enemies.
Support my Patreon: https://www.patreon.com/simoroth
Buy my game MAIA: https://store.steampowered.com/app/252250/Maia/
I guess Iβll think of something
does anyone know how to change the default gamepad button. is currently the (A) button for xbox controller
Lack of data, definitely the wrong place to ask
bAutoRegisterAllPawnsAsSources=false```
why when add this to config the AI can't move
This has nothing to do with movement
If that causes them to stop moving, then it sounds like your movement is only triggered by sight
Hey I know there is an event on pawn see but is there a way to check when the pawn doesn't detect any other pawns ?
Basically when the enemy does not see you
I forget what the exact function is called, but you can get a list of them from the perception component
Get perceived actors ?
Oh so I can just check if the player is one of them?
But will I get pawns or actors?
You will get perceived actors. You will only perceive pawns unless you have set up something else manually
Since only pawns are perceived by default
Hi all, I'm working with melee enemies in my project and I've had this issue where they seem to pile up on each other. Is there a way to have them navigate to the same or similar direction without bumping into each other?
Okay thanks
Master AI Locomotion with Behavior Tree in Unreal Engine 5.4! π
In this tutorial, youβll learn how to set up basic AI locomotion using Behavior Trees in Unreal Engine 5.4. Whether you're new to AI or looking to enhance your gameβs NPC movements, this tutorial covers everything you need to create intelligent, responsive AI characters.
π§ What Yo...
Hello. Is it normal that sometimes the AI move to node will return success when it finds a path to the target location and at other times it will return success when it arrives at the target location. I'm getting both results from the same AI Move To node and I have no idea why? It doesn't make sense to me. Why would the success output cover two different conditions?
What am I missing here?
Question:
I keep getting Nav Ai move to error aborted and blocked from my npcs. But it's pretty much a flat plane. I don't understand what they are hitting
They will start moving at the target then stop after a short while and error out. Once in a while if the target is close they will do it just fine, then on the next move to go a little ways then error saying aborted or blocked. Yet nothing is in the way.
It's a boat moving across the water from 1 dock to another.
hi guys, I just started studying State Trees, so I ran into the problem that I have a state in which the AI has to go to a location or actor. It is implemented through the AI Move to node. The problem is that the Finish task is immediately after the Fail and Success pin of the AIMoveTo node, but the tree constantly enters this state again. A new AIMoveTo begins, and the old one is aborted and ends with a fail. How can this be fixed? Maybe there are some State Tree settings for this, or some special function/state is needed?
Anyone happens to know why my Recast Nav Mesh resets its properties each time I open the level? It doesn't save my edits and it is not taking the properties from Project Settings neither.
Try making custom nav agents
Sorry, but I fail to see how that has something to do with the mesh generation and the Recast nav mesh not saving my edits on level change 
Alright then donβt try it
I'm not sure what desired result you're looking for but here's some things to keep in mind:
State tree will try 5 times to find a valid state to enter when it fails to find one (I'm simplifying a bit here, be this is why the tree re enters the failed state)
AIMove state tree task does not clear it's failed request on exit. Which means if it's immediately called again, it'll re use the failed task and stop immediately. I consider this a bug because the behavior tree equivalent does handle this property.
I've got a behavior tree with a TargetActor blackboard key, in My service I am finding a target and setting the TargetActor then I'm calling MoveTo with the TargetActor, initially the ai will follow the player but it will suddenly spas out and the BT is jus flashing the MoveTo node over and over without moving anywhere even though the TargetActor is set.
It's like MoveTo is grabbing the initial location off of the TargetActor and then never updating it even when the Target moves... is there some special setting or something that needs to be enabled on the move to node?
Hi friends does anyone knows how to create custom path for our agents? I want to create a custom path instead of the path is created by navigation but I don't know where should I do this, I will be appriciated if you help me to solve this issue, Thanks in advance.
Iβm trying to make a gun centric npc Ai for my half life 2 ue4 project my think I want to make is smart Ai like combine soldiers or metro cops that do certain things in combat I donβt know a lot about unreal Ai but any help would be appreciated
I would start checking tutorials for AI in YouTube. Get string basics before attempt anything advanced
As in modify the one recast gives you? You can pass whatever you want to the path following component really. What people usually do is apply modifications to the path obtained through recast
Hi @slow bobcat Thanks for your answer, But I am really doing that but that is not working, I've created my own recast class and override the FindPath function I am simply adding a point to the PathPoints to see if it has effect or not, Although the Point is added but my character doesn't follow the points goes from the shortest path still, I don't know how my character chooses shortest path, I am using CrowdController for my character I believe that shouldn't edit my main points!?
Your point might be getting filtered out in the string pulling phase... I don't know if that function runs before/after that, you might want to check
Also check that your recast class is actually being used, I vaguely recall there were a few hoops you have to jump through for it to do that
Hey I was wondering is there a way to check how far the player can see? Because I'm using the exponential height fog so I can limit player view and create atmosphere and I would like the enemy to stalk my player just barely at the point the fog starts. Can I get the distance between the camera and the fog ?
Hi @misty wharf Thanks for replying, Actually I already tested my recast class is being used, I also realized the problem is comming from CrowdFollowingComponent of the controller that overrides the points I am using without Crowdcontroller it was working as expected, But now I don't know exactly which part of this component overrides my Path! Does anyone knows where should I look for this issue, I will be appriciated if you help me to find the right place, Thanks in advance.
Grabbing the camera location is easy (you have an api for it) but the fog stuff is up to you I guess? No idea how the fog system works, if you can trace to it or what
Hey, people!
Has anyone solved the need to wait for a GAS Ability Task to finish inside a Behaviour Tree Task?
Thanks!
Okay thanks I will figure something out
Also I don't think the camera location can help much. I can tell the ai to move to a point in a specific radius of my location but 1 I don't know what the radius is for the fog and 2 the fog is changing through the game
Oh wait I just realized when using ai move to you can use a float to limit how close the ai comes to you
Hey @livid dew , I already did.
Can you give me a hint of what your solution looks like? π€
I think I'm close enough by creating a custom ActivateAbilityByClass that returns the instantiated Ability and having a delegate in it that will be invoked when it's finished. Then the BTT binds to that event and only finishes its task when the Ability Task is effectively finished.
But that may not be the correct approach.
Greetings,
I have a smart object here. I want two NPC to be at each side and trigger an animation if there are. How can I check in the Gameplay Behavior if both slots are filled?
They are the same smart object, just two different slots, but I don't know how to check if another slot is currently in use.
I've not done exactly this but I have something slightly similar which uses a component on the SO actor to track this. Basically the SO task communicates with the comp
There might be some way to communicate through the smart object component itself as well but I've not looked at that, but at least it seems like something that could work - I do recall there are ways of getting more info from the SO you're interacting with, but you might have to create your own code for interacting with the SO, as I recall the builtin one somewhat lacks in the regard for advanced stuff
Thank you, I'll check it out
Who else here using state trees?
I'm trying to figure out best practices when it comes to transitioning between states on complete, failed or success.
It becomes so confusing with how one can run multiple parallel tasks in one state. There seems to be no setting for waiting to see if all tasks are completed, succeeded or failed, it only checks the first one, if it has completed and then if fail or success.
Anybody know of a good way to handle this stuff?
Is anyone able to shed any light on why move to location or actor behaves as if it working, (The NPC starts to move) but they then stop and a few seconds later, triggers the on move finished pin despite not reaching its location. The location is reachable on the nav mesh.
Is it possible to create non replicated ai's on clients and make them follow the local player? When I try AI Move To node, character rotates to target but can't move. Is there any setting I need to play with?
I've found splitting them into tasks which get stuff and tasks which do stuff works well https://zomgmoz.tv/unreal/State-Tree/Custom-StateTree-tasks#task-design
Are you using runtime navmesh generation? If the navmesh updates it could potentially affect it in this way
Oh wait, it's not non-replicated. When listen server tries to make it move, it moves on the client as well. Is it not enough to simply tick off the replicates on ACharacter?
It's currently set to static.
Ok that's not it then... Check in Visual Logger if it outputs anything useful. It usually shows more information on move failures there
So the tasks that get stuff are set up to not finish execute, and the tasks that do stuff do finish execute?
And then only do one task that does stuff per state?
Yeah
All right, it sounds interesting.
I suppose the doer task can't execute before the getters if it takes in variables from the getters?
Or could it and then it just gets the defaults? π€
if the getter tasks are asynchronous then the doer can execute before the data is available
Seems then it's necessary to make it synchronous to avoid this possibility.
But by default all the tasks within a state are asynchronous.
So one has to set up the synchronicity manually?
by async I mean if it doesn't make the data available immediately when it executes
iirc as long as it does that then it should be fine
Oh you meant it like that, ok then it makes sense that it works, since getting stuff should be really fast and doing stuff should usually take some time (eg, move to target or such would take some time).
Good shout with the visual logger. It looks like the walk speed gets set to 0. At least this gives me a place to look. Thanks for the help. π
It's not a question of speed, it's a question of execution order. Although it runs all the tasks on the state at the "same time", they do still get executed in a certain order
Oh so if i make two tasks that print a stringA and stringB, i should see some difference in the way i order them that is consistent then? π€
I'll test real quick
You need to do client-side navmesh generation as well. There is a setting in the project settings somewhere.
The reason it moves on the client when the server does it, is because it is replicated.
There may also be an AI on client setting in the project settings. Can't remember.
Yeah the order of the prints do resemble the order of they are placed under the state!
With this the getter/doer setup makes a lot of sense.
Thanks for helping out!
Yeah I am able to prevent movement with setting replication to false again after posses as well
and for that link to those notes, they seem usefull in other categories too :D
I don't know how to do this though
Oh also in the project settings, okay let me check them
Well it's already checked though
This one I believe?
Hi! I wanted to ask about Navigation in a bit of a lower level: In our RTS game, we have a custom movement system, in which unit avoid each other and also avoid/collide against buildings etc. We're researching how to "hook" to the navigation data information so that we can also treat non-navigable areas (mountains, rivers, etc) similarly to how we treat other static gameplay objects.
Basically we need to get the non/passable area polygons to process them with custom logic
You can get the flags of the nav polys your units are standing on. There's an api unreal exposes to get that kind of information
Through that same api you can check if a point in the nav is within X area
Yes, I am aware - but ideally I would get the polygons because we need to do avoidance etc before the units are standing on the actual non-navigable area
You can do that. The api uses a location to get the poly/s there. You can pass whatever you need. That's how the path finding works
Yeah, we have the pathfinding setup already
But maybe you're talking about other API - do you know the name of the function?
Ok, let's see if we can be on the same page.
What I mean by "That's how the path finding works": when obtaining the path between A and B, one of the steps is to check if the next point calculated can be trasversed. For that, the engine (using the detour recast logic) checks the flags.
The same way the DR library reads the flags of the poly involved in the calculation, you can read them too.
One easy way is using
/** Get up to 256 polys that overlap the specified box */ NAVIGATIONSYSTEM_API bool GetPolysInBox(const FBox& Box, TArray<FNavPoly>& Polys, FSharedConstNavQueryFilter Filter = nullptr, const UObject* Owner = nullptr) const;
but if you need something faster, just keep digging deeper (debugging that function) until you get to the low level code in the DR library
That call is part of the API exposed by the engine to read navigation data from the world in RecastNavmesh.h
another good one is
NavNodeRef ARecastNavMesh::FindNearestPoly(FVector const& Loc, FVector const& Extent, FSharedConstNavQueryFilter Filter, const UObject* QueryOwner) const
there's a 1:1 conversion between unreal types and detour types. You can do this kind of stuff
NavNodeRef nodeRef = FindNearestPoly(FVector const& Loc, FVector const& Extent, FSharedConstNavQueryFilter Filter, const UObject* QueryOwner);
const dtPolyRef polyRef = static_cast<dtPolyRef>(nodeRef);
uint32 areaID = RECAST_DEFAULT_AREA;
areaID = GetRecastNavMeshImpl()->GetPolyAreaID(nodeRef);
uint16 currentPolyFlags = 0;
dtNavMesh * detourNavMesh = GetRecastMesh();
detourNavMesh->getPolyFlags(polyRef, ¤tPolyFlags);
detourNavMesh->setPolyFlags(polyRef, currentPolyFlags | (1 << node.MyCustomFlag));
that's what I meant by the API the engine exposes.
Everything goes through the infamous FPImplRecastNavMesh* RecastNavMeshImpl;
/**
* This is a pimpl-style arrangement used to tightly hide the Recast internals from the rest of the engine.
* Using this class should *not* require the inclusion of the private RecastNavMesh.h
* @NOTE: if we switch over to C++11 this should be unique_ptr
* @TODO since it's no secret we're using recast there's no point in having separate implementation class. FPImplRecastNavMesh should be merged into ARecastNavMesh
*/
FPImplRecastNavMesh* RecastNavMeshImpl;
if you have your own find path implementation (I understand you do), you definitely came across this kind of stuff
awesome, thank you very much for the explanation! I think this will be enough
I really appreciate the thorough response π
no worries mate. All this stuff is quite abstract and undocumented.
Once you get the jist of it, you will be able to do cool stuff.
Some examples we do:
- we post-process the nav on cooking and flag corridors to know the width they have, so we can filter out units that are too big for that (this allows us to have dozens of enemy types and just one nav data)
- we post process the nav after creating it (we use dynamic modifiers only mode) to purge islands and unreachable polygons (what is usually called Nav Mesh Flooding). This allows us to clean up the nav data so it makes sense without forcing us to place hundreds of nav volumes. Just one per sublevel and then clean up.
awesome, the first point is something we could do as well!
I might be experiencing a bug? But Iβm going by this tutorial https://youtu.be/gsyZdKYAT_4?si=Dlm5kcKQ253SgaTG and I have my noise event on a tick on my character atm that reports noise event while the velocity is over 0 and theyβre not crouched.
The ai is perceiving this fine and sending the stimulus for hearing the event but when it switches to investigate, the behavior tree just doesnβt go through at all until the character stops sending events, THEN goes to the noise location?? Anyone have any ideas lol Iβm confused
In this Unreal Engine Game development Tutorial you will learn the following:
- AI Perception: How to setup the AI Perception component
- Sight: How to get the enemy to attack when seeing the player
- Sound: How to get the enemy to go investigate a location where sound came from
- Damage: How to get the enemy to respond to getting damaged and at...
Iβm thinking it might be because the noise event is being called too frequently for the ai to react but would that pause the behavior tree? Dunno
hey all. I have a 4x4 infinite tile grid, where basically if i move into border tiles, the tiles of the opposite direction reposition in front of them. The 4x4 grid system practically 'moving' as the player moves. How would you setup navigation on it for ai agents to follow the player?
I thought about setting its bounds equal to my 4x4 grid and reposition the navmesh when the grid repositions. Is there a better way i could do it?
Sounds to me that you are retriggering your "go investigate" logic every time a sound event happens, which it's every frame, making the logic to restart constantly. When you stop, the logic actually happens. Set a breakpoint in the beggining of your investigate logic and check if I'm right. If I am, you need some form of cooldown/flag to avoid it retrigeering constantly
You can't reposition (or move at all) the nav mesh as far as I know. You are gonna need to stick with dynamic generation around the moving agents by the looks of it
i lll check it out thank you
Hey im trying to teleport my ai a specific distance from the player or more, i know i can teleport it within a set radius from a location but how do i teleport it to any point that is a specific distance from a location.
Get the location then getRandomPointInNavigableRadius
How often are small machine learning models used? I am not talking about neural networks but simplier machine learning model made with a few hundred 1000 observations.
Yeah I did that but I don't want to get a point inside a let's say 100 units radius I want the point to be on the perimeter of the circle that's created around the player with radius 100
then use EQS context
Equasion?
And can that help me do that?
yes.
specifically the EQS Querry Context part
Okay I will check it out thanks
Has anyone used NavLinks with the Detour CrowdPathFollowingComponent? I found that when using that specific component it doesn't actually generate a path that uses nav links, rather it just seems to treat the path as a direct path between areas connected with nav links.
This is what that path looks like when using the default PathFollowingComponent
This is what the path ends up looking like when using the CrowdPathFollowingComponent
Can someone help me? This is in my AIController class, and on play it runs a behavior tree, but when I play the game it tells me it cannot access none of property CallFunc_GetBlackboard_ReturnValue
Please ping me here if you know what's wrong
Nevermind, needed to define the bool name
The trigger is the AI perception On Perception Updated event, which switches the AI to Investigation State upon getting a Sound event, so maybe because Iβm using that event, it keeps updating too often but idk Iβll have to tweak this tutorial Iβm following.
In the video he only does an example for when the player jumps which only triggers a noise event once and not multiple times like I am while the player is moving
Anyone know how I can tell the AI to play random audio on sight loss? Is that something I need to do in the tree or?
The key event to do things with an AI Controller is OnPossessed. You can't run a tree if the controller hasn't possessed a pawn yet. Begin Play and On Possess can call in different order. You should try to run your pawn-related logic there to be safe
You use the API the Perception system gives you to check if you lost the stimuli your where previously detecting and then use the sound API to play the sound. Plenty of tutorials on how to do both online. Whether in the tree or somewhere else, completely up to your needs. No wrong answer there. You could check in a tree service or in the tick of your perception component and send an event
how could I possibily make the ai walk off the edge dynamically?
so that I can make the pit detection system
use "Get Blackboard" instead
not from the "Variables" category
I am not sure if this is the correct place to ask. But does anyone have experience with Smart Objects with Zone Graph?
I do not understand why I get this Error on level start, that is coming from the ZoneGraphAnnotationComponent->ZoneGraphSubsystem:
Error: Ensure condition failed: TagToAnnotationLookup[Index] == nullptr
Annotation at index 31 is already set to SmartObjectZoneAnnotations.
31 is my SmarObject tag. If I have one smart object in the scene everything is fine. If I add two Smart objects in the scene, the error is triggered. Why is this an error then? Of course it will try to add the SmartObject tag for each new Smart Object in the scene, or am I not understanding this whole tag thing?
this channel is for AI only
go to #cpp instead
guess it ain't dynamically possible.... oh well, looks like I need a workaround for it
this should do π
here is what is happening behind the scenes
I'm using a box collision that is set to block Pawns, which makes the navmesh generate over it
Hey I know I can use a trace test in my EQS to filter out any points seen by the player but how do I filter out only the points not seen by the player?
toggle the filter bool?
Oh yeah thanks
With this setup, how can I play audio once per sight gain/loss?
Spawn/Play Sound 2D/At Location
IT just overlaps the sound
Use a DoOnce
Okay but how do I reset it?
How could I make a simple "chase the player" AI without stimuli
All the tutorials I am finding are doing it with AIPerception but i dont need it
Single player?
What I want is the enemy to run to the character (No matter where he is)
Yes
Make a task to get the player pawn - simple "Get Player Pawn" and store the result in the Blackboard
Then have a Move To task and set the key to be the key in the BB that represents the target
Create a BB key variable in the task
Drag that out to the graph and pull off it and search for "Set value as" and then select the correct type.
Like this right?
Yeah. Mark it as success as well.
Or else it won't go to the next task
Obviously you want to handle fail cases as well, but just getting things working - this is fine.
I cant select the Player location key in "Move to"
Make it a public variable
Show what you're trying to do
So, I have this
And click on Move To, then change the BB key
Take a screenshot of your entire screen
I've selected where I'm trying to change it
Should be fine. You can't really select "actor". Like, you can expand the dropdown on the type and select actor.
Try restarting the editor.
I've already done that too π
How would you guys work with navmesh on a RTS with procedural map, I'm using dynamic navmesh with invokers but it's bad, if I want to send the character to go somewhere far I need to do some workarounds building several points with max distance of the navmesh, it's so much stuff that it seems I'm doing it wrong... (probably the case)
Tbh, Iβd just place a nice and fat navmesh volume and set generation to dynamic
And for a large map I think people use level streaming
@dense owl what you said is what I have, using invokers with dynamic navmesh generation and it's bad.
Streaming is used for small/mid size maps, not massive open worlds. What brings me to Partition Map that I don't know how it works with nav meshes.
Hey guys! Is it possible to make AI ignore each other in perception? Whenever my AI chases player, they start to interfere with each other and losing sight of player because he is being blocked by other AI
issue can be described like this
I believe there are several approaches for this, I would use a grouping mechanism with event dispatcher to alert all AIs from the group (could be like: guards in 5 meters) and disable the perception once this happen. When player gets too far, reset the AI turning everything on again.
Another possibility is to store the last time the line of sight hovered the player and force the AI to move there
This would make the player able to run in circles of an object and run away easier, since AI will go to the last place it saw the player
Currently I have a setup where AI stores last seen location and goes there, but it doesnt help much, as the last seen location is also being blocked, so he tries to seek for a player and randomly might get a chance to see him again if a gap between AI's that already chasing players appears but it doesn't work really well
it's really strange that I can't feed some class to perception system to completely ignore it (ai base class for example)
and if I disable perception system, how can I track that AI actually lost player due to obstacles, if perception system is disabled, wouldn't it always chase the player no matter what? Because losing player out of sight is being drived by perception system also
Did you check the collision channels to try to filter the line of sight?
- You need to set up the team stuff. That is in C++.
- When the perception event happens, check if they're the player. Only register them as a target in your BB if it is the player.
yeah I tried different combos (visibility is first that I tried) and nothing helped really
You can do one of those two things
2 approach is that what I already do
but it still block other AI vision by any AI
its pretty simple setup to filter player only
And how do you clear the target value?
To use the team interface: https://zomgmoz.tv/unreal/AI-Perception/IGenericTeamAgentInterface
here I clear it
so if the LOS gets interrupted, it clears things but you already saw the player and never really finished your move
seems to be a state problem, you don't have the player set anymore, so you just go for idle/searching instead of waiting the AI to get to its destination and than change
I'm not a pro, just trying to help tho π
thank you π hm, but I don't really know any other way to handle this
You can have an additional state, that could be called "investigating", if you don't have the player set and this bool True, it doesn't change to idle/searching
whenever you see the player, you set this false, when you lose the player you set it true, when you reach the position, you set it false
I'm also thinking about something more stupid, like if Stimulus sucessfully sensed becomes false and it goes to last seen location, I can just throw trace to check can it actually directly hit player and if yes - set it again in BB as target
like here, check it with trace and then if it's hit - set target, if not - then it really lost sight of player
ofcourse with custom trace channel to actually ignore other AIs
I believe that would work, but if you don't have the investigating state, at some point you'll need it anyway π€
I do have it, and it works whenever LastSeenLocation is set
oh got it
so AI start to investigate last point where he seen target
like so
so he basically goes there, randomly wanders around for 5 times and then resets if nothing found
will try it, thank you for the help π
I did not say use invokers, idk where you got that
Hey guys! I'm having trouble with my AI navigation in Unreal Engine 5.
I've got an alien character and some walls that should let him pass through, but the AI MoveTo keeps failing. The NavMesh isn't blocking the walls, and I've already set the walls' collision to ignore for the alien, but the AI still won't move. Everything else (NavMesh, collision settings, and movement component) seems fine, so I'm stuck.
Could anyone hop on a voice call so I can screenshare and show the issue? Would really appreciate the help!
Once again, use the Visual Logger in Tools -> Debug to find out why exactly the move is failing
ok, ive never used that before how do i use it?
Hit Start to begin recording, then run your game until you experience the issue. Stop both and then click on each of the AI Controller's frames and read the output log
the problem one may or may not be highlighted in red
ok, i guess its working now? i dont know what i did but its working and doing what i need it to
Hey peeps, a general best-practise question. When I have a custom 'move to' and 'rotate towards' function. Would it be better to add this functionality on the Controller instead of the Actor?
If you got 1 euro every time you write this you would be rich by now XD. It shoudk be a pinned message "in case of bug, use Visual logger, then ask"
No one reads pinned messages anyway
So, I did this code so that a npc follows the enemy at any moment
In the Behavior tree
Then I tell the AI to move to the character, but i cant change the key in the move to for some reason
any idea why?
It only allows vectors and actors
I have another strange question. Why is it designed that the AIPerception Component should be placed on the controller and not on the actor(s)? I would think that I might have several different actors with different (perception) stats and only one general controller. But now it seems I need different controllers for different actors
Why is APIPerception Component not like the movement component for example
Hello, I have a bit of an issue with my AI.
I have a deer AI which is meant to run away when you come near it and spook it however it just freezes in place. We checked and it seems to get stuck looping it flee action in the behaviour tree.
But this only happens for me. Not anyone else working on the project. I have completely redownloaded the project and double checked Im in sync. It even happens in our steam version of the project but again only for me.
Also this only happens on our main map, we have a test map where it seems to work fine.
Anyone have any pointers to what the issue might be or things I could try? Thanks!
Because the idea is that a pawn could be potentially used by a player or AI, so the perception component is unnecessary in the player usecase
It sounds like the move is failing for some reason, check Visual Logger as it has extra info on this
if It only happens for you and you only, it may be something with your computers performance and the way the code is 'timed'
is your computer notably weaker or stronger than your teams computers?
I don't think so. We tried adjusting settings to be lower etc to see if performance made a difference but it doesn't seem to
GOAL:
I want enemies, when searching, use EQS to only go to places that would logically be in the (pathfinding) direction of "searchpoint" relative to "searchstartpoint". So if room a is in front of them, and room b is behind them, and search point is in roomA, never validate eqs items in room b because its impossible.
The way i'm looking to achieve this is by using "dot" to compare
the first direction the ai would go when PATHING to the sound location
to
the first direction the ai would go when PATHING to the eqs item
PROBLEM: for the "policeruntoitemeqs" context, i need the current eqs item referenced as a vector IN the bp. I don't know where i can get that, or if i can get that
attached is the eqs test, and the bp of the context that IS working, "policeruntosearch". all i want is to replace "search point" with the location of the item
hmmm
well you know for sure that its only an issue with your setup, so id say the next logical step is to find any possible differences between your computer and your teams that could possibly impact the code. my suspicion is it may have something to do with timers, delays, order of execution etc
Finding the difference isn't really that useful, you need to identify the thing that is actually happening regardless
So you just need to start from the usual debugging steps being identifying why it isn't working and you can work it out from there
Facts
Do you disable tick on ai after death for optimization, both character bp and anim bp? I am using the enable tick events set to false on both bp. Some also set the anim bp to null as well
for flying AI should use navmesh or something else and if should use navmesh what is required setting
Yeah, Im looking into this now
Just not super familiar with the visual logger so taking me a bit of time π
click record, play game, look at the little markers in it to see what happens, it should show in the log panel further details on what's going on with movement, BT, etc.
So if I understand this correctly it cant find a proper destination? and then it just keeps trying and get stuck?
Yeah looks like that's the case. If the move fails, the BT node will fail, and depending on how your BT is structured that could certainly cause it to repeatedly try it
Think on investigating its something to do with this part as the behaviour tree makes it try to run this every half a second and the result is meant to be the flee location which never appears.
does anybody know if statetree binding works with structs? I can't bind FGameplayTag
nvm, it's because the supposedly output is not accessible at that state, my bad
how can create a flying AI and waht should i do...?
I didn't start coding any AI logic yet in my unreal project for the enemies in my game but I would need some insights about it, should everything be done in BP with behavior trees or some specific part in C++? I also don't know where to start with it.. (can GAS be used lol)
Hey everyone, I was wondering if anyone has tried using state trees in a game they have shipped or are planning to ship
Same advice with normal dev, do what should be done in BP with BP, and what needs to be done in C++ with C++. For the most part, you'd do most of your AI stuff in BP, so just start with that until you need to implement something in C++
Why
I noticed that the ai turns back after jumping
this happens during the Move To behaviour
I think I need to make it keep going towards the last front facing direction while in air
yeah so if the ai is too high, it starts getting lost and tries to go back to the last known position when it was grounded
this messes with the obstacle detector and makes it jump for no reason
Well yes, the navmesh is made for ground based navigation
To make something fly you either have to fake it, increase the projection to navmesh distance or build your own custom solution
I think I have an interesting workaround for it
Hey, I'am completly new to AI Stuff. I want an NPC (animal) that follows the player. However, not stubborn, but who sometimes gets lost in other interesting things or is distracted by triggers. can someone tell me which "topics" I should take a look into?
Basically you add your other behaviours as usual, but you first evaluate of the NPC is a certain distance from the player and MoveTo until it is within range.
Its not really a complex topic unless you also want to learn how to implement other behaviours
Your first branch in the behaviour tree will do the distance checking and evaluation. If that's what takes priority
question, why my task doesnt stop? even if i run Finish Execute all the nodes still runs. basically it should pick a tasks number, run the timer and then timer reaches >= 1 pick another task. what i am missing with this?
Edit: firs image task runing, second image task still runing then it reaches 1, third image my BT
Is there a reason why AISense_Damage does not trigger a Successfully Sensed = false update event when its Max Age has expired? It works with Hearing sense. Does damage behave differently?
Talking about this event and struct
I also can't get the GetKnownPerceivedActors function to remember any actors that inflict damage. Hearing and sight seem to work fine.
The damage perception event is correctly registering my player pawn as the damage instigator. Damage sense lifespan has been set at different float values and also 0 (infinite)
So lifespan is infinite? Or are you just saying you tested different values
Sounds like you want to organize a decision layer of some kind. Can look into state tree, behavior trees, or utility ai. High level topics but could give you some ideas
I tested different values, both limited lifespan (5 seconds let's say) and infinite lifespan
bear in mind OnTargetPerceptionUpdated does not always fire when you think it should. I would maybe check if that's the issue here
Should I instead try using the TargetPerceptionInfoUpdated event? Haven't looked into that one yet. Would still be nice to know why the AI perception can't remember the instigator too, as that should be independent from these events?
I'm on 4.27, if that matters
yeah maybe try that one just in case
AI is probably the one system where that doesn't matter because not much has changed since
Im interested in using it in my project and wanted to know what other experiences with it were.
So I have this weird bug where either sight perception isn't working or traces are getting block, but only in the release build. Anyone have any ideas what could be doing that or have some good ideas on how to figure it out?
Are you using a c++ project by any chance? Maybe you can do a test build, you get some debug with it
it does have c++. When you say "test build" what do you have in mind? (sorry if that's a dumb question)
Thanks π
Thanks π
I will dive into some videos π
When you make a build, it can be:
- debug: all code is unoptmized so you can debug it fully (even the editor/engine)
- debug game: like above, but only for the games' code
- development: highly debugable but some code will be optimised
- test: most debug tools will not be available, code is optimised but you can still debug it (like in development)
- shipping: no debug tools, no debugable code
You could try and see if you bug happens only in shipping or if it happens in test too. If it happens in test, you can always check code and print logs (I think logs are still available in test)
Hey I'm kinda new to ai so this might not be the optimal way to do it but I have a task that randomly selects if my enemy is gonna retreat attack or stare at you when spotted, if I were to make the stare retreat and attack logic inside other tasks can I execute them based on the outcome ? Or should I try to do them inside the task(which might get a bit messy)?
changing this value to something else other than the default setting bugs the ai for some reason?
Tile Size UU
actually changing anything in the recastnavmesh makes the pathfinder become bugged out
Yeah, Iβd leave most of those settings alone. Only fixed tile pool size might be worth it if youβre getting tile gen errors
yeah but I need the max step height to be as high as the jump height so I can make the ai reach the destination quicker
really don't get why everything has to bug out for no reason....
so far the most effective solution is to remove the recast and rebuild the navmesh
after that I can freely change the max step height and stuff
baffling that epic hasn't done any fix for this
Are you changing them in the project settings or on the recast object generated?
the recast
We have them heavily tweaked. AI shouldn't bug out if movement component settings make sense with the generation settings
Yeah, bad idea. Because you change those settings in the recast, regenerate and they are gone. Try changing them on the project settings
What kind of bugs are you experiencing?
ai simply not moving anymore
what made me think it won't bug out is cause of how the setting for the debug objects is shared between the project settings and the recast
Then try that: change them in the project settings and double check your movement component settings make sense with what you are getting (so AI actually can move)
so I was thinking maybe changing the settings in the recast would also be changed in the project settings aswell
but now that I'm checking those settings in the project settings editor, they did not change
Why would you think that
No, the recast object in the scene is an instance created using the project setting
I see
Honestly, certain settings are accesible in the instance because... Reason XD
right...
But that doesn't mean they are intended to be changed in the instance
Yeah, I guess your team has more insight into what move comp settings work with what AI settings
Changing stuff in the blind just broke things for me π
There's a book that explains them (we have it) and then we had someone tweaking them one by one to see what actually happens
"insert surprised pikatchu"
Changing things blindly is somehow a default mode of development in unreal it seems
Well like you said, you had someone changing things one by one to see what happens π
Prly because thereβs no actual docs besides the source code
now that I think more about the settings...
would there be a possibility to have different ai's be able to pass through certain obstacles?
like, this ai is able to double jump so it can pass through taller obstacles while the other ai cannot so it needs to go around it
Yeah... Kinda. It would be a mix of nav agents, nav areas and smart nav links for the example you wrote
without nav links tho π
That's gonna be tricky, but doable. There's some info here in this long chat about that
But honestly, easier to create a BP of the obstacle and set some smart nav link components
hmm
Either that or... "welcome to the nith ring of hell: vaulting mechanics"
I myself was thinking more like having different navmeshes that have their own recast settings
It's not that bad, but it takes time to nail it down so it doesn't look uber buggy
this recast has its agent max step height to 200 and this recast has its agent max step height to 50
Yeah. That you handle with nav agents
but I suppose there's no option to make ai controllers use specific navmeshes?
And nav will be generated on top of objects etc. Gdc talks about death stranding AI are pretty good for that. Also horizon zero dawn talks
Nav agents + passing the querier qhe asking for the path. The engine will determine the right nav data based on the radius capsule. If that's too limiting, you can actually pass the nav data yourself
Careful with that because memory usage goes up, specially in big games
hmm
Imagine you need 10 different nav datas. If you generate all over the map, you get your nav x10
Ideally not all your levels will have all the nav areas. Unless you can have every enemy in every corner of the map, you only need nav data for the enemies you have
hmm, looks like its impossible to have more than two recasts tho
this takes away that idea
If you watch a HZ talk, you will see they handle big and small robots this way. They show a big rock split in too. Big guys go around, small guys go inbetween
Nope. You can have as many as you want
Nav agents in nav projects settings
no like
having two navmeshes with the same dimensions, same place
and attempting to duplicate the recast nav mesh does nothing
Can you explain more?
- you have 3 nav agents with different settings
- you place a nav volume that generates for all
Yeah, itβs not how it works
And you only get 2 out of 3?
You can't copy or manipulate the recast object
From this moment on you have homework: read how navigation generation works in unreal, there are tutorials and docs. Keep an eye on nav agents
You don't need more than one volume for what you want
I see
also I'll be busy for quite some time as I'm currently on my way to making the ai less broken when it jumps
Make a single NavMesh support multiple Recast Agents on the same map. Each one is fully customizable including Tile and Cell sizes and all the other Recast settings!
Optimize Your NavMesh Recast:
https://youtu.be/II5agHlxUe4
Follow Along:
00:00 - Intro
00:36 - See It In Action!
01:07 - Start It From Scratch
02:48 - Player Pawn's Agent Radius
0...
when it jumps, it leaves the navmesh and becomes confused as it does not know where it is
so it turns back
this place for example
here is where its scripted to double jump
and that moves the ai upwards alot more
if I would've moved that platform a bit further away, and the ai turns back
into the void it falls
That's what nav links are for. Not saying you can't handle islands and jumps in between any other way, but nav links will help you
An about turning back, makes sense because it thinks it can walk (there's nav), then the CMC says "oppps.... No floor mate!", and off it goes
my solution is a more complicated one that should guarantee a cleaner result without needing nav links π
Yeah, there are other good ways.
reason why I'm avoiding nav links is because they are required to be placed in specific areas, and it makes the ai go to the specific place that could allow it to pass through an obstacle
how to make the ai be less specific? more nav links
you see where this is going? π
oh! so having separate nav agents is actually that simple! nice π
I only needed to watch 2 minutes of that video
:))
Yeah, I get why you have the volumes. For me the problem is more in the lines of "I don't want to place a nav link because of what you just said, but also don't want to place a volume that will need to be adjusted when the level changes".
If I was in your position, I would do soemthing like a special navlin that has both, the nav link and a volume. The volume simply marks an area with a special flag "jumping". Post process the path, upon finding a nav link, find a point within that area in both sides of the nav link, replace the nav link start/end points with those. Then OnTakeNavlink do the jump stuff I need (animation or whatever). I would probably check other things when deciding for the entry/exit points within my jumping area, like other pawns present
But that still requires placing stuff on the level. That's why I like this idea
https://dev.epicgames.com/documentation/en-us/unreal-engine/automatic-navigation-link-generation
Learn how to automatically generate Navigation Links in Unreal Engine.
If the code of that feature allows to tweak the nav link class spawned, a way to mark in the asset and in the levels where to generate them, that's all you need
I do have my own nav link system which is more dynamic π
But haven't checked. If it also has a way to group them when generating (like the nav area, but for the group), that would be awesome
With a flag line that I could tweak what area they generate based on level conditions
Are those physics line traces?
just line traces
first its a multi line trace which will detect up to 2 surfaces
if it has detected only 1 surface, its an obstacle that can only be jumped over, if it hits 2 surfaces, the ai can also choose to go under it
but only if the space under the obstacle has a minimum space that fits the ai character
if its lower than the minimum specified space, that area will be skipped
and the ai will only jump over
after the multi line traces, single line traces will be fired from the ones that returned a hit under the obstacle
thats how it reads the space under the object
if one of the line traces has its start and end too close to each other, the space under the object would be too small for the ai to fit under
of course, this is just a prototype
I can already see the cons in this as what I have made is still incomplete
I'm also making sure the obstacle detector does not fire every frame
I'm using a Timer for it
Hey did a dev build and could see it still not work, so now I know the perception is not working on the sight class in the builds, but IS working in the editor... Any ideas why that would be the case?
No idea
I have 2 questions:
- how do you calculate a path in between islands? Are you able because of the image above, the volume allows for nav creation?
- when are you firing that trace thing? How do you calculate where/when to trigger it?
- yeah, I'm using a box collision that is set to block pawns, and then is set to overlapp all dynamic upon starting the simulation
- First it reads the ai's location, then it is multiplied by the forward vector, then offset the Z location by the max possible jump height, and if the hit location is higher than the max possible single jump, the Z spawn location is subtracted by a small number to correct it because of a restriction I put before double jumping.
And to make sure this works well with complex meshes, the line traces will start a couple cm towards the ai for a more accurate obstacle reading
the left side of my brain is smart, but my right side that does the talking is atrocious, sorry about that π
Sorry, I didn't make myself clear. What I mean: when you calculate a path, how do you know when and where do you need to calculate all those traces? Or do you run that logic constantly on every AI while it moves?
Yeah, there is a main box trace that is fired every .2 seconds
Once it detects an obstacle that can be jumped over or slid under, it then goes through a few loops
First two loops creating those rows of line traces
And storing the data in arrays
so I sort of figure it out... seems in the built version the AI don't see me as an enemy anymore and I had the perception set to only detect enemies... weird... any idea why that would be different in the build?
i think im overcomplicating this. basically what im making is the old school COD zombies barricade. zombies walk up to the barricade with 3 of them being positioned close enough to pull boards off, the rest wait behind them. the way i have it setup now is a barricade actor that has billboard components (lets call these positions) for positioning. these positions are either marked as zombie (position that pulls boards off the barricade) or wait (waiting for a zombie to die at the barricade so it can move to that position). when the zombie spawns it gets set a target barricade which in turn links the zombie to one of the positions. when it is linked a position the position is considered used and no other zombie can use it. so if 4 zombies spawn, the first 3 will go to one of the zombie positions (the top 3 in the picture), the rest will go to one of the bottom ones and wait. when one of the zombies in the zombie positions dies, it broadcasts a change which all zombies targeting this barricade are bound to which will perform a check. if the zombie is in a waiting position, it will move to that newly opened zombie position (its kind of first come first serve). once all the boards are broken off, all the zombies go to the root of the barricade, once reached they will perform a vault montage (root motion) to enter the play area.
this works but has its own set of issues such as sometimes a zombie may get turned around so when it goes to vault, it vaults away from the window instead of through it. likewise each zombie kind of bunches up when its time to go through the window, im not sure on a good approach to make them kind of go in an orderly fashion (one after the other cleanly). im fairly new to ai, im not using behavior tree or state tree for this since the actual zombie logic once they get into the level is dirt simple. everything movement is done with AIMoveTo
Sounds kind of like a smart object setup to an extent. Either way, this is kind of common. Sounds like you just need to build a queue. So when they claim a spot, they get put into the queue. Then whoever is next, you just grab it from the queue and when they get to the window, they check what they should be doing. Climbing or removing a board.
So, they all don't get to go at once.
question about behavior trees: when you have a selector with 2 children, for example, the child on the left performing a task and the child on the right having a decorator that "Aborts Both" when the condition is satisfied. If the one in the left keeps returning true, when will it actually be interrupted by the one in the right? Because it seems that even the condition in the decorator should return true, that decorator isn't even evaluated.
After asking Chat GPT, it said that something needs to trigger a re-evaluation of that decorator so it can abort the higher priorty (the one in the left). And a re-evaluation is triggered by whether the blackboard in the decorator changes its value? Is that the only way to get the tree to evaluate that decorator? What other ways are there to do so?
didnt remember smart objects, i remember hearing about them quite awhile back but forgot. ill check that one out thank you!
Hello,
I want to make a combat system where the Ai reacts to their opponents hit direction. So if the player hits left then it blocks in that direction. If they attack left but a bit lower, the blendspace would blend according to that. My problems are:
How do I dynamically pass the changing hit direction to the enemy when the player moves their camera, strafes, jumps, gets knocked back, whatever would change the angle of attack so that the Ai could react dynamically during the swing of the sword? I have method of tracing the sword but it doesnt predict the future swords path, which I'm not sure if would be necessary or even a good solution.
How do I implement a blendspace that could blend according to the dynamically changing vector?
Even if you don't have a solution, advice would be helpful, thanks.
Not saying you should use UE's smart object stuff, but the concept itself (been around since The Sims - maybe earlier)
right, it just sounds like a good solution for this specific use case
Can someone please help me, I feel like I'm losing my mind. I remember pretty well that some time ago I managed to visualize the path my AI was following with some balls on the ground linked by a line. Nothing crazy, but very useful, however now I cannot manage to visualize it again. Can't find anything like this on the internet neither. Did I dream about this or is it just pretty hidden?
i have some questions about AI controller and behavior trees, so i have 3 different spiders who are child of main AI actor, can i reuse same AI controller and behavior tree for them? or do i need give separate AI controllers to all of them? my all AI logic was in AI actor and its controller, but want to get to behavior trees and bit expand my knowledge.
Bot start at point A goes to point B. I start immediately start looking for new path when at B. There is significant delay before bot start moving again.
Is there some log or sth, which show how long is pathfinding taking ?