#gameplay-ai
1 messages · Page 39 of 1
I would stay away from threads. You can just make use of ticking if you need to run something like that
Is there not some sought of C++ only TQueue type?
How do I define a AIController pointer property so I can bind it as an input in the State Tree asset file?
This is how it looks at the moment.
Just wrapping my head around this - do you mean something like this?
Are you running this state tree in an AI controller or somewhere else?
Something like that, but you don't really need to tick to do this. Let's say that this is a component on an actor, you would just set it up so that your input actions call a function on this component when it needs to abort. Similarly, once a task has been started, you don't need to keep telling it to continue
I've been messing about in state trees, and man I want them to work so badly but I just can't get them fully functional
This is in the state tree asset.
This is how my blueprint task looks.
I am trying to move it into C++.
Yes the point is that if you're running this in an AI controller, then your Context actor would be the AI controller
I even looked at the generate header preview to make sure my specifies were right. That did not help.
Why can I not get the correct UI to come up when binding inputs?
Ahh that's what you meant
Sorry.
try this
UPROPERTY(EditAnywhere, Category=Input)
AActor* Whatever;
also this needs to be in the InstanceData, not as a property on the task itself
InstanceData?
A separate struct used to store instance-specific data like this. The builtin ones should have examples on how it can be defined
Cool. I found how the Delay task is done.
Sorry, trying to wrap my head around this (I am newbish). What kind of component would I put on my actor that would allow for this semi-autonomous flow?
I see how easy it is in Blueprint.
A custom Actor Component would probably be the way to go
What does the Hidden specifier do?
I was just looking through some of the State Tree source code and found this.
I'd imagine it prevents the struct from showing up in some lists
Probably.
It's interesting that you can define all properties inside a blueprint task. I wonder how this works under the hood?
is there a way of saving a BT as a .png? so you can reference a previous version easily if you break it :x
There's a BlueprintBase or something like that for the state tree tasks, that probably handles it
Good question. Why not just duplicate the asset?
Or use blueprint pastebin.
It has a version history system.
It's weird how you need to put public for inheritance for structs.
it's just how inheritance in C++ works... if it wasn't public then methods on them would become protected or private and potentially break stuff
Is this what you mean?
Pretty much
ok, thanks - took me a bit to understand. The advantage here is that I gain a bit of modularity and can cancel the current task without having an on tick 'interrupting key pressed?' bool?
Yeah.. in general in UE you don't need to poll for inputs
you get events and then you can react to those events
is there a way to disable an AIStimulusSource during runtime so AI Perceptions wont sense it?
hey guys, i have an issue with a Service node of my Behavior tree
i need a Service, which must force an AI-controlled pawn immediately drop a right branch (moving to waypoint) when they see an enemy, and go to that enemy to attack it
i have a Perception logic in a AIController, so i need just force a pawn to follow it
what do i need inside of a Service then?
@crystal hatch I can't DM you, think the server default settings changed
I sent Daniel a couple more engine bugs, one with a fix included, but I don't think he checks Discord
If its not too much trouble could you ask him to check his DMs 🙂
I thought I understood the NavModifierComponent, but apparently not. It works as expected with the doors, but with a different static mesh, it doesn't do anything 😭
Yes. There is a function in the perception system.
Trying to use it, because a crane is supposed to move a shipping container that is in the play area and then it gets moved to an area to form a "bridge" pretty much. I want to dirty the tile where it sits originally, so it becomes an open path and then dirty the area where it forms the bridge so that AI can cross it as well.
You can't generate new nav mesh using modifiers only. In fact, putting a nav modifier component on it, will stop navigation from being built on it at all.
😭
What you can do is the opposite. So build the nav mesh with it in the "bridge" position. When the game starts, move it to the starting position and add a nav modifier to where the end position is (to cut out that bridge nav mesh). Then when you move it back to the end position, disable the modifier.
Nice idea. Thanks!
You're welcome. We do it a lot of the time for different things.
Figured out something about the nav modifier component with this mesh. It seems it's not finding the bounds of the static mesh correctly?
And for w/e reason, for this one, I needed the static mesh component to be able to affect the navigation - but for the doors, I don't.
And the nav modifier component even seems to have a check to see if the root component has that option checked or not, and it shouldn't matter 🤔
What's the difference between nav walking and regular walking in the character movement component? When should I be using the nav walking rather than the regular one?
Weird. Collision issue maybe?
nav walking is cheaper but less precise, prly best to use it when you have perf issues stemmed from nav https://forums.unrealengine.com/t/how-to-use-navmesh-walking/310732
It's supposed to be using the collision of the object, but the collision shape looks fine 😭
If you add a box collision to it, does it change the shape the navmesh takes around it?
Didn't try that because I didn't want to wrestle with it at the time.
Oh, well if it does what you want it to then yeah it’s moot
Walking = PhysWalking (It raycasts the floor and move the character to the hit impact + sweep when moving)
NavWalking = It relies on the navmesh (it tries to find the best location within the Navigation Data. if you don't have any navigation data, it won't work)
Generally you use Walking for your Players
And NavWalking for your AIs
Except if your players' pawns move thanks to a path
🤔
I tried using nav walking in my project for AIs and it was pretty janky
but it would probably be worthwhile to look into because regular walking is fairly performance consuming thanks to CMC being CMC
I've always used nav walking for my AI to be honest
I personally have noted that using nav walking doesn't allow AI to slide along some round collision. So if one AI character walks into another, it'll stuck there. That doesn't include any crowd avoidance or RVO obviously
There is some if you enable it
What exactly? I have tried to search for properties in the CMC, but didn't find anything
Using the ADetourCrowdAIController
https://docs.unrealengine.com/5.0/en-US/using-avoidance-with-the-navigation-system-in-unreal-engine/
There is also another solution
Both are explained here ☝️
That doesn't include any crowd avoidance or RVO obviously
You may have missed this part
Does anyone know why sometimes changing navigation mesh tile size, does absolutely nothing?
Yeah i didn't get it ^^'
Hi.
I Have a question that i would need to discuss with someone familiar with AI and AI behaviours or maybe even training AI via ML. I have a car game, but the NPC/AI should be able to move like frearoam on an open maop terraint, not after a path or a spline.
I would highly appreaciate if someone with infor or ideas, or knowledge of great videos/tutorials could give ´me some help here.
Tag me with your answer thnx in advance // Philip
There's a bunch of vids on YT if you look up machine learning car ai or something like that. I think game ai pro also has some sections on racing games, they are free on the game ai pro website
In general I think this is fairly complex for an open world'ish thing. A spline based approach would probably be a lot simpler to implement - they don't have to stick to the spline, but rather just use the spline as a "guide" towards which they steer. This would allow them to deviate from the spline if necessary, but make it so they don't really have to understand what's happening when moving normally
What are AI messages used for?
Hi guys this should be pretty simple but I am not sure how to go about it.
Basically, I have a 90-degree left and right turn for my boss character, currently, they are set to rotate to their new target destination before moving.
How can I set up a way to determine if it is a left or right turn and have it play the correct animation during the rotate to BB entry function?
That’s up to you, isn’t it?
?
What determines whether he should turn right or left?
Also try not to cross-post, it’s against #rules
Thats what I mean I dunno how to define that information to use as a variable.
I guess I would have to maybe do something with a Dot product times it by 360 and use that somehow to determine left and right but again I would be just guessing kinda
I will note that for the future just thought this channel might be particularly quiet
I mean maybe EQS with dot product but my point was why does he need to turn into a specific direction?
So when he rotates he isn't skating and actually turns I will show you the animations
If you look at the previous clip he is just playing his idle animation when rotating without any foot movement
It doesn't need to be perfect like with IK's or anything as long as it plays left or right turn to match the rotation roughly
I just need a way to get if it is a right or a left basically I can figure the rest out with triggering bools, states etc. Just unsure how to know which way he is turning
Ok, so this isn’t about determining whether he should go left or right but more like deciding which #animation to use depending on the turn he is making
Pretty much yeah but it's not the animation I am struggling with I just need a number I can use a greater or less than node on to plug into a branch to determine which turn animation to play
Yeah, I get you
Normally you’d prly use one walking animation but if he needs to lean over or something, then you’d prly need to do something like subtracting the current rotation from the target rotation, and pick the animation depending on the result. For example, if the result is positive, then it’s right and if it’s negative it’s left. This would require some testing and there might be better solutions out there but that’s where I’d start
I tried that but I am pretty sure I had the sequence messed up a little i will try this again with a dot product and using greater or less than 0.5 should determine left or right I think if I make a dot product out of the forward vector Z axis maybe
AI messages are for the BT to wait for a message. It's not really used much, because it's based on FNames.
You determine the direction by using a dot product of the direction to the target and the AI character's right vector.
Yeah, that is indeed much cleaner 😅
If IGenericTeamInterface is not useable in blueprint, what's it's use?
It’s usable
Just needs like 5 mins of work in cpp to expose it
why is this node running while it's returning false?
nevermind, fixed it
What was it?
the issue was the decorator, I had sloppy code
for the IF statement, still not sure what to do, but I kept both
the Service runs all the time? in AI
Yeah service is for things you want to run continuously, usually
Deal, thanks
Is there a way to abort a simple move to before its complete
You can call stop movement
Random aside here, but I also find services really useful for handling scope - you can use activate/deactivate events to add/remove state, etc
Means that whenever the node it's attached to deactivates you can get an opportunity to clean stuff up
I just do them from dispatchers
For now
But I've got another thing
I'm doing this, but if the pathfinder from the EQS fails. I want it to skip the MoveTo or do another EQS instead.
Not sure on how to do that tbh
I'm quite new to AI and EQS stuff
I have this but always always returns false
I would recommend the 4th pin if you haven’t checked it out already
The RunEQS?
Does anyone know if the default Team attitude solver resolves team 255 as neutral for all? I was under the impression it should but when I assign agents to team 255 they still show up as hostiles for other teams
4th pinned link in this channel
In this presentation, Epic's Paulo Souza uses Unreal Engine's built-in AI features to build smart enemy behaviors for a game with stealth-like mechanics.
By relying on the Gameplay Framework in Unreal, we're able to quickly create convincing AI using Behavior Trees. Behavior Trees are great for creating complex AI that can be presented in a way...
Does DetourCrowdAIController not interface with regular "dumb" AIController?
I'm moving my pawns along spline points.
I want the "regular" pawn to always go linearly between the spline points and NOT go around other pawns
I want the "smart" pawn (which is a bit faster than the "dumb" ones) to go around the other pawns.
I setup the dumb ones using default AIController and the "smart" ones using DetourCrowdAIController but nothing really happens - instead of avoiding the slower pawn, the "smart" pawn just gets its velocity lowered and follows in the same line.
Any tips/ideas?
https://forums.unrealengine.com/t/how-to-use-eqs-to-check-if-path-to-target-exists-is-valid/508900/2
this helped to detect if the pathfind fails
while the video taught me something new about failing a node and such, thank you!
Hi! First of all, EQS tend to be expensive. I would approach your problem by actually creating a custom Behavior Tree node that checks whether there’s a path from actor to actor. Something like this (the node checks if Find Paths return a partial path; in that case, it means there’s no full path between the two actors, and so it returns false):...
That advice is terrible. The EQS is time sliced, so it's not really that expensive. Also the does path exist EQS test is considerably cheaper than Find Path. If the EQS has many points that are valid and it keeps returning one that isn't, because it's the highest score, your AI won't move.
Hi.
I Have a question that i would need to discuss with someone familiar with AI and AI behaviours or maybe even training AI via ML. I have a car game, but the NPC/AI should be able to move like frearoam on an open maop terraint, not after a path or a spline.
I would highly appreaciate if someone with infor or ideas, or knowledge of great videos/tutorials could give ´me some help here.
Tag me with your answer thnx in advance // Philip
Pretty sure someone already replied to you on this yesterday ?
Hey guys, how can I ensure that my ranged AI can see my player before they attack? My AI decides whether to chase down the target with melee attacks or long ranged attacks depending on the distance from player to AI. However, if I hide behind a wall the AI will just stand there shooting at my location. Any tips? 🙂
Is your wall blocking visibility ?
Yeah
Are you using EQS for this yet?
Sounds more like a perception issue rather than EQS
If you are using perception, you will get a perception event with successfully sensed set to false when sight is lost
Yeah but I mean if it’s a half wall or something and it needs to go around
But yeah you’re right about the perception
Yeah depends on how it should work I guess, easy start would just to have the AI pathfind normally towards the player's position
Hmm really, can't see it ?
Oh yeah, well I wanted to find someone to talk to about this stuff that's why I posted again
Tbh unless you get really lucky you might be hard pressed to find someone
It's a complex and kinda niche topic, but who knows :)
Use the has line of sight function on the AI controller.
Huh, there's a function like that in the AI controller? :P
Why do you think you need GOAP? What does it give you? What is the difference between GOAP and a BT? If you don't know the answers to this, you need to do more research.
Cant find that function 🤔
Does it maybe not inherit from the Detour crowd AI controller?
I think the one she's referring to is LineOfSightTo
Ooooh
(but if you're using perception you probably can do it in a different way)
yeah, would hope so 🤔 Im using both vision and hearing though
Right, in that case you want to check what I mentioned above
You should be getting a stimulus event from perception for sight when line of sight is lost
I can just have the AI move to a closer location after attacking though, that could work 🤔
If the NPC is still shooting at the wall and they are using perception to pick a target, then the problem isn't with perception.
It could be just a mistake in how the perception is being handled, it's kinda tricky to understand how it all works at first so those are pretty common problems with it
Well, I can have the AI run one montage of the ranged attack and then move to a closer location based on their previous location, that would force the AI to change locations 🤔
Yeah I noticed the problem as I was testing. And I couldn't find the Does Path Exist.
What kind of complex and dynamic behavior are you actually looking for?
Like, have the AI choose a point to move to between their last moveto position and towards their perception target
It's not failproof, but could give the impression that it's tactically moving about
The EQS batch pathfinding test. Set it to filter only.
“coding to generate emergent behaviour” sounds a bit contradictory
Why are you trying to work around just finding a location that has line of sight to the target?
I have added the batch one, but what is the difference?? should I replace the first one with the match?? how will I get the Bool if a single path is valid or not?
Well, not quite sure how to do that 😅 I'll check out some vids on the LineTrace function you mentioned
The batch one is cheaper.
ok, how can I return if a pathfind is valid or not?
like I want the actor to make another EQS for another location for example
The EQS does it for you. It filters out any locations that are unreachable. If no points are reachable, the Run EQS task will fail.
and the rest of the sequence will not run
You can put another generator to the right and it will be run if the first one fails. Or you can use how the BT functions to do a fall back behavior
doing something like this
That can be done in a BT. I'd use Utility before GOAP for that, but it can also be done in a BT.
In your case, because the sequence is the same, I'd set up a 2nd generator in the EQS.
second generator?
like 2 of em in the same EQS?
ohh okay
didn't know we can do that
You can set up a multiple generators in an EQS. It will do them left to right until one has a valid item.
thank you
and the percieved actor will check all actors currently in the actor's sight?? not age
is there any way to set the default values of keys in a blackboard 🤔 ...
as far as i can see there is none...
its sometimes annoying to set the key default value right after running the behaviour tree...
I think you just have to set them f.ex. in your AI controller's BeginPlay before you start the behavior tree
Starting the BT should not happen in begin play, it should be on possess.
Anyone knows why I keep getting these message on client (client side allow navigation is OFF):
LogNavigation: Warning: ConstructTiledNavMesh: Failed to create navmesh of size 0.
(UE5.1)
BTs separate out the decisions from the actions. They aren't bad at making decisions, but you also don't need to put the decisions in the tree. BTs are a priority order set of actions. Sometimes that's great for what game you are making and sometimes it's not.
You can't really pick the right architecture without fully understanding the options. I will reiterate that you should do more research on how they work. Not research on what other people think you should use.
There's a lot of really bad advice out there, mostly from people who don't understand the different options. Especially with "GOAP is better" or more advanced or whatever. Planners (arguably HTNs are better than GOAP perf wise) have pros and cons just like BTs do.
Do we have any resources on other AI systems (other than BT and mass) within Unreal? I didn’t really see anything in pinned except for general AI concepts
Game AI Pro has good articles on different systems. HTN, Utility and hybrids. While there is an unfinished HTN in UE and some mediocre plug-ins for others, it's completely unknown if they will add more than the BT and State Tree.
Ah fair enough thx
There is still a lot of misunderstanding between State Machines and BTs. Good luck demystifying the other AI architectures 😅
Yeah, I mean until recently I hadn’t touched animation at all, now I realize SMs are animation related ?
Doesn't help that most tutorials treat the BT like a bad FSM.
They can be. But you also have logic state machines.
Ah I c
The CMC is also a state machine
You can have a state machine for pretty much anything
I always write my BTs as more like a behavior priority selector pretty much
"What is the most important thing for this AI to do". And then work down from there
2nd most, 3rd most, etc...
Seems reasonable
Is it necessary to inherit BTService node memory from FBTAuxiliaryMemory? I've just realized that I never did although it seems BTComponent actually somewhat relies on the fields of that structure 🤔
In case anyone else will encounter it - fixed by setting auto destroy when no navigation data in project settings
(LogNavigation: Warning: ConstructTiledNavMesh: Failed to create navmesh of size 0.)
Ah yes, navmesh walking
I decided to try it in my project and immediately get mysterious issues such as the npc no longer appears to trigger overlaps
wonder why it would be affecting that...
Generate overlaps is enabled on capsule... it starts working if I also enable overlaps on the skeletal mesh, which seems a bit weird
What about perf gains?
Hard to say. Will need to test some more
I was doing quick testing in PIE spawning 20 mannys who just run towards you and hitting like 30 fps drops as soon as they were spawned, I don't think changing it to navmesh walking had much of an impact
Lawlster mentioned the CMC itself comes with big perf hit
It does yeah
I would maybe run stat game and other #profiling tools to determine exactly what’s causing the drop, may be entirely unrelated to nav
Yeah I was using unreal insights but it was not being very insightful
mostly claiming that slate was taking majority of the render time (eg. the UE editor itself)
messing around with something that might need to spawn quite many characters so want to just see whether it's going to perform properly and where the issues are going to be, but will need to test some more later
does anyone know how to access State Tree parameters from Task in code ? (or any other node), without using bindings.
in most shipped projects ive worked on I end up in a very hybrid type of place..
I usually end up with a set of high level behaviors in a priority order, that are "tested" to see if I meet the conditions to do the sequence of events each chunky high level behavior represents.. These can also be nested so that a single high level behavior can be broken down to smaller, but still chunky components
Typically a behavior tree runs these sequence of events/tasks, but the gating condtionals tend to vary per game ive worked on.. Sometimes its all done in a single behavior tree, sometimes its a set of functions that then runs smaller behavior trees, etc..
So like at a high level it looks pretty HTN-y as we select behavior but then when we find out what to do, it processes all the tasks and actions with a behavior tree.
State machines come into play to manage character state.. this is usually either the same SM or a tightly coupled SM with the animation state, though I have used them to drive AI decisions as well..
The above is engine agnostic explanation.. in 16 years i never have shipped an unreal game haha but in engines i've used (mostly internal tech) its how i've gone about it
AI perf only really gets bad due to counts and external systems not having good codepaths for AI to make efficient calls to ime
the actual decision logic is pretty quick typically in comparison
IME?
in my experience
Oh ok I thought it was some system 😅
i always did it in the begin play :/
looks like from now on I'll have to do it in onpossess
yeah i am doing all those default value stuff in controller, right after running the BT
Most of my shipped games have been a similar system, but using a Utility/BT hybrid.
Yeah, especially if you have a lot of variants.
You can run into situations when begin play is called before the controller has been possessed by a pawn.
well and also its easier to hand designers a big block of "this is behavior that does x" than "here are the little bits and peices for you to make behavior"
ive never met a designer that wants to futz with the behavior tree haha
how can we learn other AI systems like HTN and GOAP etc, as for behaviour tree and FSM we can use them in unreal and unity. So do we have to create these on our own or is there another way? as for HTN i think there is a plugin by unreal engine, but never used it
I have, but it never goes well.
i never came into such situation, i think thats why i always used it in begin play...
from now on will run it in onpossessed
thank you for this
There are articles in AI Game Pro that you can read for free.
will look into it...
but about the practical part, looks like i have to create a simpler system like it 🤔
nothing wrong with creating a simple mostly naive implementation of some of these patterns to get the feel of how they would fit into your game if you have the time/bandwidth to do so
well time is a big problem here 😅
as because of this i never got a change to try the state tree
The marketplace HTN plugin looks might nice to be honest. Always had my eye on it. Just, haven't needed it just yet 😅
i got to know about this plugin by bigfry, as they are using it in their game Transience...
from that day its in my cart😅
Well that's certainly interesting... poking around the state tree thing and turns out at least witht the state tree component...
- if you use
GetExternalDataand your handle is to a pawn, it pulls the component's pawn - similarly if the handle is to an AI controller, it pulls the component's controller
- if your handle is to a component, it pulls the component from the owner
- if it's a world subsystem, it pulls the world subsystem from the world
- if it's some other actor type it just assumes you want the pawn
imagine if this was documented somewhere beyond just "if you want external data use Get External Data" which never made any sense because how would it know what data you actually wanted... well turns out it just gets set by the state tree component
External data is anything that matches class of handle and is defined in Schema - GetContextDataDescs(), and is initialized from that schema
for more details need to compile full debug and go in. That is from what I tested so far. It seems like it doesn't care about any specific types. It will just grab whatever is closest match
within hierarchy of classes
What's I dont understand is how parameters work..
and Why I can't bind properties within the same task -;-
external data is anything that is set into the state tree by something else, really
because if you ask for a game instance subsystem or something, you'll get nothing because there's no code to populate that into it
in case of StateTreeComponent, the code for populating it is in SetContextRequirements
I've not looked at parameters much tbh, I see there's a field to fill them in if you look at the details of the state tree component but that's about as far as I bothered with them :D
SetContextRequirements
Yeah handles wont really work correctly if don't set it from schema in some way ; d
I tried to convert State Tree into "utility selector" and it honestly kind of works, without even modifying engine code
Wall I hit is how to create "results" for each actor. I have it working, but UX for it sucks hard 😄
it would be so much easier If I cloud bind inputs/outputs within the same task
or would be able to write into some global parameter from task and read it from other bound property
I'm currently attempting to create a state tree task in C++ that would allow me to use AITask_MoveTo or something similar but I'm not quite sure how exactly you're supposed to bind a delegate to the task 🤔
I have it in blueprints but I've noticed with sufficiently many AI's using the task it consumes 1/4th of the entire frame to run them so wanted to see if moving it into C++ would make it perform a bit better
assuming you are using the default component for State Tree, you can just store delegates inside instance data, it should survive for duration of tree execution.
Yeah the problem is more on the side of how do you have the delegate tell the task to finish, or how do you bind to a dynamic delegate to begin with because you can't have UFUNCTIONs in a USTRUCT
what conditions need to be true for AI MoveTo to work? I know for a fact that the node is begin called, I created a navmesh bounds volume and pressed P, the character is set to AIController, but it is just not moving
is there something I'm missing?
I would look in visual logger as navigation logs more output into it
Various reasons for it, like trying to move somewhere invalid, or missing a suitable movement component, etc.
by visual logger you mean the visual studio output?
oh I'll take a look
thanks
turns out I was forgetting something, I just had to call SpawnDefaultControlelr at BeginPlay
@misty wharf
Yeah it's often something simple like that lol
By the way if anyone's curious about statetree performance BP vs C++ - I had two state tree tasks running on about 60 AIs, getting called pretty often. BP version: 10ms / C++ version: 171us
profiled with Unreal Insights
Ah ok. In that case... I see only option, which is to rewrite that entire task in C++. It's mostly wrapper around exposing it to blueprint anyway ;
Yeah. I looked at some of the builtins, seems the intended way is to just tick the task
I ended up implementing it like this:
EStateTreeRunStatus FShSTT_MoveTo::EnterState(FStateTreeExecutionContext& Context, const FStateTreeTransitionResult& Transition) const
{
const FInstanceDataType& InstanceData = Context.GetInstanceData(*this);
if(!IsValid(InstanceData.TargetActor))
{
//Target is not valid, can't move to it
return EStateTreeRunStatus::Failed;
}
AAIController& Controller = Context.GetExternalData(ControllerHandle);
Controller.MoveToActor(InstanceData.TargetActor, InstanceData.AcceptanceRadius);
return EStateTreeRunStatus::Running;
}
EStateTreeRunStatus FShSTT_MoveTo::Tick(FStateTreeExecutionContext& Context, const float DeltaTime) const
{
const AAIController& Controller = Context.GetExternalData(ControllerHandle);
bool Moving = Controller.GetMoveStatus() == EPathFollowingStatus::Moving;
return Moving ? EStateTreeRunStatus::Running : EStateTreeRunStatus::Succeeded;
}
yeah, seems about right.
Other thing I learned is that Global Tasks/Evaluator are run on tree start until tree runs out of them. Then If you want to run states, you need to tick tree.
And if any of the global tasks return other tree status than Running.. You need to start tree again ;
Yeah it's a pretty big gotcha that if your global task returns something else than Running the entire tree just stops
Imagine if documentation existed
lol
no way. None read it.
Ok I tried, and only learned basic how it work in editor 😄
Yeah at least there's a little bit of something
if I want agents using the nav mesh to be able to walk off all ledges anywhere on my map regardless of height is there a simpler way to do that then adding nav link proxies all over the place? I want my agents to be able to chase a player. When I do use nav link proxies they also seem to slow down and sort of stutter a bit at the top of the ledge before jumping so they are unable to keep up with a human player.
@crystal sequoia you can do a task that detects if there is any walkable area at a certain distance or height and jump off to there regardless of nav mesh
makes sense, thanks
If I use nav mesh invokers en I don't need nav mesh bounds any more?
Did you ever figure out what caused this? I just ran into it on a task that had no instance data and seems adding instance data fixed it 🤔 Seems kinda weird that it would force you to have instance data even if you're not using it
(No - I didn't ever figure out what caused it, lol)
lol yep saw that message also
I guess it just really wants you to have instance data even if it's empty
How are the Supported Nav Agents supposed to work?
It seems like its only available as part of a NavMesh, but I cant find where you classify a Pawn or AIController as belonging to a particular Agent type?
My AI character is setup to possess automatically, however on OpenLevel or RestartLevel, the AI never possess. Any ideas why?
Should be project settings -> nav -> agents
Sry I realized I misread
I should have clarified, that is what I can find. But how does it relate to a specific Pawn.
It has to do with the nav agent radius afaik
Which you can change on the CMC
Might be on the floating pawn component too, idk
Thats a really weird choice
You would think it was an explicit decision by developers to which agent settings a pawn or the like belongs to.
Yeah, from what I’m reading, the movement component agent settings are as precise as it gets
The navigation system finds the best fit nav data for the agent properties. It actually makes more sense when you consider games with NPCs of various sizes, but using buckets for nav data. Because of the memory cost, you really don't want more than a handful of nav meshes.
Ugh found yet another fun state tree gotcha
if you use GetExternalData and it so happens that the thing you asked for isn't available... it just silently does absolutely nothing. No log info, nothing. Good luck figuring that out if you weren't paying attention to the one line of comments somewhere inside UE's source code that says the state tree won't run if the data isn't there
Thought I'd share, skinned skelmesh from Luma.ai text to 3D model (I had a mess last night and this morning)
Thats the luma model, before I import it into accurig for automated rigging
clearly you'd retopo first.. but hey, works alright
What's the most efficient way to make an AI Controller follow a road / path / route? Someone suggested lots of target points that you 'walk to' but that seems archaic to me. Is there some sort of Spline system you can setup that you can reference in a 'move to' or 'follow' command?
There is zone graph but let me verify if that's not only available for Mass
https://dev.epicgames.com/community/learning/tutorials/qz6r/unreal-engine-zonegraph-quick-start-guide @paper sparrow
Seems to be only for Mass tho 😔
You would need to use Mass and awake/asleep your AI to move from road to any other behavior
Cool feature! No worries, I'm not using mass, I was hoping for maybe something simpler, like a spline template with a 'AI Follow Spline' command or something
I don't think it should be too hard to implement something where you dynamically adjust the point you're steering towards
Eg. you set up a spline which is your path, and then your actor picks a point slightly ahead of it on the spline to steer towards
and you just keep updating that
Not a bad idea actually, yeah could do that, just wondering if there was anything already built-in
Hi all,
Once I've Called UEnvQueryManager::RunEQSQuery, am I able to cache and reuse the same return UEnvQueryInstanceBlueprintWrapper object ptr to call RunQuery again to avoid frequent creation of the UEnvQueryInstanceBlueprintWrapper obj? Or does some sort of de-registration happen at the end of the EQS query?
Nevermind, I can literally just bypass all of that and call FEnvQueryRequest::Execute and pass in the callback obj + OnFinished function to call bypassing the need for the wrapper at all, just noticed in my ill state that it's a blueprint wrapper - brain is clearly having a go slow day!
Hello I am looking for advice.
I am making enemy and minion ai. I got them to attack each other no problem. I created a token system so they can only attack so often.
Where I am confused is how to program how a fight between say 4 enemy slimes and 4 minions should work.
Currently I get closest targets, if he has an attack token available reserve It and attack. But each slime will just get closest and do that. A lot of times they will stand around because they are targeting same opponent. How can I go about getting different opponents? Any suggestions?
Maybe you can have some system in place that gives a list of alternative targets if the desired target is unavailable? Or just have a list of available targets and pick from there (eg targets with tokens)
Yea I was thinking of checking all targets with tokens and choose one with a free token, but then not sure if the AI would just change targets Everytime someone else took their target over and over. I feel like there needs to be some sort of threat or prioritizing or something somehow
Hello. Stupid question. Shouldn't Rotate to face BB entry be able to take any BB objects?
Not all objects have representation in the world. Click the dropdown and choose a specific type of Object. Like Actor.
I'd imagine the key has a restriction to Actors or vectors.
Yep that was it.
Thanks.
when i use this, it never succeeds, how do i "succeed" it? do i need to put something in the gameplay behavior?
If your gameplay behavior immediately returns iirc it won't actually acknowledge it
so your gameplay behavior needs to at least wait until the next tick before finishing, or you need to write a custom version where it works correctly
but, what node do i put in the gameplay behavior to finish it? i dont see anything like execute finished for example :X
Isn't there End Behavior or something?
UFUNCTION(BlueprintCallable, Category = GameplayBehavior, meta = (DisplayName = "EndBehavior"))
void K2_EndBehavior(AActor* Avatar);
at least the code suggests this exists
yes! i will try, thanks 😄 totally missed it
There are splines that you can use.
Oh really? What are they called?
If you use C++, you can write your own EQS tests to prioritize your targets in any way that you want. Including threat and token availability.
Spline component
Oh yeah I know about the spline component, I was wondering if there was an AI-specific variant or function you could use to make an AI actor follow a spline path nicely
Not built in, but it's easy to do.
The best thing I can think of is what 'zomg' recommended, continiously take the next point infront of the actor and move there
Ok, if that's the best way to do it then all good, just checking in if there' an alterative way
mmm it still does not succeed if i put the endbehavior in the behavior, i set a breakpoint to trap it if it does succeed and it never happens :/
You get the next point when the AI gets to the current point, turn on use acceleration for paths in the movement component and adjust the deceleration speed to smooth out the movement.
Really helpful! Thanks Luthage ❤️
You're welcome.
hey, how would i go about improving the performance for large number (300-500) of Ai agents from the CMC?
RIP
I cannot afford to create my own cmc as the game is multiplayer
That's even more reason to make your own CMC honestly
You're going to need to do a lot of optimizations
oh, is my only option to make my own?
i'd be fine with less accuracy, cmc doesn't seem to have that option tho
Navmesh walking movement mode helps some
yeah emphasis on 'some'
Ik you said it’s late in your development but it still sounds like #mass might be the right way
Tho I’ve heard of people faking stuff with HISMs, if you can afford to do that in your use case
Btw my comment about people saying make your own CMC was before you said you’re gonna have 500x of them 😅
oh wait that mode, despite having not showed much difference earlier in my development, did just now show quite a bit
brought me down from 50ms to 20ms from the CMC
i'm not aiming for 144fps w/ 500 AI, just "Playable lag", ie 15-25fps
What an odd target FPS. But you do you
I would also do some profiling to see exactly what else is slowing you down, it’s not always just the CMC
Animations are costly as well
well that screenshot is right from profiling :P
surprsingly, they're not very high up in the list
compared to cmc and some of my code
Mb my discord’s been acting up not loading screenshots until I restart the app,
motherfucker
imagine your hud taking your entire 60fps frame budget 🤣
The real reason games like to go hudless, lol
How many canvas' do you have merpl
one per each part of each widget, eg
Canvas can be costly
id rather make my own cmc than optimize ui 😭
What is one of the most fundamental pieces of any project? If you guessed UI, you’d be right! Even though it’s a necessary step there are a lot of questions around some of the best ways to create and implement it, so this week we’ll be discussing with our own technical writer Michael Prinke some of the best tips and tricks, do’s and don’ts, and ...
tldr; replace canvas with overlay
thanks will do
but canvas' will absolutely shred performance
also the rest of common ui is pog as well, saves a bunch of time not that hard 2 learn
It's so common, they made it a plugin instead of base.
i wish i'd come across it 10 months earlier into development lmao
yeah lol the curse of too many things in unreal 🤣
I still haven't really bothered with common ui
Ik very little about #umg but I did read Cade’s blog about Canvas being absolute shit lol
this is easier to optimize than the cmc tho prolly
Can someone pls help (live prefarabli) we cant get our AI spline to move
We have tried builds 100 builds and it cant be done.
does this mean can't be executed in the first 5 seconds?
It means it will execute once, then fail for the next 5s, then execute again, and so on
it wont run the first 5
Show your tree
Could it be that the next decorator is failing? Have you hit pause and stepped through the tree?
It fails if it’s not inside the cone
4.45
damn goodbye player character is set
That doesn’t show whether it tried to run the first time and failed
Like hit pause and go back using the arrows
You can also remove the other decorators under it and just put a wait there or something to test
Ok so we FINALLY found the problem, but not the solution. There is something with the Spline that cant detect the Level (generated Landscape) but it can detect on a regular plain. Why is that?
can i change the brush?
Making your own CMC is a really bad idea. There are lots of optimizations you can do.
You really should profile using a packaged test build. You are going to get very different results when trying to profile via the editor.
You pretty much have to make your own CMC for smoother gameplay for a number of things. Because of FSavedMoves. (I should've been more clear on which part I was referring to. The networking portion of the comment. Not necessarily improving perf for the AI)
It can be done and is actually trivial. How are you trying to use the spline?
Every single time I've seen a team do their own CMC, it's always worse.
I'm talking about inheriting from it btw. Not a full bespoke custom thing.
That's completely different
Change what brush?
da sprite thingy face
Only by editing engine source
Do you mean a full shipping standalone or 'play standalone' option in the play options?
But that takes hours
I suppose it would be worth it, for unreal insights do I need debug, development, or shipping build? (for getting a detailed profiling tree)
Definitely not shipping. But otherwise, I think the others are fine? I haven't used much of insights to be honest. #profiling would know though.
A packaged test build. Not in the editor, a packaged game. Not shipping or development, but TEST. Test is the closest you can get to a shipping build, but still has the profiling events.
Oh i never noticed a test setting
Know how I knew you were profiling in the editor? Your slate numbers.
Do you know any way to reduce the time to build down from hours?
It does get significantly faster the 2nd time but the 1st one is too long
You might have non performant UI, but it's unlikely to have that bad of slate issues in a packaged build
When packaging, what takes the longest is cooking assets. So make sure you don't have a lot of unused assets that you are cooking
Interesting, I'll filter those out then
Yeah, extending from the base one makes alot more sense 🙂
Hej , we have some issue with landscape and spline . If we remove the landscape and use a plane the spline works in. Build. It always works in all cases in editor tho.
Might be something with collision when the landscape was generated or something with the material function we painted landscape with or maybe something else ... We can't figure out what it is .
@uneven cloud Do you have any ideas ?
Its something in the landscape material that has material funcitions, and check the material when AI is moving to make different sounds.
When we build with only a landscape without material it can move, when we build with material and paint the landscape, it moves on the first tick then stops (not visible but we hear the step sounds)
Do all the blackboard key get assigned the stuff they should? Relying on random literal names seems bad, how does it know when to put a vector value if I have 9 vector keys
I don’t understand what you mean.
It's just a TMap with FName as the key. So, yes, they get the correct value.
Do I have to put the exact same name? Or if typo won't be assigned?
Yeah, make literal is not ideal, granted, very bug prone to typos. But you prly also shouldn’t have 9 diff vector bb keys
Question guys, if I have a selector and the left branch (sequence) is executing, can it jump to the right if it's if it's true or it won't jump unless it breaks?
Only if it fails
so the sound thingy never executes if the actor is not set right
pointless
cant jump
Correct
You also don’t usually need that second decorator
If not set fails, it means it’s set
There are some instances where you need both tho
Gotcha thanks for the help👍
What do you mean that it doesn't work? How are you moving it? You need to give information on what you are actually doing.
this is a notify when you land but absolutley nothing happens, any1 know why?
You can make it abort lower priority.
Have they changed it to a TMap? Last I looked it was an array.
no i mean its not executing, breakpoint dont hit
Usual way, tick and points on spline
Gosh dang it Luthage. You did it again. Caused me to actually look at it. It's a UDataAsset with a TArray<FBlackboardEntry> for the actual contents. So, yeah it is still an array. I've always thought it was a TMap because the way you work with it was very map-like.
FBlackboardEntry has the entry name as an FName. And a TObjectPtr<UBlackboardKeyType> for the type.
That's not much information for her to help you. You need to describe how you're doing things in a lot more detail. The less you want to type, the less of a chance someone will be able to help you.
There is no such thing as "usual way." There are lots of ways to do things.
Yeah. That's what I remember. If you use the key ID instead of FName, it's constant access to the array instead of iterating through it.
You can get the key ID from a blackboard key selector.
Anyone played around with customizing pathfinding? I'm trying to see if there's some way to make actors prefer moving only in cardinal directions
I tired setting up a query filter which increases cost on paths the more they diverge from directly on X or Y axes but it doesn't really seem to have an effect
so im making a game (blueprint) with chasing ai, but for some reason the ai likes to chase the other ai instead as well???
it likes to make clusters of ai
especially at like 0:49
for now it goes to enemies and neutral but:
- switching to enemies makes it chase nothing
- the ai doesnt have their own stimuli
trying to follow this tutorial: https://www.youtube.com/watch?v=R87HO3PeIso
hopefully you can read that
this
this is update actor bbkey
I'll attend later , not är the computer and the logic is not the problem, the problem is described and seems to be a unreal thing or a setting that we missed for physics materials
my guess is that they keep getting "distracted"
i guess so, by themselves
which is weird cuz i thought they needed stimuli
there's a way to make them respond to certain actors only but i cant remember it rn 🙂 , give me a minute pls
i swear ai was easier in 4.26
this is how it should work
yeah, give me 1 more minute pls 🙂
@dull harbor
u can define it only in c++ it seems
you can use LowEntryExtendedUtilities plugin
whats that
they exposed the functions to set GenericTeamId
affillation detects based on the IGenericTeamAgentInterface
with for each loop
oh thank goodness
If you aren't using C++, then you can't use the team interface that the perception system uses. That means you have to filter targets yourself.
If you don't want the NPCs to be perceived at all, you can disable auto registering pawns in the ini and add a stimulus source component to your player.
default is 0 = neutral
how do i disable auto registering
=/= is hostile
== is friendly
whats ini
a config file
In C++ all you need to do is to call UAPerceptionComponent::UnregisterSource. This function however is not exposed to BP, so if you want to do it in BP you’ll need to put more work in. You need to make pawns not auto register for AIs’ sight sense. To do that add following to your DefaultEngine.ini: [/Script/AIModule.AISense_Sight] bAutoRegiste...
lets hope this works 🙏
with the plugin you can set those team id
no they still cluster oof
should these also be numbers
Did you restart the editor after changing the ini?
yes, 0~65565 only however
yeah
so... is:
undefined = neutral
0 = enemy
1-65565 = friend
??????????
No. The default affiliation is team id != Other team id
oh ok makes sense
0 = neutral
team id != other id > hostile
team id == other id > friendly
gonna try this see if it works
so should i set the team id of the ai to 2 and the player to 1
how can I keep updating the AI MoveTo with the EQS??
it updates the EQS, but the AI moves to the location it set before updating
ok uh @south ferry so i set them to only follow enemies
and i put first person character team id to 1 in construction
and ai team id to 2 in construction
still doesnt work tho
nv, fixed it, my bad
cc @uneven cloud @lyric flint
now they just dont follow
with blueprints, i'd just end up utilizing that node
I've never used that plugin, so I don't know if or how it adds the team interface to the player
@dull harbor what do u have that set to?
also u might wanna try doing that on begin play
just in case
i'm unsure how it's supposed to work though
changed to this
same thing
make it set to neutrals
as well
just don't have friendlies detection enabled
@dull harbor
i just remembered something
only AAIController has IGenericTeamInterface implemented by default 🤦♂️
so it wouldnt work without c++ anyhow
so the only option would be making use of this node I'm guessing?
@south ferry
The fact AI controller implements that by default is kinda confusing
yea
It literally cannot work without implementing it on a pawn
since it sense the pawn..
waaaaaaah
so can i detect if its a player or something
no...
ye so you have to detect neutral, from the array of perception, either use casting or actor tag to differenciate between player or ai
ok hmm
this-to
u can also check (equal or whatever) the class (would be much better than casting)
i should probably silence myself as idk how these events actually operate 🙂
do an ==
target perception update is probably easier to use
just cast the actor to your player class
and check stimulus' successfully sensed to determine whether sight was gained or lost
also casting isnt so bad if the class is already loaded somewhere else in the game
casting is only bad when it loads an entire class unintentionally or having too much dependency
if true select player otherwise none
if you dont want to care about classes, then use actor tags to differenciate them
It can. You just need to override a function.
now these ai are really scary lol
they can use chase you and use doors and are fast 😨
in the 4.26 version they could open doors cuz doors kinda sucked
i wonder if i can have an ai tell the other ai in a certain area where the player is??? but this would kinda suck if there were multiple players
you still can do that though, the ai just tells which player it is looking at (what is my target)
what would be the best way to implement broadcasting to nearby AIs like that?
with a collision box?
or maybe a multitrace?
Oh? Which one? I was looking at it a while back and don't think I saw anything other than "implement this on the pawn and call the functions on the controller"
maybe each ai could have an array of actor locations (with max ages)
would be so complicated
and i kinda dont need to worry about this right now heh
either a trace or a hearing sense
Hey there, I was wondering, is it possible to tell an AI character to jump, and to have some relatively fine control on how said character is jumping?
The same way you would do it with a player, I’d imagine.
One of the functions on the team interface. One of the get affiliation for functions that takes in an actor. We use the pawn, because we need the team id replicated, but in the past I've just used the controller.
Please stay on topic
Better you just screenshot and explain the issue
Pretty sure the object it's sensing (eg. the pawn) needs to have the interface, because how else is it going to know what to call because I'm pretty sure it doesn't try to GetController() from it and check whether that implements the interface 🤔
The only thing I could find was a Jump() method on ACharactor, I'm trying to find if there's any other method than that to do it.
It calls the interface function on the listener, which is the AI controller
You could prly make your own jump function if you really wanted to, but it’s not going to be any different if you did it with AI or player
his name is carl... he is mean
Correct, but it compares it to the sight target which is the pawn
It calls a function on the interface that sends the pawn. You can override that function and get the controller instead.
hmm
yeah I guess if you override GetTeamAttitudeTowards on the controller that's doing the sensing and have that cast Other and get the controller from it that would do it
It just feels a bit backwards that the one that is sensing needs to deal with that :D
If I wanted to turn off gravity for my agent, what would I do? I couldn't find a good way to do it online.
(in C++).
cant you just use the viewer and do it from there?
the viewport
Depends on what the agent in question is
If it's a character you can turn off gravity from the CMC
Yeah, that's what I found out, thank you!
how can I keep the AI to move to the updated location??
the AI will fire only when the point is reached
what happens, the AI sets a location and goes to it
when the EQS updates, the AI will remain moving to the first location until reached
I instead, want the AI to move to the updated EQS location and on success we do the rest.
any ideas?>
In the move to node there is a setting for observing blackboard changes. You need to set it to do that and set the tolerance.
thank you!
this is never going into the sequence, why??
Because it's under a selector and the task is succeeding, so it doesn't need to go to anything else.
Ohhhh. My bad..
That's embarrassing
thanks
yup, all working well
This is what I am thinking on how my ai choose and fight other ai. Any thoughts on this?
Basically I got minions and Enemies. Slimes and stuff.
So if I have 5 minions fighting 5 slimes I want it to flow and look good. not just them all jump on 1 thing
any idea why this would be happening? the AIMoveTo always returns success when really it prly shouldn't considering the path is never resolved
maybe because of partial path?
what's the best way to deal with enemy reaction time??
the enemy will only be able to attack when the reaction time is >= 0 and we will stop reducing.
if not, we will keep failing and reduce the reaction time
was thinking with a service, but not sure how would I make it to fail within the condition?
Please explain better
I’m pretty sure I’ve tried it with both AI MoveTo and move to location or actor with partial path turned off, and still same. I’ll double check when I get back on
It can’t seem to project to the navmesh for some reason
Your vislog log says it's a partial path.
Ok, so if i try move to location again with accept partial path off, it should return fail, I imagine. I still need to figure out why it can’t find project to the navmesh though
Hi, I'm trying to make that AI Enemy able to avoid bullet(slow speed) by running EQS and MoveTo the location.
But Query doesn't get score from bullet actor's distance.
For Bullet Context, I just set Cast BP_Bullet. How could I make it?
also, I try another way like this. but AI Character only come to bullet actor
I got it working
Reaction time says to the AI when to attack when it reaches 0
I ended up doing it in a service and a decorator
Service to reduce the reaction time until 0
And the decorator to check if it's >=0
And it worked well
Try setting the bullet to the ground and see if anything changes
I tried it and nothing changes.
It's the Bullet Context node
That's never going to work unless the actor performing the query is a bullet
Note that the parameter is name is Querier Actor - the actor which is performing this query
for me i got the querier actor's blackboard and got the actor i set as target
but mine is for AI not sure about yours
still need help figuring this out. Like yeah, it fails if I don't allow partial path, but this doesn't tell me what's wrong with it other than it can't generate a path.
I've tried diff move to nodes, diff AI Controller classes, testing the navmesh on the landscape vs on a mesh, using actor or location as a goal
You need to give more information on what is failing. Add some vislog debugging, such as showing the start and end points.
What you are trying isn't going to tell you what is wrong. You need to actually debug it and not try random things.
ik that lol, I initially showed my vis log
sec I'll get one with something other than AIMoveTo
You did not add any of your own logging.
ik you mentioned that before but I couldn't find how to do that in the docs, is it the cpp functions they mention?
There are vislog BP nodes. Just search for vislog.
oh, right, doh 🤦♂️
ty
Start with doing vislog location for the start point (pawn location) and end point. It says that it can't project the end point, so showing the end point will likely show you exactly why.
yeah, I added a vis log location with 50 radius and it's not even showing anywhere on the map, I gotta figure out what's going on lol
Anyone know if there's some particular reason StateTreeRef in UStateTreeComponent is not settable? As far as I can tell there is nothing in there that wouldn't allow switching it at runtime
(Looking to reduce my boilerplate a little so I could define the default tree in my pawn and the controller would grab it from there instead)
I tried setting the Z to 0 as well, so the sphere is even lower on the mesh just in case
but now with move to location or actor I don't even see anything in the vislog about the actual pathing, only these redirects
I don't get this, I've made AI before with no issues 😅
ah ffs
I thought about this before but I didn't actually try it... 🤦♂️
Had to add a delay until next tick between the line trace I'm doing and the actual moveTo node
weird tho, it's not like I have to wait for the line trace to get the vector, I'd tried it with fixed vectors too
running this onPossess btw, so not like it's a BeginPlay issue 🤷
Hmm, it's kinda looking like state tree doesn't really have any mechanism of easily waiting for a task to finish, and then performing another task based on the finished task's data 🤔
Eg. you have a task which runs an EQS query and you want to use the result of it in another task - how are you going to do that? You can only link task parameters into tasks in parent states, but you have no way of determining whether a parent state's task has finished.... because if the parent state's task actually ever finishes, it causes the entire state to finish immediately
So it seems you either have to do all this work up front, or you have to keep retrying until the data becomes available, which you determine via some other property
idk why I had to add a slight delay after Event Possessed for the AI to be ready to move (maybe bp too slow?), but it's not like I need it to go as soon as the game starts. the vislog nodes are def helping troubleshoot the path issues, thanks @uneven cloud 🙏
Hmm so there is an actual example in the engine source of how a delegate can be used within statetree tasks 🤔
It seems to suggest if you want you can write into instancedata in the delegate through the struct ref
It also unregisters the delegate if it's still valid in ExitState as one might expect
(this is in FGameplayInteractionSyncSlotTagTransitionTask if anyone is wondering)
is there a way to run the generator on the right if the left one is valid?? (by context)
afaik the additional generators only run if the previous ones produce no results, so that would be no
alright, thanks
Expose the variable
dont see any option to do so
How are you setting this target, inside a task?
from the Ai controller
Show code
Can I use multiple sights on a perception component or is this not allowed?
When I use second sight, it seems to not be registered
sights or senses?
sight, wanted to do two different configs (e.g. one for noticing for combat and one for stealing)
Two sight configs on same perception component won't work
You can add a second perception component and give it a different config
Thanks, will check that out.
on possess happens before begin play so it needs a delay i just found this out too
ive never even heard of vislog i needa learn that
I thought it was the opposite - well, the point is usually you want to wait for possession before doing anything, hence why OnPossess is preferable over begin play
Tools -> Debug -> Visual Logger
Does anyone know how to use FindPathToLocationSynchronously()? What is the WorldContext UObject first parameter and PathfindingContext supposed to be?
Also wondering do people generally follow the public/private split or just put all their code in one directory?
Hey folks, why doesn't State Tree component start its logic when you add it to the AI Controller instead of the Controlled Pawn?
Also why doesn't the State Tree enter/exit state debug feature work in 5.3.1? I can't figure out why the button is there, but it doesn't function.
Hello. I'm trying to get navigation mesh invokers to work. Followed several tutorials but for some reason my AI does nothing. AI works perfect with a normal navigation (non-invoker) volume. When using invokers pressing P also does not show the green nav mesh. But I guess this is logical as navigation only gets generated on runtime? Question still remains why my AI doesn't do anything? Is there a way to see the generated nav mesh on runtime?
Wait, ok so I reverted everything back to static, disabled invokers and now my navmesh doesn't work anymore either?
Everything worked perfectly fine before switching to invokers? What is going on? 🤔
OK, Anyone know why I cant select my target Variable here, Cant even see any option to expose them?
Strange AS my EQS can use it.
Do you mean that I need to make That Bullet's Behavior Tree ?
Thank you! I will try it!
nvm I just Made My Own, as the inbuilt one seems to have an issue.
I solved it. I use Get actor of class then it has affected. Thank you!!
key type for you Target should be an Actor
you can also use Focus/SetFocalPoint
when designing a generic BT to handle the most common NPC tasks, is it best to try to keep it all in one BT or should I have a "core" BT which then runs smaller BTs which are just for specific tasks? if that made sense :X
Your use case generally gives you that answer on its own. If you have shared behaviours, you’ll likely end up breaking it down into subtrees so you can reuse things without duplicating entire trees
You can always start with one tree and make your way from there, refactoring is inevitable anyways
I see, I will start making some smaller BTs for individual tasks rather than trying to make just one big BT and see how it feels. I already have a robust BT for the common tasks, my problem is getting the BT to go "back" so it can start with another task earlier in the tree as it just wants to move right, this problem is easily fixed by just splitting it into smaller trees though. Do the BTs share a blackboard if they are all on the same aicontroller? that would massively streamline things
Yeah, in fact you have to use the same blackboard for subtrees
Otherwise it’ll yell at you 😀
cool! i will have a play around, thanks for the info!
Why are you directly using find path instead of the built-in functionality? A world context object is anything you can get the world from, such as an actor.
You're saying there's an equivalent class functions for actors?
Unless your project only has a few files, organizing your files into directories is incredibly important.
Yeah I do organize in directories, but don't find a lot of value in private/{dir1} + public/{dir1} vs one set of folders other than unreal seems to expect the first way
I don't understand what you are asking. Actors have a function to get the world.
What do you mean by built in functionality?
Most projects I've worked on has used the public/private directory set up. It's more for larger projects.
If you are trying to make an AI move there are better ways to do it. Like the AI task or the function on the AI controller.
I see, yeah that makes sense.
This is actually to find the distance to different players before I move though, to make the decision on who to target
You can see the nav mesh during runtime by hitting F8 and toggling it on/off using P. F8 toggles simulate mode.
Delete your recast nav mesh actor (not the bounds volume) and rebuild the static nav mesh.
EQS tests
You rarely need to get the path length for target selection. Go with the simplest version of distance first.
Ok thanks
Hello, I have multiple types of enemies in my game. I'm trying to make animation blueprints in a reusable way. I already made the ABP for the melee enemies and now I'm trying to use basically the same blueprint just with a different skeleton and animations for the ranged enemies. Is there a way for me to do that? I tried creating an animation template but I couldn't find a way to change the animations. Do you guys know a smart way to do that so I don't have to basically create the same state machine and variables in another ABP?
Probably a question for #animation
you are right, I didn't find the animations channel
thanks
We need a Luthage appreciation day 😀
Somehow this channel gets a lot of animation questions so you're not the first one lol
now I might be stupid here but I can't see an animation channel
it shows up if I click on your link but I just can't find it otherwise
🤔
Server settings check all categories
It's in the Content Creation category, yeah maybe you got it hidden somehow
The naming of those categories is… lacking
Any way to make certain AIs not use navlink proxies? I want them to not use navlinks in their pathing
It is actually my birthday today
I do not want this to generate here, since the actor on the right is out of range
but generate here since the actor is in range
is it possible?
or should I make a custom generator in cpp? making the actorsofclass does the cone?
Oh! Happy Birthday!! 🥳 🎂
happy bday!
What is it that you are trying to do?
I do not want to generate an EQS if the target projectile is out of range
I'm just trying to make the AI to evade incoming projectile coming their way
iirc you can mark the links as some nav area type, and then use a navigation query filter that excludes those area types
Then you should make separate EQS. Then do a sequence of Run EQS tasks.
so make an EQS to detect, if valid, run another EQS for the Cone?
Yes. The first one puts the projectile into a blackboard key that the 2nd one can use as a context.
can i set/ get vlaues of a blackboard from the character bp?
like for making ai go to where the player see or smth like that
As opposed to just doing it from the tree ?
Better to get the reference of the player inside the Aicontroller and do there
Or directly from bt
*in bt
makes sense
yh basically get actor from class and get the event and feed the params
You can use get player character node, use an interface, cast to player all kinds of goodies
Happy Birthday Luthage. Thank you for always sharing your knowledge so willingly and especially thank you for always making me double check the code itself. I highly appreciate you 🥳 🥳
Does anyone know how to increase the avoidance distance of moving ai actors (RVOAvoidance or detour) without making the character capsule bigger?
Try increasing the agent radius in the CMC
this?
sadly had no effect
if I make the character capsule bigger things work perfecly
but than they don't fit through doors
Hold on
There’s a couple of settings under the RVO avoidance
Did you try changing that consideration radius
yea I did
but I think it is just the radius in which range it considers other actors
not the actual avoidance distance
And the weight?
tryed some values but anything other than 0.5 just had weird results
lol comments
The 1st and 3rd have the same exact comment
/** The scaled collider radius to consider for RVO avoidance **/
virtual float GetRVOAvoidanceRadius() = 0;
/** The scaled collider height to consider for RVO avoidance **/
virtual float GetRVOAvoidanceHeight() = 0;
/** The scaled collider radius to consider for RVO avoidance **/
virtual float GetRVOAvoidanceConsiderationRadius() = 0;
how would I change the Radius without making the collider bigger 🤔
I use mostly bp, would I need to do this in cpp?
idk if you can. Tbh I know very little cpp, but looking at the overrides in the CMC, it looks like that is directly tied to capsule size
float UCharacterMovementComponent::GetRVOAvoidanceRadius()
{
UCapsuleComponent* CapsuleComp = GetCharacterOwner()->GetCapsuleComponent();
return CapsuleComp ? CapsuleComp->GetScaledCapsuleRadius() : 0.0f;
}
could I just put in some other value for the CapsuleRadius or would this require me to compile the engine from source?
because right now I am just using the one from the launcher
Yeah, not sure if you can do it otherwise. There's the AvoidanceConsideration one that's not being overridden and is the one exposed in the settings there, but I can't tell what the diff is between the 2, I think maybe that one is used for rotation?
There are smarter people in here that might know if there's a way to change this otherwise 😅
You can try DetourCrowdAI instead (turn RVO off) see if that works better for you
I think consideration radius is how far the character to avoid can be away
but I need the GetRVOAvoidanceRadius to be bigger as it seams to be t5e actuall distance they keep
but afaik to make either of these options work smoothly, you need to go into cpp at some point
yeah, that might be it
@dense owlI think I just found the dumbest solution ever...
I thought what if it only runs "GetRVOAvoidanceRadius()" at begin play. Than I can make the capsule big by default, and than after some delay make it small again and it still uses the big radius. As dumb as it is it seems to work 😆 Thanks for the help 🙂
I won't judge haha, just hope it doesn't break other things.
yea me, too 😅 for not it works like a charm but if I end up with any other issues I will have to look into a cpp fix
I just don't want to have to compile the whole engine just to change one float value 😅
it might not be necessary to do all of that, but I'm afraid I don't know have that know-how 😅
same here
You're going to have a lot of problems doing it that way. From what I remember, detour had more things you can tune.
sadly I can't figure out how to tune the avoidance radius
hehe, I had a feeling Luthage would know we're doing hacky shit 😄
try the DetourCrowd AI instead like she suggested, might work out better. Turn off RVO when you do
I think that uses actual collision
you could try adding a fat sphere/capsule to your char that ignores other objects
I did that too but for some reason it just ignored that collison for moving even if set to blockAll
I'm having a hard time reading through it but it looks like it's doing a lot more complex calculations than RVO
Hi, I have a question about the decorators of the behavior trees.
TL;DR - Is there any way to "short-circuit" the decorators?
I'd like to abort the lower priority tasks when all 3 decorators return success. Setting like this works, but the problem is the last decorator (Can go straight to) is rather expensive, so I want it to be executed only if the prior 2 decorators return success. Right now it runs every tick no matter the prior 2 returned fail or not. Is there any way to do this? I tried turning it into a composite, but no luck. I know it can be done if I make a new decorator that combines those 3, but I want them to be separate, as they can be used separately elsewhere.
No. You need to make one decorator
How small is your capsule?
😔 OK... Thank you for answering. Just one more question, at least is there any way to call another decorator inside a decorator or do I need to move all the nodes of those 3 to a blueprint library and make them to call the ones in that?
There is no way to call a different decorator in BP.
Got it. 😂 Thank you for answering!
Hey guys, what would be the correct way to replicate the focus to the ABP? We want the character to look at the head location of the focus.
Hello. I'm trying to create a simple rts (base defence game). I'm rather a beginner when it comes to blueprints but i want to optimize the game as much as i can. So far I'm having issue with AI tanking the fps rather quickly. Having 18 AI drops fps from almost 90 to 40. Im only telling the units to move to specific location and attack building - I think i have most of the stuff on timers instead of ticks. Is there something else i can do to save performance (like some simplier navigation method or something?).
It's most defenitely not the navigation on its own. I've used up to 20 AIs with CrowdFollowingComponent on my dev scene with no major issues.
If you call the path following once at the start of your procedure, then the path is calculated once, and then the pawn just follows along. Unless you re-calculate path on tick there should be no issue with that.
@wanton compass Thank You. I'll look into it 🙂
If you have any performance issues in general, I highly recommend using Unreal Insights to diagnose them https://docs.unrealengine.com/5.3/en-US/unreal-insights-in-unreal-engine/
It looks scarier than it is in reality 😉 The pre-built .exe should be located in your unreal installation directory
@wanton compass Thank You again. I don't mind it being scary! It looks like debugging tool from Unity 🙂
Does anybody know, how to combine Navigation Invokers, with a simplified pre-baked pathfinding for the open world that would support them?
When I enable "Generate Navigation Only Around Navigation Invokers" I can't pre-build the navmesh in "NavMeshBoundsVolume". When I disable it, the Navigation Invokers stop working for me.
Is there a way to combine those approaches or are they incompatible by design? If so, how do I avoid my actors with NavigationInvokers getting stuck in dead ends?
Timers are not an answer to tick being slow btw
Probably having two layers of navigation
One for long travel and one for detailled travel (the navmesh)
They are talking about that in the Death Stranding GDC
Aaaa, why it's never easy 😄
But yeah invokers are for dynamic navmesh while prebaked is with the static option 😦
not sure about the static + dynamic option tho
22, is best at representing it's size to fit though small spaces. But I want them to keee some distance from each other, it looks best with a size of 60. But than they don't fir though doors
As unfortunate as it is, I need to have access to dynamic navigation, since the enviornment in some places changes based on player action in an unpredictible manner (I'm not able to narrow it down just to few static layers that I could toggle between)
If static navmesh is trully unavailable for Invokers then the only thing that comes to mind is inplementing a custom node system for long-distance travel for NPCs (along the roads for example)
Are there any premade solutions for that?
Plugins are fine too
Blueprint only life is not easy in general, while C++ continuing to be a pita since 1998 too 😄
So it's bad either way :d
Hi guys. I am working on a project with a particularly large map in UE 4.27. I was wondering what is the best approach for the navigation for a large area with many AI. I read about Navigation Invoker's but I have some questions in mind. I am trying to keep the project as optimized as possible so I was wondering, would it be better to use a one large static Nav Bounds Volume or a dynamic one with invokers attached to the AI/player?
You can make services that check the three things in the order you want and then activate a single Door decorator
@eren I've managede to increase my fps from 20 units on screen at 18fps to 120units at 35fps 😄 Thanks for the help. I still wonder what would be a better solution to this 'set timer' - with the current red line connected, the fps still drops from 44 to 35 at 120-140 units on screen. Without the red even connection, it barely drops by 1 fps. I don't know how i could optimized it :/
You should profile
you're also likely measuring your fps on editor
a 1 sec timer wont affect your performance that much :0
shipping build matters when it comes to BP
Editor build is 10x slower than shipping
I see
Always good to do actual profiling, as much as Eren’s blog says timers can be expensive, it doesn’t mean that’s what’s slowing down your game right now
timers can be expensive
timers can be more expensive than a tick call*
but still true
I'll do the profiling then. I already gained a huge amount of performance just by removing one of the timer events. I'm also very early in the 'development' so I'm not sure how much i should worry about optimization - just the fact that i can have 120units now instead of 18 is a huge win. Thanks guys for all the help/feedback 🙂
Always profile on lowest common denominator at early stage
Performance comes from design, not from having tick/timer/other in different forms
And you're mostly bound to whatever BP exposes you when you want to optimize, for example default CharacterMovementComponent is most common overhead in the UE so far (and its not a thing you can optimize without deep C++ knowledge)
So you should do a wide research while profiling constantly and carefully structure your project
Thanks, I'll try - i take since BPs performance can be so bad in editor, it's better to do all the profiling in the build? There's just soo much to learn at once. Every time i fix something, two new issues appears :d
Yes, set packaging mode to shipping in project settings
then package your exe
and profile with insights
you can also read the rest of the article that I've sent
(when you have time, because it wont provide an immediate information)
Aye, i glanced through it quickly to find the things I was doing in my BPs wrong, but i will definitely dive deeper into it later on 🙂
Via the character. Cache it off to the character anytime focus changes. Then replicate that variable.
okay, thanks. Wasn't sure if that was the way to go 🙂
How much smaller than your mesh is that? Can you show a picture of your character in the bp?
The controller and the ABP do not replicate, so the character is the only way to do it.
The only way you can optimize is to know what is causing problems. You do that by profiling a packaged Test build using insights. If you don't profile, you can only guess at what is slowing down.
the small collider works well for normal walking around and fitting through doors. The big one makes avoidance look good so they arent all cluping up when running after you
Why do you need invokers? It's the most expensive option. Modifiers only allows you to have a static nav mesh and then can cut the nav mesh with modifiers, but can't build new areas. Dynamic allows you to build the nav mesh at editor time and it only builds during runtime when the geo changes.
When they are running after you are they all trying to go to the same place? The best way to keep them from clumping is to use the EQS to spread out the destination and detour to keep them separated while moving.
Makes sense
the destination is already a circle around the player, but that only spreads them a bit after all they need to reach you at some point, but for example when running around a corner they stack up again.
The result is perfect when detour our avoidance have a bigger radius but is seams like you can not increase it without making the capsule bigger, which is too bad ;/
There's a lot wrong in that blog post.
Hehe that sounds much better than using random point in navigable radius 😅
Well yeah. They can be smart about where they go. Like preferring the same heading (dot product) or not going past the target (dot product).
like shown here by NeoExidious the AvoidanceRadius is hard coded to be related to capsule size
In RVO
Idk about Detour
Idk enough cpp to decipher the math they’re doing there, I just saw it was complex
pretty sure Detour also uses capsule size
Detour has more things you can tune, but it's been a long time since I used it.
are these the settings?
because I had no luck tuning/ understanding them 😅
Ah right I forgot they have them in settings
I already cranked up max agent radius and my agents radius inside movement comp and it changed nothing
But also like turn up that brightness 😀
Invokers are the most expensive options and can cause navigation bugs. The best option is to use level streaming for the nav mesh. In world partition, the nav data is broken up by the world partition grid and streamed in with it.
so many settings and nothing as simple as just the radius to avoid 😔
or maybe there is but I dont really understand what all of the parameters mean. I can also not find any documentation on the parameters
Shipping compiles out the profiling markers. Test is what you want.
Like?
Hmm, yeah recently tried to run insights on shipping and didnt get anything.. And was asked here if I was doing something wrong but didnt get any answers. Maybe related?
"Everytime the Blueprint VM evaluates a function, it just runs a code to invoke the C++ function." This section is pretty misleading. Someone on my team went through the code that BP uses to add to a variable. Get, add, and set. It was several PAGES of C++ code.
Yeah that's why. Test config is just shipping + profiling events.
It is several pages. I'll look at it again today to see what exactly it was doing.
Hah. Didn't realize you wrote that.
I've been working on a tool automatically transpiles BP to C++ for a while, ended up memorizing everything in ScriptCore.cpp 
So I thought I could write something about my adventures back at the day
though like my AI article its one of the articles I dislike, because when I wrote that I was still naive
Yeah, well, now that it’s “feature complete” when is release? 😛
when its also "bug free" 😄
creator of fluid ninja live gave me access to his plugin
been trying to compile it since a week
and its not going well haha
In the section: Do not use cast, its expensive, I would add that casting to a C++ class does not cause a hard reference. Often people cast to the BP version, when all they really need is an actor or a character.
It does not create a hard reference to data. So it's cheaper in the memory sense, which is what is bad about casting in BP.
Thats the second time I get this recommendation so I guess I wasnt really clear about that there 😅 I'll add as you said
Also put (credits: Luthage) in there 😛
The point of using timers instead of tick isn't that they are cheaper (they aren't) it's that most of the time, you don't need to do the thing every tick. So you usually end up spreading things out across frames.
I think this explained well in the reddit post I linked, but majority of the people at #blueprint is under the impression timers are faster than tick just because, so I was specifically targeting them
Fair enough. I didn't see anything about that in the reddit comment that is linked.
I'll rewrite it when I'm available then, thanks for the feedback
Casting to a BP is fine as well. What matters is the references inside of that BP. If you have no hard refs inside of the BP, it is perfectly fine.
I don’t recommend them because they’re faster, but rather to use instead of delays and to be able to control their runtime without having to use bool checks
Casting to some class with insane amount of references is also fine (in terms of casting as an operation), its just it makes BPs loading at runtime very slow but the cast itself will still run at the same speed of casting to a native class
Huh, intriguing. I was under the impression that small invokers were more performant when the world scale gets too big, or at least I think that's what my coworker said.
Are multiple dynamic navmesh bounds really more performant than invokers? If so that could spare me a lot of trouble.
When the geometry changes, only that single navmesh bound that it changed in gets rebuit, do I assume correctly?
World scale really doesn't matter, because only a section will be loaded at a time.
Dynamic nav mesh is more performant. Modifiers only is far more performant. Both start with a static nav mesh built at editor time and only update the cells when the geo changes. Not everything in the bounds, just the cells that are affected.
Just the cells? That sounds even better!
Thank you kindly I'll definitively pass that on to my coworkers and we'll reevaluate our decisions.
I made an ability system but i don't know how to apply the dmg to the ai enemy damage script i did
Apply damage , on damage taken
So whilst using the debugger, I can see that due to me rechecking if we are still chasing the right target (After move to start > delay > Stop all movement > run EQS > move to start), it is creating a queue of MoveTo gameplay tasks. Is there a way to invalidate/remove these from the queue? After reaching about 10 in the queue the AI starts moving very slowly and jittery (likely because it is trying to figure out what to actually do).
You can see things in that? 🙃
I might have started seeing things, as if the unreal debug gods are reaching out to me 🪄 I might just be going insane though, not sure which
You shouldn’t be doing this way tho
Just use a service
And have your decorator observe on bb key change
Right that is what I initially did, but I couldn't find a way for a service to run the EQS task
That is, if you’re using a BT
That’s how I usually run EQS
Task didn’t work well for me
Here is the setup:
Right click your selector
Yep
I might very well, and this has taken many hours of research, be an idiot 😂
The strange thing though is that I can only select "SelfActor" as the blackboard key it outputs into 🤔
So if I understand this correctly; The service will check every x seconds if its conditions are met. If it is, it will output the result into the key you provide, and will run the task beneath the selector right? If it returns false, it will run back up to the root node?
here's mine:
Is that selector running straight from the root node, or does it have something else above it?
This is my problem at the moment:
I mean I have another selector above it but shouldn’t make much difference
Yea I figured, just wanted to double check
You prly didn’t select the right base class on your bb key
Should be Actor