#gameplay-ai
1 messages · Page 45 of 1
@uneven cloud Do you happen to have any idea why this is happening?
LogAINavigation (Error) AAIController::MoveTo: Destination is not valid! Goal(Invalid)
LogAINavigation (Log) MoveTo: Location(X=340282346638528859811704183484516925440.000 Y=340282346638528859811704183484516925440.000 Z=340282346638528859811704183484516925440.000) Mode(partial path) Filter(None) AcceptanceRadius(50.0 + overlap)
I'm using this setup to get a position however these ones from the debugging (Print string seem fine) but the one in the visual logger are huge
Well you are setting the location in the blackboard and returning true even if it doesn't find a reachable point.
Add some vis log events to this function to debug it further.
If I only reach an offset of the player, then i never reach the player which is literally my goal?Or, you just mean an offset so close to the player that the enemy can already attack them from there?
My AI character is only rotating towards me instead of moving towards me. I have perception working and the behavor tree is also working, but the character wont actually move towards my player. What could be causing this?
It's showing this in the visual logger:
LogPathFollowing (Log) Moving directly to move goal rather than following last path segment
You'll never be able to have both the player and the AI occupy the exact same location. Unless you want them to be able to not collide at all. The destination should be close enough to attack, but not be at the exact same position.
What's odd is that I've setup other AI characters in the past and they don't seem to have this issue.
Acceptable radius is default 5
Ok ok, I think I get it now, sry for the trouble lol
What node are you using to move ?
The generic MoveTo on the behavior tree
I assign focus to my target actor (using perception), then MoveTo target actor and the BT looks normal.
Is your target bb key the actor itself or its location vector?
The target is my player character not a location vector.
Targeting using perception is working, and it can track my player character as I run around it in circles but it will only rotate and won't actually move towards my player character. There aren't any issues with navigation which I can see with the runtime AI debugger UI.
Fixed it. The problem was that I had some mesh that was affecting navigation mesh enabled so it was always in some invalid spot.
Visual logger should have had something saying move was aborted tho 🤷♂️
Is there a way to retrieve a parent actor from a state tree's task blueprints? I'm having trouble locating any such function.
Figured it out! I missed a plugin so not everything was showing up correctly.
I do have an additional quandary though, how do I go about triggering specific states from external scripts? I see something about events and tags, but it seems a bit confuddling.
Something like this?
If I'm trying to construct a floating AI in a zero-G environment, I'm going to have to probably need to recreate a "Move To Location" from scratch; do these functions run on Tick? I'm just wondering about how they work in the abstract
I'm assumign it's something like:
Pathfind once,
Then every tick to "continue on path" until reached
yeah they run on tick
it's pretty simple when you have a path
FVector UNecroAiComponent::MoveAlongSpline()
{
const auto ClosestSplinePoint = SplineComponent->FindLocationClosestToWorldLocation(ControlledCharacter->GetActorLocation(), ESplineCoordinateSpace::World);
const auto MovementDirection = SplineComponent->FindDirectionClosestToWorldLocation(ClosestSplinePoint, ESplineCoordinateSpace::World);
ControlledCharacter->AddMovementInput(MovementDirection);
return ClosestSplinePoint;
}
but the path bit is the tricky bit.
but this would run on tick, which is basically not optional for characters it has to work like that
Hello friends
I'm really at my wits' end when it comes to a flying opponent
So now I'm just trying to program a projectile movement so that it moves in the air in my direction.
My question is, is it possible to tune a projectile to move as soon as it sees me, i.e. with Pawn Sensing?
i upload my Bp image
Because the problem is now taht it moves in my direction but not if he sees so at the begin of the game he starts to move
(I know that's not the right way for a flying opponent, but I'm still far too new to unreal to be able to do everything without being able to see the whole thing in a video or picture)
What could be the reason my zombie hand slash is knocking my character around? I have set Ignore Radial Impulse on both the character and zombie but it is still happening. Although, I am applying radial damage for the attack, is that the reason?
You should probably make use of Behavior Trees and learn how to manage things like state, whether it's seen you, etc
Yeah, rn I'll just do line of sight and figure out 6DOF pathfinding later
Good to know that I essentially have to create a spline, tho
What’s an IA in this context ?
No like literally. Do you mean AI?
If so, you’ll need to troubleshoot it using the Visual Logger. We can’t really guess at what could be wrong too much, other than the obvious stuff like did you forget to add a navmesh?
Not really, it should know. But you could be trying to move to a goal location that’s not on it for example. Use Visual Logger in Tools -> Debug.
You should also manually give it a location you know it’s on the navmesh for sure to test
Then you’ll know for sure
You hit record, play the game, let the AI nodes fire. Then you can pause and click on each frame and read the info. Often, the problem frame is highlighted in red. You can also use some VisLog blueprint nodes to get some extra visual indicators, like drawing a debug sphere at the goal location vs projected location
Is there a way to manually rebuild navigation at runtime? I don't want to set it to dynamic, just to rebuild once after I set up my level
IA is AI in a lot of different languages like Italian, Spanish and French. Because the words are swapped. Instead of saying I have a green jacket, they say I have a jacket green. So it's intelligence artificial instead of artificial intelligence.
Oh lol that makes more sense. First time I read it I thought Input Action 😀
It's especially confusing when the rest of the question is in English. I'm actively learning Italian and it still took me longer than it should have to figure out.
Not without editing engine source.
Ooh nice hehe, for work or passion project ?
thanks 🙂
If you are that new, then you really should try something simpler.
I really try to keep it as simple as possible I mean this is also a sidescroller game that I make
The one with the flying unit is my last unit tab that I need
I already have all the other types 🙂
Now I just took boxes that float in the air and give points for character hits...
For fun. I want to move to Europe when I retire. I was leaning towards Italy, but their political situation isn't great for me. So now it's leaning towards Spain.
So are you going to try to learn Spanish instead now? They are very much alike, Latin based
But flying isn't simple, especially since it doesn't work out of the box.
Yes, I have to deal with that
I have now learned in life that a true artist creates his work with the things that are available to him 😄
That's why I'm going to play with the things I can for now... I hope that over time my skills will continue to improve ^^
Yep! Learning both now, but my Italian is a lot better. They are very similar.
A true programmer doesn't hack a bunch of bad ideas together.
Yes I still have a lot to learn with unreal and in the future also with C++, but where there is a willingness to have fun and enjoy the work even if nothing works xD, the way will be found
Not entirely certain why you are trying to get philosophical. Your ideas on using a pawn sensing on a projectile is so bad that it tells me that you need to try easier things first.
As already mentioned, I'm a total beginner, so I referred back to a simple tutorial. It also mentions that it's not the right way, but rather just a "wrong" option
https://www.youtube.com/watch?v=XEqUWYb6n8I&t=381s&pp=ygUUZmx5aW5nIGFpIHByb2plY3RpbGU%3D
Hope you enjoyed the tutorial, comment with any questions or suggestions.
Follow and support my Instagram and Twitter to track the development of my games!
https://www.instagram.com/joshgoblue_dev/
https://twitter.com/JoshGoBlue_Dev
If you would like to see more tutorials in the future, subscribe and comment ideas!
It's always funny when french speakers use the french abbreviation for Object-Oriented Programming in english context 
That isn't actually helping you.
You're right, just like Gorka's tutorials xD, but I'll leave that topic for the future for now...
Anyway, thank you very much for the tips and ways you mentioned on the topic of “Flying Ai” 😄
in vermintide, theres a lot of enemies that spawn like 100 - 200 and when i try to add a large amount of my enemies into the game, the performance sucks
is there a way to make unreal engine handle a large amount of AI's?
note: the performance isnt like 1 FPS its more like 20 which isnt and never wanted when fighting this many (or more) enemies
It's possible but it's unlikely to be super simple
For starters the Character Movement Component is expensive enough to cause issues when you have a lot of enemies. It has features which can be toggled to alleviate the issue, but it may not fully solve it. Beyond that, there's also things like costs from skeletal animation which can also be optimized but it's a complex topic of its own
The best way to find out what you need to do is to profile your game using Unreal Insights
Can also make your own dynamic tick system that adjusts the tick rate of actors depending on their distance from the player using the significance manager and the viewport.
Which is only relevant if the problem is with ticking actors. Should never do something like that without profiling with Insights
Mass Entity and Mass AI are the new systems designed for large groups of characters.
Profiling and optimization is not an easy topic and it mostly comes down to: profile to see what is causing problems and then fix what you can. If you don't know C++, you're going to have a very difficult time getting hundreds of enemies to be performant.
the issue i had with Mass AI is that they have to follow a path not the location of the player thats why i didnt use it
That's a really bad reason. Non mass AI have to follow a path, it's just added functionality that makes it follow an actor. It's trivial functionality that you can add.
but would is there any tutorials or stuff out there that explains how to set this up cuz im new the the Mass AI and never experimented with it before
No idea if there are tutorials for it. You are going to have to eventually not rely on tutorials to do everything, because there isn't always going to be one.
well i know that but if there isnt a tutorial on something i go to this discord or look at a forum cuz i dont know what im doing since its something i dont have experience with
Hi guy! I'm using the following setup to try and set a bool for my running animation to have a random jump while running. However as I'm debugging on why its not working I found out that the "get distance to" my character seems to be resetting to 0 everytime.
Here is my debug:
LogBlueprintUserMessages: [ABP_Jester_C_0] 0.0 LogBlueprintUserMessages: [ABP_Jester_C_0] 1880.454346 LogBlueprintUserMessages: [ABP_Jester_C_0] 0.0 LogBlueprintUserMessages: [ABP_Jester_C_0] 1879.905029 LogBlueprintUserMessages: [ABP_Jester_C_0] 0.0
Does anyone know why this is happening?
Which part is AI related ?
the player controllers isnt your actually player, you'd have to use getPlayerCharacter then plug that in the other actor
That still gives me the same weird output of 0.0 and the actual distance instead of only the actual distance unfortunately
is the jester variable set properly and stuff
I Thought it fitted here as it is part of my AI characters behaviour
Excuse me for misposting 🫠
You need a ref to your target actor
Your Target pin should be self
Jester should be other actor
Provided you’re doing this on your char and Jester is the intended actor you want to check distance to
It should not be self in the anim bp
Ah, I missed that part. Get player pawn or what was it again
As far as I know it is, I'm using it to get the velocity of the Jester as well as other stuff
Again incorrect
Idk much about #animation sorry, but regardless Other Actor was wrong in both cases
Its actually vice versa, I want to calculate the distance from the Jester to the player
Yeah should post it there, my bad
Then do that in the Jester maybe?
People are doing a lot of guessing at what you are trying to do. How about you actually say in words what you are trying to accomplish?
Okay 🙂 So I have a Jester Character that walks around. As soon at is detects the player by sight, it starts to move towards the player. When moving towards the player the speed gets set from 30 to 300 and it starts the running animation. What I'm trying to do now is, to check if the distance between the Jester and the Current player is greater than 250, in order to set a bool "IsInPlayerRange" to True, otherwise false. This bool contols an Animation State in which the jester jumps instead of runs
The problem that it seems to have is that it goes back and forth when reporting the distance between 0 and 1800, the actual distance instead of a consistent 1800
You are going about this very wrong. The animation BP should NOT be determining AI behavior.
BT and a service/task that checks distance should do the trick
The AI should determine if IsInPlayerRange is true and the anim bp should get that from the AI. Not calculate it itself.
Not everything needs to be a BT and service. Calm down.
I figured this would not be the only behaviour they need for their AI in the long run but 🤷♂️
Aight thanks for pushing me into the right direction on where to look! I already have a Behaviour Tree (if that's what you mean with BT) for patrolling around and chasing the player 🙂
How do the AI Controllers have "Move To" within a single node? Are there just a bunch of state and hidden tick functions that move towards a target while the right state is ticked?
In trying to make my own custom Move To for 6DOF for an AI Pawn/Controller, I'm a little unsure of how to start.
I'm only still checking out some primers on Behavior Trees, but it seems like something that a BT could do for me anyways, since it can itself evaluate per tick what it needs to be doing.
It's either overkill or a good bridge for not having the MoveTo functions I need, by having tasks as simple as "accelerate towards target" and managing all the typical things a "move to" node must already manage
The AI move to uses the path following component to follow a path. It finds a path from the navigation system and moves the character via the movement component. There are no states or hidden ticks.
What i mean is that, implicitly, there must be a tick event going "so long as you haven't reached the destination, keep going along this path, etc"
Like I said, it's all handled in the path following component
Moving that functionality to a BT would be a very bad idea.
Then you'd recommend if I needed to modify for 6DOF, that I should just modify the path following component?
No. First you need to get 3d navigation working. Then your own movement component. Path following probably doesn't need to change.
Is this doable without C++?
FloatingPawnMovement probably sufficient for movement component for now.
Not in any performant way
What exactly are you trying to navigate? Often 3D doesn’t need path finding because there’s no obstacles
That's not even remotely true
Right now I think I can get away without path finding since I'm just testing, but ideally I'm making a 3D map; i.e. picture an astronaut around asteroid fields
I'll forgo pathfinding then until I'm more confident in how it all works together; FloatingPawnMovement and Move To Actor should be sufficient for now until I need more complex navigation.
I naively thought all the AI movement funcitons would only work in 2D with a navmesh but it seems to work with floating just fine.
I would argue it is. Not many games ask for 3D path finding. They just have actors flying in unobstructed sky in safe boundary zones
I'm starting with the idea of an astronaut defending a bare planet with AI floating directly towards targets/player, but ideally it could get more complex than that (navigating a 3d maze, or being inside a sphere with entrances, etc.)
Lots of games use 3d pathfinding. Some use probes instead. Others do a hover offset from the 2d nav mesh. Rarely is it unobstructed for anything intelligent.
Yeah, but not many games need intelligence :p
Flying npcs are usually dumb and that’s usually fine. Not to say there aren’t cases where you want it but… eh. Indie games probably not
What do I need to take into account when trying to replicate zombie AI? Isn't the character movement replication built in and just needs to be turned on? Would the only replication required be with the player characters it's interacting with? Just trying to understand the basics and where I should start.
Nothing AI related needs to be replicated. The ai figures out what to do on the server and whatever it tells it to do is the stuff that gets replicated
Well... AI is not replicated. The AI happens on the server and the character is a server owned actor.
Ok, so I should be multicasting every action? Like just the actions, nothing needs to be done with the animations? How about the character movement for the AI?
No you shouldn't use multicast.
Then what should I do?
That entirely depends on what you are trying to do. IF the action needs to be replicated, then it's better to use on rep functions on variables.
So the replication happens through the variables?
Character movement is already set up to be replicated, you just need to turn it on.
Yeah cool
What part of it depends on what you are trying to do is not clear to you?
With the character movement being replicated with it replicate any animations it has?
No. The animations will not be replicated.
Ok settle down just trying to understand how AI is replicated
AI is not replicated. How you replicate the CHARACTER depends on what you are doing.
Well the AI is a character, so I was assuming it also replicates AI movement. That is what I was asking.
Because the "same" CharacterMovement component is used on both.
Yeah, so it's different since the player is a client and the AI is on the server?
No it’s pretty much the same
AI on server tells actor to do thing. This action gets replicated.
Player on a client asks the server to tell the actor to do a thing. The server says ok. The action gets replicated from the server
So movement type animations will replicate the same as a player?
Animations are entirely local
Ok
Your local animation blueprint should figure out what to do based on the replicated variables
Montages being different
Ahh I think I understand now. At least a little bit more, I'll look at more tutorials. Thanks.
for a simple Ai is it better to make a Ai from the pawn or character class?
it will only go towards the player and do attacks according to what enemy it is
since it would be more performant than using a character class and im not using like 90% of the characterMovement
There are still a lot of useful things in the CMC.
though i doubt id use them since my enemies will not be complex
Even something as simple as Add Force and Add Impulse aren't available in the other movement components
but if you don't think you'll need it, then why not?
well my enemies are currently made from the character class and im using addimpulse. i guess ill stay with the character class instead of pawn but how do i turn off most of the unwanted functionality in the charcter class if possible (askin this cuz i need to spawn in a large amount of enemies with great performance and i read a reddit post abt the character movement could be a factor in the bad performance)
Measure Profile twice cut once 🙂
is there anything to look out for, i only really used unrealinsights a couple times but dont know a lot abt it
There’s some pins in the channel Duro mentioned that help learn it. And you can always ask in there too
Session Frontend also had some decent functionality but that part was deprecated
Im making a strategy game AI.
I need AI to recruit soldier every 30 seconds.
Build building every 40 seconds.
And build city every 60 seconds.
Should this all be in one task?
Or i create a new task for each one of them?
I think it be more organized if it was all in one task.
Though im not really sure how im going to do that
In blueprint its Set Timer by Event : 30 s , Recruit Soldier
Any tips, pls?
Yeah at least to me it seems timers would work if it's like that
I don't know if I would put the logic into a BT task though. I'd make it maybe in the AI controller assuming that's what you have
If you use BT you can then call that function from a BT task but the logic would be within the controller so it's easier to control the specific implementation I think
yeah i have AI controller. Well that would be better there because i find the task and BT quite weird, maybe because not much exrpeince
So i can put those set timer in the Controller
but the behavior tree still checks for when to attack, when to defend and wait (boom)
And that is tied to the ammount of units the AI has vs the human player has
So, should i skip the behavior tree entirely for this?
I'm not sure why the BT doing those things would be a problem?
because its a bit messy. For this to be done in the BT. i have to create 1 task for each thing
then need to create a variable to control the time for each task, the recruitment, the building, and the build city
as you said, this would be easier with just some set timers in the controller
but then the controller wont be good to control the attack
etc...
Yeah I mean why is it a problem for the BT to control the attack?
You have some timers in the controller to build stuff and whatever, so what's the issue with BT making some other decisions?
no, there is no problem with that. Thats actually what i want. The Bt is great for that
hmmm
wait
i think i got what you saying
yes will do that
I think you could potentially use a BT service for the building stuff since they can be set to tick at some specific intervals
But hard to say which approach would be best
do i need to always use a finish excute in an ai task node ?
if you mean BT Task - you need to call finish execute when you want the task node to complete
If you don't call finish execute, the BT will never continue to the next task
(aborts can still occur of course)
So how do you stop it from repeating a task
Usually by structuring your BT in such a way the task is only ran once
I guess you could use a decorator to prevent the task from being ran if a BB value is set to true or something, or some other approach like that also
yeah but at the end of the day, its the same as using a set timer
if not more confusing in the bt
You can do all this in one task. Your timers would just switch bools on and off, which your tick function would be checking. If no bools are on, do nothing, else, do something. If your actions are all discrete (not interdependent), and greater than, say, 3, enums would work better.
thanks
If this behavior is a function of the state of the ai it makes sense to do it in a task
If it’s something the ai should always be doing you should probably just put it in the ai controller
Like unrelated to everything else
yeah its something the ai is doing all game
This sounds like a side task to me.
i dont understand how you do that in one task. Do you set a condition for the task? How do you count the time? Do you have 3 conditions?
I thought of 3 tasks for this
You don’t want 3 tasks because you want to be tracking progress for each task simultaneously. You also want your ai to be doing other things in parallel while doing the spawning business.
That what I would vote for personally. But it depends on the design. If it’s really a dumb do this every x seconds, then I would do it in the controller
If it’s nuanced and depends on state then do it in a task
Regardless of where you’re putting it. You’ll just want to spawn a timer for 60 seconds that binds to an event that spawns the thing and then restarts the timer. Alternatively, you could give yourself credits at a rate of 1 per second which will in turn build something whenever it hits 60. This is probably better in case you want to change the timing rules ever and don’t want to simply restart the clock when you do so.
You should think of the BT as a kind of state machine. There should be a clear enter and exit state. The execute function should be used to perform the setting up logic i.e. which target to attack, do you need to move/turn. The tick is where your timing logic goes so e.g.
Execute runs a function to check enemy position and established you need to move first. You set bAttack to false, then set a callback that sets bAttack to true. Tick will checking if (bAttack) then perform logic when it's true. If this isn't what you're looking for, give us more info on what actions are happening simultaneously and how your timers are set up.
Ah just read this. Agree with gorilla, sounds like more of fire and forget logic that should be handled with functions in the ai controller.
Tasks are for more complicated do X, wait, then y, wait, then z logic
got it. thanks a lot for the help guys @oblique basin @vivid drift
i need to study better the BT
its a bit complicated
too many things at once
also another thing. i create what i call a sub ai commander.
basically when its time to attack, i create a new ai and a pawn, and that ai and pawn has a new controller. And give it some units. so this ai that is supposed to be a little commander that will perform an attack
so its like almost independent from the main ai
once all the units that are under the control of this ai dies, i destroy it
this is so the enemy faction can coordinate different attacks. given different units
so a little group is given to one sub ai, and he goes here ->
and another group is given to another sub ai, and he goes there to attack another faction ->
its working quite well. though i dont know if this is a good practice
Sounds fine to me
since im having a lot of Ai enemies in my game i needed to find out what is making them less optimized and fix that and i found that one factor is the tick function but i need the enemies to update every frame and not 0.1 per frame. is there any fix or another way to optimize tick?
what do you mean 0.1 per frame
you mean every ten frames? what exactly are you doing on tick that "needs" to be done
well i mean like having a settimerbyfunction node and setting the time to 0.1
so every 0.1 seconds it fires a function to update where the players location is and go towards it also with rotating to the player
a "frame" is every time the game runs an update and draws a new frame on the screen. e.g. when people talk about games running at 60fps that means it's doing 60 updates every single second.
You do not need to be updating the player location and reorienting towards the player every frame or anything like that. You can just use built in functions to go towards an actor.
but theres a issue. the player will move to a different position and the enemy will go to that old position (where the player is not is) and i dont know a fix thats optimal
AI MoveTo's Target Actor pin
well im using that node but if u call it once it doesnt update the location for the Ai to move to
You don't actually NEED to update it that frequently. Human reaction time is about .2 seconds.
now that i think abt it at first i need to rotate the enemy every frame since it looked choppy if it had a delay but i changed it to lerp between the current rotation to facing the player so i might add a delay without it looking weird but the going towards the player is different
Why aren't you using the built-in rotation in the movement component? There already is a really good and performant lerp.
character movement component or something else?
Yes.
when u say built in rotation do u mean theres a function or a variable because when i search up "rotation" there isnt anything to change the rotation
There is a rotation rate.
oh my bad i forgot it was a rotator brain kind of shut off. makes more sense now
You still do not need to update the target's location every tick. .25 seconds should be fine.
but what about the position, im still telling the AI to move to the players location every frame since the player will move and the target location needs to be updated
I just said you don't need to update the player's location every frame. .25 seconds is enough.
i just thought that it would look weird cuz there not accurately going straight towards u but now that i just tried it it doesnt look too bad
Never assume something like that.
So right now things are rudimentarily implemented with MoveDirectlyToward, FloatingPawn.
For context, these are AIs floating in zero-g, and while I've added some ragdolling on bullet hits, they move a little too cleanly.
I'll probably update their Target of movement to include a predictive tasks that changes the target location to something offset based on relative velocities for an intercept (since right now they "orbit" in a circle if there's lateral movement), but how would you recommend adding naturalistic "bobbing" or imperfection in their floating?
Hey guys, one question regarding pawn sensing. Sometimes when I just keep standing still it seems to stop working and doesn't recognize the pawn anymore. If I move slightly, it senses me again. Why is that happening?
Don't use the deprecated pawn sensing.
would simulating physics for a pawn that uses addForce with 100 Ai's at once be costly or would it not be that expensive
try it
when physics actors collide I'm sure they're doing much more complicated calculations than that
Yes. Simulating physics is incredibly expensive
then what would be a work around for the launchcharacter node but in the pawn class if i cant use physics?
By actually doing the calculations. The character movement component simulates physics, but is cheaper than "simulate physics".
When my character is in their default, controllable state, I'll often need to activate individual sub-states via abilities. Would the parent state be a good place to put the event-driven transitions?
Hi guys, what are your takes on implementing AI/NPCs/Monsters in Unreal (specifically Lyra)? Right now each bot gets spawned by its own AIController, PlayerState and Lyracharacter. Which is ok for a team deathmatch kind of game. But I need to all quite many roaming monsters across the map. What do you think is a better way to implement this (if any). Or should they also be spawned with their own AIController et'c within the proximity of the players? Because I kinda want them to be visible from afar as well.
OK thanks, I got it from a tutorial. What’s a better alternative?
I'm still rather new to Unreal, but from what I can tell the behaviour/state tree system seems quite efficient. Everything is structured in such a way that lends itself to good performance, only running code when it's necessary. So offhand I would think AI controllers would be fine.
I'm 100% not sure about player states though, but I would think those would only be relevant to players and NPCs who are actively playing the game, less so the ones who are just wandering about.
AI Perception
4th pin video here goes over it a bit, among other things
Im more concerned about battle tested techniques and not speculations at this point, cus Im quite comfortable with Unreal and behavior trees etc but is not sure if it can run 150-200 agents over multiplayer well
Hi! I am using smart objects in my game for slot machine logic and I'm also planning to use it for my NPC's collecting trash.
However, I was planning to place a smart object on a "cheater" gambler npc, so my staff AI can walk over to the cheater and interact with it. The problem is that the AI doesn't seem to care about me moving the smart object while playing. Is there a better way for me to do this? My idea was to use smart objects cause of their nice claim system to prevent multiple staff from trying to interact with the same cheater npc.
Lyra uses player state to store abilities and attributes for replication out of the box, im asking because I want to know if its worthwhile to build my own system
so i have a question about making an AI manager, I want AI to see and hear for themselves but I want the decision making to be done via a manager bp. what is the best way to do this? should the AI process its perception or should the AI report its perception for the manager to handle? im not super sure if the tradeoff is worth it or not and if it is has anyone tried something like this?
So, I essentially need to be able to move the smart object and the slot of the object itself
It’s mostly a question of encapsulation I think… both can be valid but if you want the manager to be higher level then processing the basic perception in the pawn would make sense
I think the processing in pawn has the advantage of allowing pawns control over how they implement it but other than that it probably doesn’t make that much of a difference
I hear alot of companies use managers for AI, and they apparently can be better on performance, but im not really sure what should be handled by the manager and what should be handled by the individual. do you perhaps have any insight on this? i thought of condensing ai perception to simple traces from a pool of known world pawns and then doing "perception" calculations based on dot product, distance, and blocking traces instead of true detection, and let the individual AI manage attacks and such but would it be better for the manager to handle the navigation calculations, detection levels, EQS and other things like this? I would like to have quite a few AI on screen, anywhere from 20 to 30 but since its a vr game I need to squeeze every bit of performance I can out of it.
Well the perception system itself is already timesliced which could be an advantage for performance
I would personally start with the perception handled in the pawns, and the pawn sending "higher level" information to the manager about it, as at least to me this feels more architecturally sound
The advantage of doing more in the manager would probably be the ability to potentially coordinate things better between different pawns but I think you would still be able to do that for the most part even if the perception events themselves are mostly handled within the pawn
Maybe try turning the SO or slot on/off... I know it works if you spawn/destroy SO's during gameplay, so maybe moving the actor just doesn't get tracked
i have a questions about State Tree
looks like Evaluators works like a Blackboard of the Behavior Tree, am i right?
and how to get information from the Evaluators in the another blueprints, like Task?
for a Behavior Tree we have a Get Blackboard node, but i dont see a "get evaluator" or something
Evaluators are more like services
The way you get values from evaluators into tasks is you use the binding mechanism
For example you set a value of some property in the evaluator, and then you bind one of the properties of a task to it
i think Global Tasks is like Services, its not?
and i dont see a way to bind something to Evaluator inside a ST Task, how to do it exactly?
Are you using BP or C++?
bp
I think this explains how to set it up https://docs.unrealengine.com/5.1/en-US/statetree-quick-start-guide
Check the section for "adding an evaluator"
the parts where it mentions adding the Output category on the variable and such should be it
no, its not 🥲
and i ask about, because its not
it says about Evaluator setup, but not about get or set Evaluator data from the Task
is there a simple-ish way to discourage AI from retreading the same paths as it roams around an area?
it's just one agent roaming around an area for ~5 minutes
I guess you could store a list of previous waypoints and use EQS to pick points to roam that are weighted to be away from the points previously used
I have a cooldown on my task
how do i make this cooldown to be random in range everytime
write a custom decorator or just check make the cooldown a property of the actor that can be checked in the task itself without using the decorator
how would that be done? Make a float inside the Pawn, then check time since last time and add?
🧠 ⚡
AI Perception Report Damage Event doesn't work on pawns?
I have tried adding to my player bp but seems like not working when debugged
also saw a forum saying should implement this in aic
make a float on the pawn and then when the cooldown gets reset make a timeline that decrements it or something like that
this works too
a Wait Blackboard Time
then have a variable in the BB
not the same thing
that is telling your blackboard to wait
vs. trying to activate the task and failing because the cooldown is still active
it might come out to the same place depending on your design but the difference is pretty important
like you had SEQUENCE(WAIT, USE SKILL, MOVE TO) and the cooldown was 60 seconds your unit would wait 60 seconds, use the skill, then move. if you had SEQUENCE(USE SKILL w/ COOLDOWN DECORATOR, MOVE TO) it would observe that the cooldown is active, fail to execute use skill, and not try to do the move to because it failed out of the sequence.
depending on your blackboard setup it might just rerout back into the the failing use skill sequence until it works though
ahhh
got it
yeah this is bad then
maybe need to implement some weird custom cooldown though cant figure it out yet
thanks though
Hello ! If i have a smartObject with a pending Gameplay Behavior
How can I finish the gameplay behavior externally?
Why do we have to set up things in a blackboard
why dont we just check on the AI Controller where we can store the variables, and change them
Is there a reason for using the blackboard instead of that?
Because you don't have to have an AIController in order to use the Behavior Tree
ahh
ok so else if you have an ai controller you dont need the BlackBoard variables
and these variables are limited
ex: no arrays
This is news to me. Don’t you need the brain component for it to work?
BTComp is a brain component. But there is no requirement that it be on an ai controller. None that I saw yesterday when I was poking around in it with siliex
It might get/cache the AI Controller when it gets added to an actor. But I didn't check what would happen if it failed to be on an ai controller. Let me check real quick.
Ig if you don’t need the perception system
Looks like this is the only place in the Brain Component that does anything with the ai controller.
So that property would just be nullptr
And the BT Component doesn't use it at all
Now - there may be some tasks that Epic wrote that have the expectation that it is on the ai controller mind you
(And I'm also not saying that you should avoid putting it on the ai controller!)
Haha ik, I was jw what you would use it with instead
I would also need to actually check the bt system to see if it has any ai controller assumptions
And whether or not the engine just assigns the AICon for you like they do when you use AIMoveTo
Why do you think you need to have many roaming NPCs across the map? Most games don't spawn them in until a player is nearby.
The last time I looked at the smart object system, it didn't support moving smart objects.
That type of manager increases the complexity without increasing the performance. I would not say that most games do that. I've used managers before, but not for that.
why can't I select "Both" ??
iirc selectors don't have the same options available so is the parent node that's just barely visible a selector?
might be another way of doing this
I might remember wrong but I've definitely also seen this on occasion
Because it's a sequence and not a selector.
Selector don't have the Both option here
The node type you have the decorator on is a sequence, which is why you can't select both.
BB Condition have, but not the cooldown.
That's a sequence
Sometimes you need to close the BT or readd the decorator.
didn;t work, even after restarting the engine
if the cooldown is NOT 0
doing it another way
I'm using the default moveto task in a behavior tree. My actor is a flying drone tho. So whenever I set gravity scale to 0 or default movement mode to flying it's not moving anymore and the BT is stuck at the moveto task. Do I need to implement a custom moveto task?
Just a heads up navmesh allows ground based movement only, so you need the capsule itself to be on the ground (if it’s a char)
If you’re looking for 3D movement you need to either implement your own, get some plugin or fake it by adjusting the mesh height within the character rather than its whole location
What's the fix for when you have an AI chasing a target actor around the level (main character) but can't find a valid path to the target actor anymore for a move to whenever the target actor is jumping or falling?
Nav link proxies presuming you mean they should be able to follow
No I don't mean nav links, that's for making my AI agent jump from A to B, I'm talking about whenever my character jumps, the AI loses its path to the character and so the BT sequence goes to the next one
I need to somehow keep a downward projection of my character's capsule to the navmesh just so that the AI can keep track whenever the character is jumping or falling a sort of large distance.
For example, the character is jumping across a series of pillars and the AI is in the pit below trying to follow along the ground underneath.
But whenever the character jumps from pillar to pillar the AI loses track of where the character is. Sometimes the jump from one pillar to another might be a large distance because the pillars are positioned one much lower than the other.
you could maybe cache the last location at jump, depending on how long the jump duration is
Can it normally navigate between pillars tho?
So the AI is never on the pillars in the first place, only the character is. The AI is on the ground trying its best to follow along wherever the player may go.
And it does, because it will temporarily lose track, then once the character lands it resumes but that brief moment causes the MoveTo on my BT to fail which rolls over to the next node in the sequence thus screwing everything else up because the nodes are in a very particular order.
Nevermind, I fixed the issue by adjusting my BT so it didn't get all screwed up when the tracking is briefly lost.
All good
Hi everyone, got a pathing question. I have a project with multiple NPCs of different actor classes and different AI controllers. They all have no trouble pathing around my map. I just created a new NPC actor along with a new controller and new behavior tree. I can see in the debugger that the behavior tree is running, but when this new NPC processes the MoveTo action, it turns toward the correct location but then does not move at all. The MoveTo action lasts a little while, like its trying to get there; it doesn't fail immediately (like I've seen it do if the location wasn't reachable).
Any ideas what could be wrong here? I checked things like movement replication (I am running on dedicated server). The other NPCs don't have troubles pathing on the navmesh. I'm not aware of debug tools for MoveTo.
Anyone playing with StateTree in 5.3.2? I have this simple test setup. This works fine, but when it gets to the Wait task it seems to call the EnterState function every single tick instead of calling EnterState once, then moving to Tick event. This means I can't properly use the FinishTask function to complete the state.
I have also had this issue, state trees are unusable at the moment in 5.3.2 because of that unfortunately 🙁. hoping 5.4 will fix it
Oh so this is indeed a bug? I was going to dig into the source code but that's a huge time sink so I was sort of hoping I was doing something wrong
I believe so, the finish task function to my knowledge has gone through quite a few iterations since state trees introduction, and most of them have been borked lol. its a shame cuz state trees are so powerful 
I MUCH prefer the workflow of state tree over behavior tree. I've been trying to adopt ST since it came out but every time I sit down to do something I hit walls like this lol
same, i like how they are MUCH less spammy, and easier to flow between states over BT's lol. but same the walls are never ending, suppose its still in beta but hopefully it will be prod ready soon
I thought I read that ST was ready in 5.3, that's kinda why I was going to dig back in. I will never emotionally recover from this
Oh maybe it is, i vaguely remember seeing beta when I enabled it last, but I just checked and still have that same issue with the finish task function lol
Well...I guess moving it out of beta means it now has the same status as the rest of the Unreal systems - buggy and unfinished 🙂
You could increase the default projection in Z. You could not go directly to the character and use the EQS instead. You could do fallback behavior. Lots of possibilities.
That entirely depends on what is failing. Is it the projection? Then you need to increase the default extent in Z. Is it not finding a path? Is it not moving? I recommend actually debugging it using the visual logger.
Use the visual logger to debug. It's under tools/debugging
Is this the correct value for the down projection? (highlighted)
So I'd use some large value like say 10? I tried but didnt notice any changes.
No. You need to set up a supported agent setting in the project settings
So more along the lines of something like this?
and then what's the 2nd part where I connect the TestAgent into an existing character? where does that happen
Because it makes it more alive
It does absolutely nothing if the player can't witness it.
It does a huge deal to immersion
Seeing flocks moving across swathes of land
The landscape is like africa, alot will be visible from afar
Nevermind I ended up sticking with the work around fix with my BT and won't bother with the Z height projection thing.
I m trying to move characters but its not moving when printing the movement result its printing success
theres nav mesh too
im trying to move the black ones to the red point
and theres a door in between and navmesh is not breaking
this is the spawn code for ai
when i put the ai class in the level instead of spawning it works the character runs to the point
but its not working when i spawn them
The problem with that is, that it is then using the capsule (or the arrow?) to do ai sense sight, but I want ai sense sight to use the drone mesh as a "starting" point. I tried setting capsule to nocollision and adding a new sphere collision, but that doesn't work. How does ai sense sight determine the starting point?
When I set gravity scale to 0 or movement mode to flying it goes haywire here, never continuing to the right of moveto. Not sure how to debug further?
Have you tried using the visual logger like I said?
I thought that is the ai logger I have open in the screenshot. Sounds like it is something else?
In your NPC character the controller spawn rules needs to be "placed in world or spawned"
Google the visual logger.
It says it can't find a path to the target.
No failed to project?
No, just LogAINavigation (Error) Trying to find path to BP_Rover_Nanite_C_0 resulted in Error
wt?
So if I scale up the capsule it will also move ai sense sight up, which is good. But scaling the capsule also scales my mesh as it is parented to it. Can I then scale down the mesh accordingly or does that mess other things up?
Scaling it just for that reason id prly not ideal. Iirc the origin point can be adjusted to eyes height for example but you need cpp to do it
Luthage would know
Spawning multiple AI in the world seams to bug. It works fine on a single AI, is the behavior tree the reason?
Bug how?
Like the sensing gets all messed up and they get confused.
That sounds like a problem in your sensing logic
Maybe they're sensing the other AI's when they're not supposed to?
In the AIPerception component?
Yeah
I should have AIPerception on the controller right? Or is it better on the AI character?
Controller is correct yeah
The idea being that the pawn itself could be used by player or AI, where the player wouldn't need the perception component at all so it's better to be on the controller
Ahh makes sense
If they could detect other AI, wouldn't the AI need an AIPerceptionStimulas? Because only the player has one.
No. All pawns get registered as stimuli sources by default
Oh wow
You can turn it off via changing a config thing https://zomgmoz.tv/unreal/AI-Perception/AISense-Sight#turning-off-pawn-autoregistration
Oh wow that has to be the issue, almost backed up
Which is stupid if you ask me. It makes AIPerceptionStimulas useless
Yeah not sure why it's set up the way it is
Wow man now they all run at me, thank you so much it seams to have fixed it. I would of never have worked that out!
np :)
can anyone tell me what this means
There is a setting on pawns, called auto possess by AI or something like that
That's what Luthage is referencing
probably a stupid question, but can someone tell me why trying to get the stimulus class here wouldn't work ? it will double up on me for sight and hearing ... every time it senses sight it works fine, every time it senses hearing it will ALSO sense sight..even behind the pawn/behind walls ect.
You are looping through the current perception data
You get a list of the last stimuli for all senses if you use Get Actors Perception
I would suggest using On Actor Perception Updated or whatever the other event was - that one will give you only the most recently updated stimulus value instead of the updated actors array
ah thanks m8, that seems to work fine 👍
AI Perception Report Damage Event doesn’t work on pawns?
the sound and the sight sense works perfectly
but when tried to implement report damage event and if i click the "H" key, it doesnt create a sphere trace!
enemy base [only one enemy is there so getting it]
player BP
unreal 5.3
Hello! I have a question which might be very off-mark, since I'm not very comfortable with AI in Unreal, but now I'm forced to learn it -- any pointers in the right direction are appreciated.
We have a dialogue/scene system which enables Pawns to participate in graph-based dialogue, which play automatically. Now I'd like to extend this system with the ability to request simple AI behaviors from the Pawns. For instance, a dialogue scene might involve the Pawn moving to a lever and pulling it; or moving to a specific location and pointing in a direction. These are kind of fire-and-forget actions. Most of them will probably be something like "path to X and play this animation montage." Is there an appropriate subject I should research to achieve this?
I'm side-eying the "MoveTo" node because it's similar to what we want -- just a simple action that can be invoked without messing around with Blackboards and Behaviour Trees. I'm not uncomfortable with BT+BB, but it feels a little overkill for simple actions. But perhaps it's the best/only way to do AI?
I think part of my confusion is the AI Behaviors plugin. Its description "Encapsulated fire-and-forget behaviors for AI agents" seems perfect, but I'm having difficulties finding info about how it's used, due to the generic name.
I guess maybe the Move To and Use Smart Object with Gameplay Behavior node is what I'm looking for huh
Yeah it sorta depends. Smart Objects can be used for something like this I suppose, and the AI behaviors plugin is only really used by that for the gameplay behavior bits
It seems it would be relatively straightforward to just invoke the logic on the pawn via using a custom AITask for example also.
Yes, I think I'll take a look at the AITask logic and see if I can figure it out -- otherwise I guess the abovementioned node probably will suffice for our cases.
So, I've got a bit of a complicated and potentially unrelated question. If this belongs somewhere else, please let me know and I'll move it:
Basically, I'm wondering if anyone knows how exactly the Navmesh is actually generated? I'm looking to potentially do something similar for a system that generates "Climbing points" that players can use to climb from ledge to ledge, and I've been trying to use the Navmesh itself as a basis. But I haven't been able to find any good examples online or in the C++ code of how the Navmesh itself is actually generated. How does it figure out if a surface is flat so efficiently? How does it know when it's reaching the edge of a flat surface? Does anyone know where I can find this information?
Not sure if it's documented anywhere, you would need to look at the sourcecode
What is the cons of not using the PerceptionComponent on a Controller? I put mine on a Pawn.
I implemented the interface to handle perception in EQS and Sense but I have a warning telling me i could have API issues.
No cons if your pawns are only used by AI
If it's used by a player also then the component is kind of useless on it
But besides that, no difference. It might get the API deprecated in the future so it has to be on a controller, but who knows
The thing is having it on pawn allow us to specify Perception Configuration directly on each pawn.
But If i put the perception component on controller : I guess, i need a distinct controller per AI for the same result right?
Thanks for your answer!
Yeah you'd need a controller per configuration
Or I suppose you could add some logic to configure it based on settings on the pawn
I have a nav mesh that looks like this. It works great, but sometimes if the AI rounds the corner (from the top right of the image to the "bridge") too fast it flies off the edge (on the left side of the bridge). Should I account for this in the nav mesh or the behaviour tree or... somewhere else entirely? (I can't really alter the movement speed of the AI since it is intended to match the player.)
Recast navigation generator (or something like that) is an engine class that handles the generation. Recast voxelizes the world to determine surfaces. I would recommend hooking into the generation after it finishes to do traversal markup. You get a lot of data like edges that can be used.
Hey, did you find a solution to this?
There are things, especially the team stuff, that the perception component assumes it is on a controller and not a pawn. Also putting logic on the AI controller makes more sense from an organization standpoint
Guys how i can make pawn to use NavMesh ?
We use a data asset to define the perception settings. It's not difficult to hook up.
I did! I made an override actor rotation by comparing the actors current rotation and its control rotation and interpolated to the control rotation using a curve. it still technically happens but its much less noticable since the rotation is smoothed out, similarly to how ALS does it with Velocity and aiming rotation
I recommend going through the AI with Blueprints course on the learning library. It will go over all the basics.
Does that just smooth out the rotation or the actual walk path? Wont the walk path still be linear?
Thank you so much! This sounds like the lead I've been looking for
The rotation rate in the movement component.
so they still technically walk linearly, but their rotation compliments their path, so if your path looked like the green, it would inevitably turn out like the red
😮 oh shit nice
I tried that but unfortunately walking around corners still makes the AI jitter from left to right lol
This is entirely unnecessary as the movement component already has this functionality.
Yeah the rotation rate in the movement component just handles the actual rotation on it's axis, it doesn't affect its pathing at all.
Where? It is not rotation rate.
If you put the rotation rate all the way down to 1, you will have a super super slow rotate, but your AI pathing will still be linear and still Move Point to Point direct.
It is the rotation rate. It literally does what ToasterMuffin did. Just in a more elegant way.
Neither does what ToasterMuffin did.
But there is an interface IGenericTeamAgentInterface that i can also implement on pawn for that if i'm right
The DataAsset is an interesting approach, i'll try to take a look to that
Thanks for your advices
it definitely is a little different. rotation rate will make the AI turn very slow but it will still path to a T, which in some cases produces the jitter. mine has the character movemnt applied to the forward vector not the control rotation, so walking is smoother. its also multiplied by a rotation curve so the bigger the rotation difference from forward vector to control rotation the faster the pawn turns and will eventually settle once the rotations get closer
not saying youre wrong, but i can never get rotation rate to produce the same results 
This is advanced, optimized and easy to setup component-based system that would let you to achieve more AAA quality aspects of your games - makes AI moving on navmeshes a lot more smooth and natural without forcing any rotation/movement limitations to your Character (or Pawn) and with no any compromises on performance side (at least on modern mi...
This is kinda what me and toaster are trying to achieve.
If you want the path to be affected (which I don't recommend) you can make changes to the string pulling functionality. In most cases you don't actually need to do this, because the problem is better solved by intelligent location selection and animation.
Location selection doesn't matter when all AI will (by default for what UE provides) a linear point to point pathing.
If you want to use a curve, the rotation rate functionality is overrideable. The problem with your solution is that it affects all rotation not just during moving.
It actually does make a huge difference, based on my experience
idk, for me it literally makes 0 difference, this is with a super low rotation rate, the AI pathing is still linear.
so i dont really use curves like that persay, the rotation rate is affected by a curve so its completely natural additive to the pathing of the AI, but its also not so harsh to the point it will make an AI miss its location target. i guess while it does smooth out the jitter its more for using a cubic interpolation over a constant or linear like rotation rate.
Yeah im trying to get true cubic interpolation of the pathing, so that it goes around corners more natural.
have no problems with the actual rotation of the character
That plugin has decent results but it's limited (eg continous tracking) to the AI movement options you can do, and it's quite dated, author isn't fixing things XD
it does automatic spline movements without the need to pre-place your splines.
what's the problem when the BT is flickering crazy like that? I'm using that movement speed task in the other trees as well and it works. VisLog shows no error.
Your BT is repeatedly entering the same branch over and over again
Most likely as a result of the task node failing, which is then resetting the BT back to the start due to how you've structured it
Set movement speed should be a service not a task. A service has the ability to do something when entering and exiting that part of the tree. Doing it as a task means that you need to use a sequence instead of a selector and it's not guaranteed to unset.
The reason for the flickering is because it's always succeeding the first task.
Ah true, it's a selector so it would be succeeding and not failing
ah, so the second one is failing?
Thanks, I'll look into services. I'm following a tutorial which does it like that.
It's a SELECTOR which means it'll try tasks until the first one succeeds. A SEQUENCE does all the tasks until the first one fails.
I highly recommend doing the AI with Blueprints course on the learning library instead of using random tutorials. You should really try to understand the systems instead of following along to really bad advice.
I'll check that course out. For now I'd like to understand what's going on. What is failing here now? I can't find a problem with both tasks
my characters only apply rotation if they have movement velocity and are on the ground, otherwise the rotation can be overridden, but its still relatively linear, its just a bit more smooth and inertial. they just dont jitter around if they get caught fighting a corner or something lol
a little bit of anim work goes a long way into hiding some of that jank too
Okay i see, so there is a little misunderstanding, I have that solved with various stuff (avoidance, agent radiuses, and rotation rates with velocity), but yeah I'm looking for something a bit nicer.
I already said it's because you are using a SELECTOR. It's executing the set move speed, returning success and then going back to the root. Because that's how selectors work. The course I recommended will go over that.
uh oh, I see the problem now, sorry!
I checked out the matrix demo a while back and they have a new crowd system which might be a nice way to get around my issues
Thanks for the help
ah i see now, I think i misunderstood then haha
You can see in your video they all hug the walls, because it's the shortest path
Until a point to point happens that moves them away, such as 2 corners, but it would be diagonally set from A > B for the shortest path.
If you were to increase your AI count a bit, and view top down and sped up, you'll see they will always follow the exact same paths and eventualy look like they're walking in a single file line 😄
This demonstrates the problem with UE5's basic Move To pathing, it'll always, by nature of how short pathing works, have point to point pathing at the corners
And having AI move away from these lines will be rare, or not happen at all, without a bunch more work on
And you can be smart, or try use variance logic, so trying to figure out ways to get a more natural, spread out, and smoother walk rotation.
I built this no-spline, spline-like navigation system today after fumbling around with spline points trying to get what I want. This is part of my Stage Left system for NPC staging and blocking in Unreal, so it's using the same "smart" perform point data - meaning the NPC can stop at a point and perform any number of actions, trigger events, and...
This is nice, but it isn't available and it's between points not for "random point in nav"
You could in theory adjust how the path is generated but ugh the code to do all the path points is so complicated lol
Yeahhh
The MassAI does solve a lot of this, but it has other limitations, and isn't applicable in some places.
Found it, it's specifically "RecastNavMeshGenerator"
Guys is it even worth to use Pawn than character for AI ?
I was wondering what is better in terms of performance if you have large groups of mobs
Well pawn can be used for non-character AI's
Character Movement Component is a resource hog so replacing it could be beneficial if you need to have a lot of humanoid type NPC's
How would I let all AI controllers know something happened inside a single AI character bp? Would I have to use GetAllActorsOfClass or is there a better way?
Basically when my zombies kill me, the one that actually killed me loses sense of me. But the others don't.
If you AI has movement (like a character) you'd be a fool to go one class lower (pawn < character) to then have to create all the functionality for the character, when it is already built in for the character. Pawns are for things like vehicles, for characters use a character. Just add an AI controller.
A pawn is something you posses and a character is one class above a pawn so it's technically a pawn also, but with added character movement ability etc.
It's like this:
- Actor: Something in the world
- Pawn: Something in the world that can be possessed by a player
- Character: Something in the world that can be possessed by a player and has character movement capability
You could unregister the actor from the stimulus system. I don't recall if this is available in BP's though - if that's an issue, you could have an event dispatcher on the player pawn which is triggered when the player is killed. The NPCs can assign a listener to the event, and then react appropriately
Ahh thank you I will look into this
That entirely depends on how well you write the replacement. A badly optimized BP version could easily be worse.
Oh yeah for sure
Does anyone happen to have a recommendation for an AI plugin that I can adopt and hook into the Gameplay Ability System pretty easy? I have been making my AI in State Tree but there are a number of blocking bugs Epic needs to work out. I'm going to pause my State Tree AI development until the bugs are worked out but I need some basic AI to slap into my project to continue some basic testing. I really don't want to go through and rebuild everything in Behavior Tree so I'm just looking for an easy, temporary solution to pop in.
What are you imagining it does
Is there any way to move the AI Perception origin up to "eye level" of my drone?
Bugs like what? I've been using the state tree and it's pretty stable. I'm not really sure what the plugin you're looking for would do, a different AI system would require you to rebuild in that system, just like moving to BT's would require rebuilding in BT's
There is a setting for eye height or head height or something like that on characters or something like this somewhere which can be used to adjust it
Just tried that. For some reason it breaks EQS pathfinding. Whenever I change capsule half height, EQS returns no valid points anymore.
All the points are blue then. It only works with default capsule half height.
You shouldn't need to adjust capsule height, the eye height is a separate setting
Adjusting capsule height could potentially be affecting whether the EQS points are clipping into terrain or something like that which could cause issues with the path check
Have a problem my Behavior tree is runing but my AI dont want to move
got it, thanks. the setting is not on the capsule, it's on the root and called 'base eye height'
the hearing circle is still on the ground, but maybe that doesn't matter
hi, i just started playing with AI for the first time and began playing with sight perception first. i immediately noticed that there was issues, as in my AI is only capable of seeing my players pelvis and nothing else. i started looking for settings to adjust to fix this but there were none. then i started looking for answers online only to figure out i apparently need to extend the character class with C++. i wouldnt mind doing this if its the best option for me, but i cant help but notice discussions from people about avoiding this entirely and building a sight system from scratch.
i have some ideas of how to do it and thats not a problem (yet), but my question is, should i? will i be shooting myself in the foot in the long run? i plan on having a very large quantity of AI at any given moment, so performance matters, but flexibility and control also really matter, realism is the goal
Yeah by default the sight checks against the origin of the character. You can change it by using IAISightTargetInterface which as you discovered is C++ only
It's quite easy to do though, so unless you have some particular reason to avoid C++, it shouldn't be an issue I think
You certainly can build your own if you want, there isn't really anything in the engine that would require you to use the perception system for something else to work
That's kinda what I was afraid of. Right now I'm having an issue where State Tree Tasks are firing the EnterState, then completing immediately without calling FinishTask. The tick function never runs and EnterState is just called over and over again. This is on 5.3.2
Do you happen to have multiple tasks in the state?
Only one in this state, which is just a custom Wait task
Hmm, sounds kinda odd yeah. I haven't seen that, it works just fine and it won't end the state until the task actually calls finish
Do note that if a task lower in the state tree branch finishes, this can also trigger the child states to exit
I made this for testing purposes essentially. I admitedly don't fully understand State Tree but I believe I am doing what I'm supposed to be doing. The enter Function is called over and over while the Tick function is never called
The result is that it keeps making a new TargetTime and tick never has a chance to check if the time has elapsed or not
Does the EQS Query task call Finish?
It does
That's the problem then. It causes the PatrolRandom state to finish
I think... sometimes it's a bit confusing lol
Oooooooooooooooooooooooooooooo man....Okay
In general, the pattern I've found useful is that tasks which get or load data should not finish
since that avoids the state from transitioning
So, EQS queries are async. How do I tell it to move on to the child state when the query is finished?
I've not found a good solution to that. Due to how the state tree node selection works, it will always attempt to enter the child
It might be possible to set up a "wait" state as the first child, where you have another task which checks whether the data from the parent state's task is available or not
and it would only transition into the next state (which would be the actual logic) once the data from the parent has become available
but I've not tried this - my solution was to simply make a task which did both the query and the other logic in one
Oh so you have a task that queries and performs a MoveTo?
Instead of having the EQS finish, I could try just publishing a bool and slapping a bool condition on the child perhaps. It might just keep looping until the bool was set. Then I can just switch FinishTask to only be called if there is a failure maybe
I didnt realize the parent success dumped the entire state branch, I thought it only mattered the state you were currently in
conditions are also a bit tricky because in order for the tasks to run, it has to find a leaf that it can enter
Something like this https://zomgmoz.tv/unreal/State-Tree/StateTree-design
@misty wharf Have you had your bindings randomly stop working in ST? That was what finally broke it for me back in 5.1. Just not being able to select any bindings in the editor (like, from the previous task)
I always had to fix it by recreating the ST and hoping it would work
The only issue I had with bindings was that it seems binding to sub properties eg. a.b doesn't seem to work, or at least it causes a nag in the UI about it
But that was ~reasonably easy to work around
But I only used ST's since 5.3 so not sure maybe it's an older issue that got fixed
Oh man, I'm bookmarking this site. Thanks for posting. I can leave an open leaf in the branch so it has somewhere to go that can force a loop I guess. Seems a little messy to me so perhaps it's not the best solution. I will have to play with a few things now that I know a little more
How do i stop behaviour tree when character dies?
GetBrainComponent()->StopLogic("Died");
i tried that but don`t work
Instead of doing the enter conditions I put a event transition in the parent of the branch and routed it to the moveto once the EQS completes. Seems to be working fine from what I can tell
Hmm, that's interesting 🤔
I'm reasonably sure it would still attempt to enter one of the leaf states, but I suppose it could enter it, and then re-enter after the query finishes and it works
Currnetly the MoveTo is not being called before EQS returns. Perhaps EQS is just returning fast enough that it can't move on in time. I will try adding a delay to EQS to test it
Ohhhh wait
I have the parent set to Try Enter
I'm pretty sure I read that this treats the parent like a Leaf
Ah, that would be useful if that's how it works. I haven't really looked at that part so much yet
I'm just now diving back into all this as ST was a hot mess in 5.1
But I can work with this
Events are honestly better for me because I can get more granular in my transitions later
One more quick question. Have you run into this in StateTree? I'm trying to bind this float, but it says the source type "" doesn't match "Float". I'm attempting to bind to a float
Yeah, that's the binding issue I mentioned where you can't bind to sub properties. Try if it works, I recall someone said it still worked despite the nag, it never occurred to me to just ignore it
(The sub property binding seems to only work without the nag on the Context actor)
Sometimes this does work. Doesn't seem to be working in this instance for some reason. I can expose the float in the global task and see if that works
Yeah it will work as long as you're not doing nested.property
Okay got it, thanks 🙂
Has anyone tried ConvAI or any other plugins for UE that allows players to talk with NPCs, ask them to do things, load up NPCs database about world, set up personality and stuff? I'm looking at ConvAI right now and thinking about using it for a single player action/rpg game. Their videos in youtube look cool but I'm concerned how configurable the ConvAI actually is for the gameplay, how well does it integrate with BTs, EQS, perception and stuff, and how performance-heavy it is. So can you guys suggest me alternatives/similar solutions like ConvAI or maybe share your experience with those kinds of plugins like does it even worth to get into that right now or is the current state of those things is only proof of concept?
Guys how to have focus on the target for ai all the time even when moving ?
So i just need to set focus in task for example and execute this along moving ?
You call it once, and then call ClearFocus whenever you need to unfocus.
Making your own perception functionality has a high probability of being far less performant. Especially if you do it in BP.
hi everyone ! I'm trying to spawn AI in mid air in flying mode and have it fly up, but my MoveTo node returns Fail all the time, any idea where this might be coming from ? They do spawn inside a Nav Volume, I set the movement mode to Flying right after spawning.
There is a built-in service that will set the focus.
Navigation is on the ground, not 3d.
So no Flying Mode for AI ? Only for players ?
I remember I had to hack the thing and use a Projectile system spawning my ai, homing to different positions, that was like a year ago
There is no 3d navigation in the engine. A cheap way to get around that is to hover an offset from the ground.
Is there a vertical navigation system ? Basically my AI climbs walls
No
Ah ! I'll hack my way through it then, thank you ! I'll try spawning with a gravity of -1 and work from there
I've got a question regarding focus. For my "flying" drone this doesn't work 100%, because I want the drone to look down on the actor.
I tried playing around with setting the rotation on the drone mesh, but set focus is overwriting that.
Would that mean that I have to implement my own set focus task which does both?
When I did flying drones, I used a Find Look At Rotation in the drone actor BP
Never used Set Focus tho, sure sure what it does, but I didn't need it
Yea, that's what I played around with as well. What kind of event did you use so that it constantly updates? I can only think of Event Tick, but dunno if that's ideal.
Anyone using State Tree with GAS? I need to figure out a good method of detecting when an ability called by tag has ended so I can progress the State Tree
Right now I'm sending an event whenever an ability ends with a tag name and I'm just detecting that tag name. I can't really use this in all scenarios though, so I was looking for a more robust solution
For characters the set focus only works in yaw rotation by default.
It's the same regardless of using a state tree or a BT. You have to bind to the delegate for when the ability ends.
Just want to bump this once in case anyone has thoughts on how to prevent AI from overshooting nav mesh when using acceleration (possibly without using invisible pieces of geo)?
Hey hey all, I've got a question regarding EQS. I'm using a Dot test to grade results which are in front of the player higher than the ones behind.
-
When I use an actor as the rotation context I get the result seen on img 1, as intended. The results behind the actor are scored lower.
-
When I use a vector (the location of the previously used actor) as the rotation context I get the result from img 2. The grading is all over the place.
Could anyone explain to me how or why these results are different?
If I remember well, I did use tick because I didn't have so many drones spawning. But right now for a Turret I'm using the Pawn Sensing in combination with the Animation Blueprint, so when it sees something, I'm using the Look At node in anim bp to rotate a specific bone and aim at a target.
My new option seems better, because you can setup how often the Pawn Sensing triggers and sees something. But, with the Look At in the Animation Blueprint, there's an option to smooth the rotation and even choose how you want your smoothing curve to be (linear, ease,etc)
And for those curious, this is how I setup my AI, works perfectly ! I'm basically spawning on a Spline start point, then using a Timeline to set the location of my ennemy AI to follow the Spline (using the distance info). When it arrives at the last point, it's free and moves around. You can even get the spline up vector to rotate your actor accordingly.
I really don't see a way to stop this other than reducing the max speed of the player and NPC. Path following is not at all tied to max speed.
Thank you for the sanity check, I might just throw up some invisible blockers (or hand fix nav mesh in bad areas).
This is because you need a ROTATION and feeding it a LOCATION. Those are 2 different things.
Thanks for your reply, I wrongfully assumed a vector would have a rotational value as well then :')
Is there any chance you would know if it's possible to get a rotation as EQS context in blueprint? Or is it time I dive into C++ to get what I want
I believe if you send it the forward vector as a context it should work. Some vectors, like the forward vector, has rotation in it. Location does not.
I think you can also provide a rotation in a context as well.
Hey guys! Maybe someone can point in direction where I can look, what I'm trying to create is a sandbox game where you can build structures and you have monsters that attack them. Something similar to Fortnite Save The World. What I struggle with is that how AI should target structures considering that player can build fortifications for the "core". I've been trying to find out any technical details on how AI works in Fortnite STW but no luck so far and I can't even find something close to AI for sandbox games where you can build shelters etc so how AI should react to that, maybe someone have seen some info on that?
Start simple, why not have it attack whatever's in front of it in a straight line?
yeah thats sort of what im worried about. i started playing around with a simple idea in BP just to give it a shot, but im gonna scrap it and try to extend the existing sight perception system in C++. i need the sight perception attached to the AI's head so they can turn to look at something when hearing perception is triggered, then i need the AI to be able to see the player's head, pelvis or feet (i use 2 traces for feet in my test but i could just use the root location instead) in that order. if the head is visible, the rest doesnt need to be checked
so uhh i gotta start playing with all that and figure it out. ive done a lot of object-oriented programming, but not C++ specifically. its time i learn
Perception isn't attached to anything. It's literally just overriding a function or doing math to figure out the eye height.
i guess my wording isnt the best, but i saw someone show how to attach the sight (cone? not really a cone) to the AI's head
I use a socket on the mesh and override the function to get the pawn's viewpoint.
yeah i think thats what they were doing
It's not attaching anything. The perception component isn't a scene component that can be attached. It's just changing the logic of how it gets the view location and rotation to be a socket instead of the default.
i followed this guide word to word
yet my state tree is not working
I feel state tree is not working on that actor
alright, trying this again, im having an issue overriding CanBeSeenFrom on my characters
in my header file:
virtual UAISense_Sight::EVisibilityResult CanBeSeenFrom(const FCanBeSeenFromContext& Context, FVector& OutSeenLocation, int32& OutNumberOfLoSChecksPerformed, int32& OutNumberOfAsyncLosCheckRequested, float& OutSightStrength, int32* UserData = nullptr, const FOnPendingVisibilityQueryProcessedDelegate* Delegate = nullptr) override;
in my .cpp file:
UAISense_Sight::EVisibilityResult ACLM_Character::CanBeSeenFrom(const FCanBeSeenFromContext& Context, FVector& OutSeenLocation, int32& OutNumberOfLoSChecksPerformed, int32& OutNumberOfAsyncLosCheckRequested, float& OutSightStrength, int32* UserData, const FOnPendingVisibilityQueryProcessedDelegate* Delegate)
{
if (GEngine)
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT("This is the pre-set text"));
return UAISense_Sight::EVisibilityResult();
}
my AI has this character class, i set up a test screen print on the begin play function, that works perfectly fine, everything works perfectly fine except for this function specifically. its not being called. AI sight perception is setup on the AI as well, thats all working perfectly fine and the player is being detected, but the overridden function is still not being called. idk what im missing
any help would be appreciated
🤔
It seems that's all you should need to do unless they changed something
Note that if the target isn't within the sight cone that function is not going to get called to begin with
thats why im so confused
i can debug the perception system, im being detected
but that function is not being called
You are on UE 5.2 or later right?
5.3
Hm yeah, just checking since that overload was introduced in 5.2 I think
it looks like they still use the function from 5.2, just within the new function
And you do have the interface set as a parent class for your class?
unless im wrong
like this?
Yeah
yes i do, anything that would create build errors has been done
No idea why that wouldn't be working 🤔 Maybe try breakpointing the code in UAISense_Sight which is calling this to check what's going on?
how would i do that?
it should be in AISense_Sight.cpp line 539 or so where that gets called
just open the file in your IDE and set a breakpoint into the function
that's fine, for breakpoints it doesn't matter
i attached and ran the level with the breakpoint set
i get this
Try installing the engine debug symbols from the epic launcher
It still might not give you the exact line, but it should at least break somewhere in the vicinity - you might need to try to breakpoint the first line of the function instead of the specific line also
this might sound a bit silly, but when i installed 5.3, it never finished
every time it would finish, it would say resume
and when that would finish, it would say it again
it would just verify
in a loop
so i actually cant really do anything with my install
removing it says it'll uninstall it
its stuck here
forever
im not really sure what to do about it
i mean reinstalling would probably work
Yeah I would try reinstalling, not sure what else you could do
i havent had any issues with the engine because of this except for 1 thing (might be unrelated but idk)
i cant set materials to translucent
lol
it crashes every time i try
That sounds kinda weird especially if it's in a new project
Seems you should try to do the reinstall, you won't be able to install the engine components like the debug symbols without that either I guess
80gb for the debug symbols ?? oh man
I think there's some components that get installed by default like android support or something which you can uninstall to get some space back
Either way the debug symbols are almost must have if you do any C++ stuff because without them figuring out stack traces can be pretty hard
btw i remove the engine version and immediately canceled the uninstall
then redownloaded to the same location
so it can run a proper verify
and it installed some small missing pieces
now i can set materials to translucent
finally got it all
i debugged again with the breakpoint not showing the warning this time
but nothing happens
Try adding a breakpoint on top of the function instead of that specific line
It should at least enter the function I think
alright it hit as soon as i clicked play
on this line at least
if thats what you were implying
ok this is why it wasnt hitting
its hitting the else
they're doing a custom trace test? ignoring CanBeSeenFrom entirely?
because Target.SightTargetInterface is null
That would seem to suggest that whatever it is detecting doesn't implement the interface
If the level you're testing with has any other pawns besides the one you want to be detected, maybe delete the others just to make it simpler
If it still does this, it kinda sounds like maybe your pawn class isn't actually extending your C++ class?
damn, so thats what i was missing, i only gave the class to the AI and not the player pawn...
finally 😭
that was as dumb of a solution as i thought it would be
but thank you very much for the help
it only took many many hours and 80 gigs of debug symbols to realize im just an idiot
yes that will be very useful
thank you for recommending
ive got this working now
i also did the GetActorEyesViewPoint override so that the AI's vision follows the head location and rotation
and the plan is to use hearing sense to get the AI to look in a direction and notice the player (or another AI)
UAISense_Sight::EVisibilityResult ACLM_Character::CanBeSeenFrom(const FCanBeSeenFromContext& Context, FVector& OutSeenLocation, int32& OutNumberOfLoSChecksPerformed, int32& OutNumberOfAsyncLosCheckRequested, float& OutSightStrength, int32* UserData, const FOnPendingVisibilityQueryProcessedDelegate* Delegate)
{
FHitResult HitResult;
FVector SightTargetLocations[3] = {
GetMesh()->GetSocketLocation("head"),
GetMesh()->GetSocketLocation("pelvis"),
GetMesh()->GetSocketLocation("root")
};
for (int i = 0; i < 3; ++i)
{
if (!GetWorld()->LineTraceSingleByChannel(HitResult, Context.ObserverLocation, SightTargetLocations[i], GET_AI_CONFIG_VAR(DefaultSightCollisionChannel), FCollisionQueryParams(FName(TEXT("TestPawnLineOfSight" + i)), false, Context.IgnoreActor)))
{
OutSeenLocation = SightTargetLocations[i];
OutSightStrength = 1;
return UAISense_Sight::EVisibilityResult::Visible;
}
}
OutSightStrength = 0;
return UAISense_Sight::EVisibilityResult::NotVisible;
}
this is what i ended with
i could trace hands and feet but im kinda worried about performance and it doesnt feel necessary
as long as each major portion of the body can be visible to AI
maybe something to add to this could be utilizing sight strength? im not sure exactly how it works or how to use it yet but i imagine if the players feet were the only thing visible, its less likely for the AI to notice them, but still possible
Yeah I don't think the strength is used internally for anything so it's up to how you want to implement it
btw you can use this GET_AI_CONFIG_VAR(DefaultSightCollisionChannel);
yeah if i think of a reason in the future then ill come back to this and add scores per bone
it returns the sight collision channel configured in project settings
so you don't need to hardcode the channel
Hi! I'm testing statetree again and i kinda don't understand what those logs mean:
LogStateTree: Error: BP_LostSoulController_C_0: FStateTreeExecutionContext::SelectStateInternal: Reached max execution depth when trying to select state Print from 'Reset Look at point:Succeeded'. 'BP_LostSoulController_C_0' using StateTree 'StateTree /Game/DesignData/AI/LostSoul/StateTreeData/ST_LostSoul.ST_LostSoul'.
LogStateTree: Error: BP_LostSoulController_C_0: FStateTreeExecutionContext::SelectStateInternal: Reached max execution depth when trying to select state Await Results from 'Reset Look at point:Succeeded'. 'BP_LostSoulController_C_0' using StateTree 'StateTree /Game/DesignData/AI/LostSoul/StateTreeData/ST_LostSoul.ST_LostSoul'.
LogStateTree: Error: BP_LostSoulController_C_0: FStateTreeExecutionContext::SelectStateInternal: Reached max execution depth when trying to select state Get Random Location To Patrol from 'Reset Look at point:Succeeded'. 'BP_LostSoulController_C_0' using StateTree 'StateTree /Game/DesignData/AI/LostSoul/StateTreeData/ST_LostSoul.ST_LostSoul'.
What is an execution depth? How do I avoid reaching the max?
Is it that i have a big hierarchy of leaves? I like to group stuff and make lots of nested States....but i thought it was allowed
Hey @proven flint
Effectively, you can only have a depth of 8 (including Root I guess)
Which means you have 8 states that got executed in parallel
Try to increase the amount if you want or be sure to have less than 8
Hi i am currently working on a couch coop local multi game .. i have 2 player character and i work on the ai.. I noticed, that the ai only sensing one of my caracter.. i looked in the behaivour three and noticed that the Focus node uses get player character 0 .. but i cant figure out how to use both 0 and 1 for the ai to sense both ..
Heres a screenshot how i use the focus node.. i already tried to add a sequence and duplicate so on the first run it uses get player character 0 and tha 1 but it doesnt really worrk ..
i wonder if anybody has any experience working with 2 sensable player character? how can io make the ai to be able to notice both..
the funny thing that the ai turn and shoot to player character 0 .. and it also shoots to player character 1 but it doesnt turn after it..
heres a screenshot from the behavior tree i am using its quite simple since i am really new to all of this..
You need to find a target (I prefer using perception + EQS) and set that target in the blackboard. Right now you are hard coding it to only use character 0.
I do not recommend setting focus in a task, because you can't reliably unset it. There is a built in service for setting focus that you can use.
Thank You for your answer.. as i said i am quite new to ai .. do you mean i should add pawn sensing component to my aienemyBP .. i need to look up what EQS do .. so far i am only using behaviour tree which i added trough an aicontroller bp if thats makes any sense
No. Pawn Sensing is deprecated. Use Perception.
so far i am using on perception updated event like this .. the sequence is what i added for player character 0 and for 1 but it doesnt go in to 1
on begin play i cast to both player character 0 and 1
ok after a quick google search it seems way complicated but thank you for all the help hoope soon i will figure out.. cD
@uneven cloud You mentioned in one of your posts in #gameplay-ai that you run a commandlet to build nav data. I was trawling through ResavePackagesCommandlet.h and noticed they have a bShouldBuildNavigationData flag. I was curious if you had tried this before rolling your own and, if that was the case, if there are headaches with using it?
You shouldn't be hard coding anything to do with player 0 or 1. You are using perception. That will give you the targets.
The EQS for selecting a target is actually a lot easier than your BP.
We rolled our own because the nav mesh often needs the be deleted and rebuilt. So we did that with the commandlet, so we didn't run into "the navmesh is weirdly not working anymore."
Also it was when I was using 4 and world composition. Designers would often build navigation in a sublevel and just break everything.
Makes sense, thanks!
You're welcome!
ok now on target perrception updated event i added these nodes so it should save the object reference as a blackboard value.. but how can i call this in the behaviour three .. i think i should use this reference in focus instead of the get player character am i right?
ok if i put it like this its work .. but i dont think its the right way to do xD
Have you looked at using EQS in your behaviour tree to get all perceived actors? Then you don't need to do anything on the controller. You just need to:
- Make a behaviour tree
- Call an EQS query
- In that EQS query, add the generator for Get Perceived Actors (or whatever it's called)
You can also call the Set Focus service in your behaviour tree once you've chosen a target.
Oops, sorry, you have a BT above. Just put Run EQS in your BT and follow steps 2 + 3.
I'm playing around with getting my drone AI to hide. EQS is correctly finding a spot on the other side of the wall, but it's always getting stuck moving around the wall somehow. Eventually it will abort the MoveTo task and try again, and then it works. But it takes too long. How can I improve this?
thank you i really have to look in to how eqs s works.. for now i got what i needed.. i really need to upgrade my ai at one point in the future.. but as a single dev theres so much aspect i need to improve on my game.. xD
What does the nav mesh look like? Does the path tell the drone to move through the wall?
You are missing the basics of how the systems work. I recommend going through the AI with Blueprints course on the learning library.
The amount of space between the wall and the nav mesh is not appropriate for that drone. It's WAY too small. So it's going to get stuck on things.
Hi! I am getting used to AI after doing pure gameplay for a while. All the tutorials I have found so far say to "Set Focus" on the AI if I want a character to turn. But I have behavior where I want them to turn more slowly or stop at certain points. Can I manipulat the AI's focus behavior? Some other option?
A good example is getting close to the player, using an ability (already set up) and having the rotation speed be slower at teh beginning of the ability and then not at all in the middle.
Doing a Line Trace from within a Decorator to detect Line of Sight; does Ignore Self apply to the Pawn it's controlling? Or should I have it as a Pawn function?
edit: nvm, I see there's already a "line of sight to" blueprint
Right now I have it manually rotate to face the character and then set Focus to lock it in
Is there a way to get an ai to clear focus midway through an attack animation?
You can change the rotation rate in the movement component. You have to turn off using control rotation in the pawn and turn it on in the movement component
You should not have setting focus in a task. There is already a built-in service that does it for you.
You can clear focus anywhere. Such as in the attack functionality.
The service will clear the focus once the node completes?
Why not do it in a task
Is it possible to "unregister" a damage stimulation like sight or hearing?
I can unregister a StimuliSource after a pawn died . But before it died, it did damage to the enemy, the enemy still perceive the pawn after stimulisource unregistration because the Sense_damage exist
You can forget an actor manually, it should clear remaining stimulis, let me check.
Iirc you need to turn on can forget actors or something along those lines
I only find ForgetAll
Ahhh this is the only one available in blueprint
Either you modify the perception component in c++ (or inherit from it to add this feature)
Or you can maybe set a max age to a low value for the damage (this will maybe cause issue later if you need to remember a damage stimulus for a long time)
Thanks for the reply!
-
What does "Executed" mean exactly in this context? Having "Running" Run Status? Or it just means the traversal to a parent/child/sibling state?
-
If it means just traversal, is there a good practice to avoid having big depth/ long traversals in the tree?
- They are all runing in parallel (possibly ticking if you have a ticking node)
Hi! Working with smart objects right now for my AI, and I need to move the object in runtime. However, when i do that, the smart object slot stays behind. it doesn't want to move with the object.
Is there a way to fix this. I know someone suggested turning off and on the smart object slot, but I'm not sure if that's possible to do in runtime
I seem to remember one of the examples of smart object usecases was a car with seats
Available in 5.4 or later, you need to implement the logic yourself by cherrypicking what they done
Oh so they won't move until the next version of unreal eh... darn
Ohhhhh so it should be safe to increase this max value if none of my states use ticking and are event based?
Not sure about that :/
They won't move at runtime but maybe spawn them in a specific position works, i don't know since i didn't encounter this case
For instance for a car, you spawn the car so the smart Object is available at the car position
It won't follow the car so maybe have an extra actor that you spawn/despawn could do the trick ? 🤔
Nevermind, it will lose slot info if you do that
Yeah so i don't get the official unreal example... it sounds odd to have it if the SO are not able to move in their current state
Hmmmm. I mean, when i think about it, the main thing i need from the smart object for this particular usecase is the claiming part and the behavior part.
Cause I can just use normal AI navigation to get to the object that the smart object is attatched to.
For context, my idea was to have a smart object on casino cheater npc's for my game, so that my casino staff can find them and more easily interact with them without multiple staff going to the same person. So in theory, i can just claim the smart object, then use an AI move to function followed by a "use smart object" once they arrive
Hi guys, quick question, My Ai can detect client or server stimulus, then i set an Attack target key in the BB get the actor that trigger the stimulus, but on AI moveto, If I pass the key, the AI doesn't move to the "Attack Target Actor", If I put "get player character it work fine but it only move to the server has the player index is 0. Anyone has an idea about what i'm doing wrong ? thx
If your NPC is moving but not the smart object component, you won't be able to interact with the SO at the right position if i understood correctly
Okay, so if I'm In state B1, when i want to traverse to B3, does this mean that Execution Depth is 6? (Root->A->B->B1->B2->B3)? Or 3? (Root->B->B3)? Or a different number?
1st step is find a state to select
Your tree tries to enter each state by evaluating their enter condition. Until it finds a State "Leaf" that has a valid enter condition.
For instance : Root > A ( ❎ ) - B ( ✅ ) > B1 ( ❎ ) - B2 ( ✅ )
2nd step :
We now execute the hierarchy that is valid
So Root + B + B2. Which means Enter in each state sequentially.
Ohhh okay, so why is my execution depth too big here? The logs point that I reach max when Selecting this state (Print) After finishing "Reset Look at point"
Bonus Question : I don't finish latent tasks that aren't in leaf states of the tree, because i think when they finish, they try to trigger the transitions anyway, even if there's none, and break the flow, am i right?
Yeah that's strange you're at depth 5 maybe there is recursive call at one point that consider it deeper or something else.
Not sure i understood your bonus question
The only way to know is debug in c++ (for the first question about depth)
I mean, as long as I use the "use smart object with gameplay behavior" function instead of the "move to and use...." one I should be okay right? Cause I'll use a normal AI move to to make it navigate to the parent object
In both case, this is the AI that moves to the SmartObject
not the smartObject
If your NPC is not moving from its position, you don't even need to move the smart object
But for a car, the smart object should move with it, so yeah it's different
smart objects can't move (as of 5.3)
Well, the smart object is going to be an npc that roams around.
The car was just an example I saw that made me initially assume that they could move.
Just trying to figure out some workarounds to this limitation
the best workaround is to wait for 5.4
Or we didn't wait for it :p
Firstly, we did our own implementation, that was quick
Then we saw that Epic did it so we fix our implementation
so the main changes merge fine in 5.3? (haven't tried yet as it's not high priority for me)
Not sure, we didn't merge it, we just fixed an issue with our code base
But it is essentially the same
I guess it should merge fine
Apart from that.
Anyone knows why we don't have a UEnvQueryItemType_Location in the unreal code base 😦 ?
There is UEnvQueryItemType_Point which is a navpoint and UEnvQueryItemType_Direction which considers the vector as a rotation
Maybe Point is enough for most project
But here, i got several navigation system so I need vector. Anyway, i'll implement it.
Do you know why that green area is so small and not wide enough for the drone? There is more than enough space around this wall.
Check your NavmeshBoundsVolume bounds ?
It looks like your world is so big that you didn't made your volume wide enough (considering the size of the gizmos)
the navmesh covers all this space
I'm talking about this screenshot further up:
Why does it generate the tiny green path for the drone and make it get stuck?
it does cover the whole area
Ahhh you just debug the path in the screen?
yea
here's the triangle preview
trying to understand why it doesn't use the big tiles around the wall, but just the tiny ones
What is your agent radius?
what's that?
The radius needed to compute a path for your agent
It restricts how your agent can navigate on the navmesh.
For instance if a corridor is too narrow.
And i'm suspecting your agent radius is so tiny that it goes through narrow nav meshes
is it this nav agent radius setting here in my character bp?
nah, that alone doesn't seem to do it. I increased it, but the path is still the same width around that corner
I increased Agent Radius on the RecastNavMesh, now it looks better. It was 35, but I won't have agents that small.
hi everyone i've created a game with multiple playable character..when i switch character the AI controller still running the character conflicting with player controller..the way i did it is first to store all the controller in the game mode on begin play..then unposses all contoller on all character..then posses back all the character..the thing is when i posses character B or C or D their AI controller still running the function..tried a few thing like stop logic on brain component and stop using behaviour tree and using blueprint instead to drive the ai controller but i think the problem lies with ai controller not unpossesing the character..any advice?
Ohhhh
Does it fixed the issue?
You need to verify where the problem is. Check if the AI controller is actually unpossessing it or not. Most likely it is, but your code just isn't being disabled when that happens
Yes
Hello, is it possible to get sense's config out of it? I'm in a sense method, and I need to get own config, but I don't have any reference to the owning AI perception component. Obviously C++
Hey guys, what's the easiest way to check if an actor is on/inside the generated navmesh (in Blueprints)?
project point to navmesh from the actor's center is the first thing that comes to mind
ProjectPointToNavigation
Hey all. I need to have my AI perform certain constant tasks while specific States are active in State Tree. An example would be needing my AI to face his combat target in State A, but needing him to face a friendly target during State B. While a state is active I just add the task I need it to perform and bind a target. This results in movement or rotation logic being executed on tick inside of the State Task. The workflow works well and is easy to use, but is this the best place to put this sort of tick data? I don't want to bog down the State Tree. I could offload this to a companion component I have, but I'm not sure if this makes any difference in terms of frame or tree performance. The comment for StateTreeTask tick seems to suggest that I might not want to put this data inside the task itself.
It doesn't seem like it would make any difference 🤔
Mostly just a question of how you want to organize the logic
Okay that's what I assumed but I the comments on Tick in the task read a lot more dubious than tick in a component or actor
I think I prefer the task taking care of the logic itself. I feel like that's exactly what tasks are for.
Hi,
I'm having an issue where my On Target Perception Updated event in my AI Controller is rapid firing true and false.
The situation occurs if my player is behind the AI when the AI is turning toward the player or whenever I run out of the AI's peripheral vision (either by running right by them, or running to the side where the peripheral boundaries are).
If I disconnect the behavior tree I can start the level out behind the AI and when it is possessed by the controller it will turn and see me normally, but once I hook up the behavior tree as soon as the AI is possessed, the debug shows line of sight to me (even though I'm behind the AI and out of it's peripheral) and then the AI snaps a little toward the player losing sight (the debug shows the age reset) then it immediately picks me up again and so on until it faces towards me.
Thanks in advance for reading this!
Here is a YouTube video of the issue. It shows the level start where I am behind the AI (there is a countdown delay at which point the Run Behavior tree executes), and during a chase sequence if I manage to run by him or out of his peripheral.
I'm running into issues with the AI Perception in UE4. When the behavior tree is ran the AI can sense my character behind him even though it's outside of the cone of vision. Also when I go outside of the cone of vision while close, the AI repeatedly loses and gains site of me as it turns. Any suggestions would be appreciated.
Services can do something when you enter that branch and then when you exit. Using a task for set/unset focus is not reliable on it being unset.
What do you mean you can detect on the client or server? You should only be detecting on the server. Are you using the AI perception on the AI controller?
It's based on your agent radius settings in the project settings.
I'm having some issues with some "basic" ai. I have an AIcontroller with a behavior tree that goes through the following sequence. Move to player (with a stop range), turn to face player, fire at player (if in range still). I have a line trace that starts at the ai characters mesh but every time it fires, it fires from the meshes original location, not from the current location. I can't figure out why. The movement and look to work only the line trace is messed up.
Why are you storing all the controllers on the game mode, unposessing and possessing again? That sounds like a recipe for disaster. The AI controller should be unpossessed when the player takes control. During unpossess the BT is shut down.
Get a sense config out of what? The sense is supposed to cache the sense config for the listener when they start using it. If this is your own sense, look at how the built-in ones work.
Show the line trace functionality
Was just trying to get the screenshot.
This should be it. This is inside of the bp_enemy blueprint (which is a Character class)
The first linetrace works, but after the character has moved and fires again, the line traces start and end at the original location the mesh was, not where it's moved to. Pretty sure I am doing something wrong but I've never done AI before so trying to figure it out.
Get the sense out of itself. I know that there's the UAISenseConfig* UAIPerceptionComponent::GetSenseConfig(const FAISenseID& SenseID), but the issue is that I don't see any way of getting the owning UAIPerceptionComponent out of the sense itself.
The behavior tree logic
There is no owning perception component. You have to get the listener you want and get the perception component. Please look at the built-in senses and try to understand what it's doing.
You should use the actor forward vector and not the mesh.
Which actor?
Your BP character.
Wouldn't that be 'self'? I am in the enemy character bp. Self cant connect to forward vector.
Oh, 'Get Actor Forward Vector'
duh
Why did you make your own move to? Or rotate to? You lose a lot of functionality making your own.
What are they doing?
The move to just uses AIMoveto
and the FacePlayer just does a RInterp to rotate it towards the player
There are built in tasks that do that. How are you rotating it?
I just noticed there's a 'move to' task already made, but I haven't figured out how to pass the players pawn into the behavior tree yet so all I have available is targetSelf
You pass it in via the blackboard.
Should probably go through the AI course on the learning site
This is the rotate to.
I highly recommend doing the AI with Blueprints course on the learning library to learn about the basics of the AI systems
Watching and reading doesn't help me learn. I am a hands on learner.
Except I've not found a single course that actually explains to you what things do, it just says 'put this here, connect this, do that'. Not helpful.
Have you done the AI with BP course?
Any ideas why this setting on the RecastNavMesh is not saved? Whenever I restart it's back to 35, even tho it saves the RecastNavMesh when closing.
The AI With blueprints course will explain the systems and how to use them.
I don't think I've ever had that stuff work. Set up agent settings in the project settings
The weird thing is, setting it in Project Settings doesn't solve my problem.
On the left is the default 35, it creates this weird small area where my AI gets stuck.
Setting it to 200 in the RecastNavMesh fixes it, right image. Setting it to 200 in project settings doesn't do anything.
Have you tried deleting and making the navmesh again?
Yea, same issue
Thought I found a fix, and then it always resets it when reopening the project, what the heck 😦
Found a fix in Dev forums
You need to create a supported agent here
Then RecastNavmesh takes it from there, it works
That's what I said 😭
Are you setting it in the nav mesh settings or making a supported agent setting? You need to make a supported agent.
There's another Agent Radius in navigation mesh 😄 hell, this is confusing
Does AI Perception only work with Characters?
I'm trying to get my AI to perceive buildings (which inherit from Actor not Character), and it is never triggered. If I reparent the buildings to character, then the AI properly sees them, but that leads to a lot of other issues since the buildings are not supposed to move.
I couldn't see anything in the perception settings about what type of objects it should perceive, should I not be using AI perception for this and instead just use a straight up collision query in a separate task?
It works with anything. Pawns (such as Characters) get registered as stimuli sources by default for it, anything else has to be registered manually
Easiest way to do that is to add a stimuli source component to the actor you wish to register
Ah stimuli source, man googling how to get objects to be perceived gave me no help, thank you
that works perfectly
Keep in mind that each source will get a linetrace to it from the perceiving AI if it's within the radius and sight cone, so if you plan on having a lot of them it may have an impact on perception speed
i didnt store the controller at first but the ai controller is conflicting with player controller whenever i switch back to the first character..one solution that i look up in unreal engine forum is to store all the controller on game mode.. which didnt work
What is conflicting? Are you unpossessing the AI controller? That forum post gave you really terrible advice.
my behaviour tree function is stored on the ai controller so when i possesed the first character back after i switch to other character the behaviour tree is still running even though i try to stop logic and set the behaviour tree to none
Are you unpossessing the character?
Please explain what "when I possessed the first character back after I switch to other characters" actually means.
im sorry if this is confusing because its kinda like the 3-4 time that i rewrite the code to make the system works..at first attempt when i switch to character B theres no problem that i notice but when i switch back to character A ..the pawn still trying to aim at the enemy even though i try to move away from the enemy
i try many things in between so i cant really point out what come after that its just one thing broke when i try to fix the other
I can't help you if you refuse to answer my questions. I've asked you several times now if you are unpossessing the character and you won't answer.
in one of my attempt is to unposses it in game mode like i stated earier
earlier
I"ve been a big fan of this guy Ali Elzoheiry's tutorials. I'm only one or two videos in, but the clarity with which he's explained how and why it all works has been very helpful for my behavior tree understanding, so far.
https://youtu.be/WFV5IewGks8?si=jJ1qhBxzgHwG09Wg
As far as what things do, you also have to take what they've given you and just play around with them. I've just been using Set Focus, but I'll probably use Rotate to Face BB Entry now that I noticed it...
In this Unreal Engine Game development Tutorial you will learn the following:
- Patrolling: How to make an enemy AI patrol along a spline
- States: How to switch between different states in behavior trees
- Priority: How priority works in behaviour trees and how to abort low priority tasks for higher priority ones
- Animation Montages: How to se...
Again. What do you mean by "switch to character b"? Do you mean that character b was an AI and you are switching to a player? You need to be specific on WHAT YOU ARE DOING because we can't just sit here and guess.
The AI with Blueprints course in the learning library is better. That is yet another tutorial that is teaching people to use the BT as if it's a state machine, which is incredibly bad practice.
You have to first unpossess the AI and then possess with the player controller. Preferably not in the game mode.
Unpossessing will turn off everything.
will try..thank you so much!
Hm, I had that exact question in my head as it was going over the use of Enums for state in the behavior tree
Not that I'm super familiar with State Machines, but the premise of as behavior tree led me to think that the behavior should flow through the tree based on tree logic and not have a state dictating which branch to go down
Can anyone share any resources on AI path finding on moving platforms?
That's pretty much it. The main difference between a state machine and a BT is that a BT separates the transitions from the actions.
Forcing it to act like a state machine ignores how a BT works, limits you a lot and causes unnecessary indirection.
Does anyone know if there is a way to put a limit on the pathing cost an AI can have? Basically I trying to dynamically make areas the players can stay in and be safe from the AI with Dynamic Obstacles. All the dynamic obstacles do is raise the cost. If there is no other way to get to the player the cost doesn't matter anymore and they just path directly to the player. I've been working on this one for hours and hours, but I can't find a solution. I'm trying to avoid physically blocking them.
You can use nav area null on a modifier (volume or component). It's a lot easier and less problematic than limiting the cost.
Or you can do what most games do (including the AAA game I'm working on) is to tether the AI to their spawn location. If they get too far away from their spawn location, retreat.
Hmm, I dont see it on my sphere collider properties. I'll search online for those terms and see what comes up.
Basically I have a zombie survival game (think pitch black movie mechanic). I have hundreds of zombies and I'm trying to the player the ability to carve out safe spots.
Nav modifiers modify the nav mesh. By using a class called nav areas. Nav area null is a built in nav area that cuts the nav mesh.
Think turn on a light source (in realtime) and they Nav is removed around the light.
Can they be used at Runtime?
I've used the static ones.
You can do that with modifiers. You need to turn on runtime generation to modifiers only.
Ah, I found the component. Thanks, I'll figure it out from here how to enable and disable. Thanks Luthage 😄
When a modifier is added, removed, moved or area class changed, the navigation will rebuild just that area.
I think I just can't quite parse the nuance yet; if, say, I want an AI to be stunned before becoming active again, even with a behavior tree I'd probably have a decorator checking or a blackboard boolean dictating whether it goes down the "stunned" branch. But I'm unclear on if I am avoiding "state machine" pitfalls, because aren't the series of checks and booleans I do a "state" in the abstract? I guess I'm wondering what the guiding light or dividing lines in principle of design are for a BT versus a state machine.
I guess a series of booleans offers more unique combinations and behaviors than coding the same number of explicit states
Why would you put stunned functionality in a BT? They are stunned. That should happen immediately and pause logic.
Using a bool for something like "stunned" is doing the same thing as setting up states. You are still thinking about it as if it's a "stunned state."