#gameplay-ai
1 messages ยท Page 143 of 1
and spawning new ball everytime one dies
i can run 200 monsters in our game, at 60fps with 8 players on listen server
with those above techniques
I see, I'm trying this right now, but i guess if i want to simulate a horde of enemies I need a completely different method.
I mean you have instancing for static meshes, but i don't think there is anything comparable with actual pawns, right?
its not going to be your render thread
so having instanced meshes wont benefit that much
make sure they dont block navmesh also
I've seen a video from epic were they used a bunch of different techniques to simulate thousands of enemies and using niagara was one of the things they used.
Is this just for the visuals or could it even help to "fake" AI with these particles, i mean they just have to follow and die (in my case)
I will try your suggestions first and see the results and try niagara after that (really unexperienced with it though)
this is what i mean by its the movement of the actor in the world
eating your game time
So I used all your suggestions and I get similar results (200 Enemies at ~60 fps), i guess it worked! ๐
Wondering if anyone could answer my question. Does child blueprints share ticks of the parent bp?
as in, a child actor component, or you mean when you inherit a BP from another?
Inherit
in that case if your child has a Tick event, it overrides the parent's tick, same with other events and functions as well if they exist in the parent
You can right click the event or function node and choose "insert call to parent" or whatever the option was called, which gives you a node that allows you to trigger the parent tick
Hmm. Ok I had multiple ai on screen and for some reason they take turns to attack.
if they are all individual actors then they all have their own ticks and such even if they are based on the same blueprint
Thanks for your answer
np
Hey, am using predict projectile path by trace channel and for some reason when it hits an AI with AIperception it stops detecting the player
Any ideas?
@pallid mica
i dont want to stop movement
i want it to stop following the targeted location and change the location
And calling MoveAI again with a new location doesn't do that?
nope
it first completes what it was doing
(in my case)
for example i have a deer which roams around
i have set such that if player is too clost to deer it will run
but at first the deer completes its roaming then run'
yeah there is
oh i see
so can anyone help?
Can anyone tell me how can i cancel an ai move to when it has already locked in on an actor
what i am doing is i want the ai to follow the player on a certain distance
so when the player comes too near to the ai it starts following it
but when following if the player goes too far the ai doenst stop
i think its because the ai already locked his location to the location of the player
can i somhow cancel it midways?
for example i have a deer which roams around
i have set such that if player is too clost to deer it will run
but at first the deer completes its roaming then run'
How would u know if the ai npc are within the player render distance and also not behind the player? I would like to disable ai brain and animbp based on that.
How do you detect if your AI is not in "8" players view?
WasRecentlyRendered() runs authority only so I assume you are doing a math based on distance?
You can tag player with extra visual sense source where it basically do LOS check. So if AI can't sense anything from this tag/sensory it's not spotted.(cause LOS goes both way.)
Are you using behavior tree? Cause if you just try to wire up your own AI events, some of the action like the AI move to nodes can't be interrupted. (Notice the clock icon on top right of node, also the node doesn't accept extra interrupt execution input)
easiest way to move a fish from point a to point b without a navigation system? I'd like a way to do it with a timeline and lerp vectors, but I want to be able to control how fast they go with a movement speed parameter
no im using the normal player controller
how can i get the rotation of the navlink point an AI
How do you make AI rotate using animations when finding random location?
I have my AI roaming from location to location. I've 1d BS that goes from idle to -> walk -> run
I want it to rotate towards its destination
so if its at the bottom it will face the top destination and vice versa
iirc there's a rotation speed setting or something like this on the character movement comp which you can use to artificially slow it down, you could probably do something in anim bps to make it play some kind of animation... but I'm not really super familiar with that part of the equation :)
Currently I'm doing that. But I wanted to use animations.
Maybe I coudl create a task FaceDirection then play anim.
There's probably some way you can find out what the target rotation is vs current rotation, so you can animate it in the anim bp while those don't match
Alrighty, so I have a bit of a dilemma. So a few days ago I've been taking a dive into trying out level streaming, something I've been wanting to implement into my game since the beginning of development. A few days ago, I finally reached the point in development where I could start implementing it, and for the most part, it's been working out very well! Except for one thing. Navmesh's and AI seems to be very very finicky when it comes to level streaming. Sometimes it'll work, and sometimes it won't. In most cases, the enemy AI will just flat out not work at all.
I've tried a whole bunch of things, putting the Navmesh in the persistent level so that it's always loaded. It seemed to worked at first, but eventually that method stopped working. I tried putting the Navmesh in the same level chunk as my enemies, so that both are loaded in at the same time. Still nothing. I tried putting the enemies and the Navmesh in two separate level layers, loading the Navmesh first, and then the enemy. Nothing. I'm not really sure what else I'm suppose to do here.
Not a big help, but I had no issues with level streaming and NavMesh in 4.23 or 4.24 (don't remember), so there might be another cause of your AI issues
I'm using 4.26 on my end. I'm pretty sure the actual AI itself is fine, and that it is something about the level streaming that's confusing it. I can sometimes fix it by loading up the standalone level and building the navigation. Then immediately afterwards, loading up the Level Streaming world with the testing area already being visible at the start. It doesn't always fix it, but it's been the most consistent solution.
But....as soon as I disable the visibility of the level, in order to edit a different level, the AI breaks. And that's a massive problem, since the entire point of me wanting to use this Level Stream system is to link levels together into one seamless world, with almost no need for loading screens. (Outside of a few exceptions of course.)
In my head, this issue actually does make a lot of sense, since it's trying to build AI pathing for a level that isn't currently there, and that may be confusing it. I just don't have even the slightest idea of how to fix it, aside from building the navigation while literally every single level of my game is visible/loaded in at once, which I don't really wanna do for obvious reasons.
So this is certainly an interesting navmesh generation result...
I got recommendation in #legacy-physics to ask in this channel please don't remove
Hi people, I have problem with ragdolls. I already set preset to ragdoll block only WorldStatic to allow my ai enemies to pass through ragdolls (because they stay on scene). However that works but this one ai character has some strange corrections during Move To task in BT, when comes on dead bodies. USeControllerYaw in Pawn is disabled and UseControllerDesiredRotation is enabled (in CharacterMovement)
https://drive.google.com/file/d/10lHknflRzHwkcbtL4QHVrp5bSwU_K1xr/view
Are you using avoidance?
If it's using avoidance then you probably need to unregister the dead pawn from the avoidance system so it won't do that
Did you put the AI in the streaming level? Have you consider spawn them in with a pool of prespawn AI(but not possessed)
Like the actual AI object? Not the character?
I've never heard of the other method with prespawning, so I dunno how to do that.
Cause spawning AI controllers and pawns have some overhead if you have plenty AI loading/destroyed
So in your case where you go through levels, does the AI belong to that level being destroyed as well?
By pre-spawn a pool of AI pawns and AI controllers, it lets you move the pawn where you wanted and then possessed before starting the AI.
Of course you can hide that during transition if you have like only 3-5 AI max
@misty wharf yes, posible tnx
yes that was problem i forget on avoidance :), tnx again
any advice on enemies finding a good spot to stand in to shoot the player. There are 2 factors in this case I think. One, is an enemy in front of them, two is distance from player.
Also, is a cover system necessary for a game that empasises stealth?
@hearty niche You might want to look into EQS
You'll probably want a visibility check, distance check, and dot product check
also would cover system be needed in a stealth oriented fps?It feels like a real pain in the ass to program.
Like I intend to make damage received higher to discourage head on encounters.
I wouldn't say its needed, imo. Usually cover systems are for third person shooting games.
Instead I think you should focus on a more sophisticated detection / investigation system
Fair enough so I should be looking at spotting, search and callouts then I guess. Thanks that actually helps a lot.
The enemies (And by extension, their AI.) are apart of the same level being destroyed, yes. The Navmesh is in the first layer for the level being loaded, so it's one of the very first things being loaded in when the level is streamed. And then enemies and NPCs are on the final layer of the level, so they're the very last things that are loaded in.
best way to move a AI without a navmesh? I have a fish that I want to go from point a to point b and i don't need a a* setup or anything like that. Just "move to this vector" The only thing i do need is to be able to do it with a speed variable so different fish go different speeds. Any ideas? I was thinking a timeline, but I don't know how to make it go at different speeds.
A siMple way to check is by turning on the AI debug drawing
' โ use this key
If it doesn't draw a representation of a view piechart etc, it's not possessed by a valid AI controller.
(this is assuming you are using behavior tree, if you didn't use BT, you probably need to do a print via on possess event.)
Most broken AI should check first they are possessed, and then check other things later.
hello, i'm having a weird problem where i have a sequence with a move to, then it executes Task A and then it executes Task B. In Task A i override OnTaskFinished to cleanup a state variable before executing Task B. Most of the time everything works fine, except sometimes it goes into Task B without running OnTaskFinished for Task A which puts the AI in an inconsistent state. Is there any known reason where the BT flow can go into the next task without calling OnTaskFinished on the current task?
One thing I learn very early on in UE4 blueprint is you do not assume two different things running in sequence you assume that will be just fine. As in your case, majority of time.
And that some times it doesn't work can lead to very dramatic changes later down the road when you try to fix it.
Basically, I would suggest that you put all the things you want to do with OnTaskFinished only deal with inconsequential stuff. Cause you can't guarantee the event call is issued the same frame as your task.
You can do a simple test, by adjusting max fps and other scalability settings so you can achieve say 24-240fps
And then test if your AI still holds up.
My guess is at higher frame rate your AI will fail and run into issues you have more.
You can put those clean up into a macro or something so they are guaranteed to run together with you task.
i just thought it was sequential, once a task finished it triggers OnTaskFinished and then it moves on to the next
Never assume that treat all the red event nodes as if they can be run at the same time and can run at different frames.
Even if you directly call Event B from Event A
There are special cases like BeginPlay only run once at the beginning before anything else.
In your case, my understanding probably be that main task events have a higher priority than the onTaskFinished if they are scheduled to next frame.
Don't ask me how Epic do that cause I don't know the source code that well.
But that's how they deal with AIs so they can run a lot of AI before you hit bottleneck.(since they don't have to finish all the logics in 1 frame, they just run enough to update and then do something else to try reach the target.)
It's not really that unpredictable
Async/latent execution pins are usually (probably always?) separate and labeled
so nodes which look synchronous are synchronous... they may trigger an asynchronous action, such as the Run EQS Query node, but it's usually somewhat obvious in that you can't get any useful result out of that node unless you listen to the event from the returned value
(or you need to use the labeled latent pins)
How do you know for sure? I am saying because BP events like I mentioned above doesn't even guarantee atomic execution even if you chain them together. If say event A fires pretty often and then Event B use Event A's result. I've run into data race issues like this enough time that I never trust the execution orders even if event B only getting called by Event A.
The execution is in order they are chained, but the data access aren't.
how do i check if the MoveToLocation on an AIController was successful or if it failed because they got stuck and all that jazz 
I've never had that problem. It sounds like you have latent logic mixed in where you don't realize if you have issues with that... also if you really have events which run and produce results you need to use in another events, it sounds like you probably should be using functions and having them return values :)
There's a move to node with pins for the results, use that one if you need to know that kind of information
i figured it out, but i was wondering what is the best way to make a character slow down on a slope (and i'm using c++)
also thxies :>
I think you should be able to get the angle of the surface it's standing on and then based on that reduce speed perhaps. Not sure if that's the best way but it's at least an idea I guess
what would i find that in, the AiController class ?
it'd probably be either in character movement controller or in the character itself
the CMC definitely does some logic on what actor it's currently based on (meaning on top of)
Which is what happen to @storm zephyr example. His task C relies on Task B's clean up event do the job.
Pretty sure he had that in C++ though?
Thus I suggest not doing it in 2 events.
C++ or not doesn't change the fact that events can be fired from different frames or have those data race issues no?
But I am not familiar with UE4 code base enough to say for sure.
Well in BT's yes, but if the tasks are set up correctly they will run all of their lifecycle functions before the next one runs
it's possible he didn't have it correctly set up to handle asynchronous task execution, or some other situation like that
So basically you mean he have logical errors that only happen randomly and Not from execution/data race?
I haven't really done BT stuff in C++ tbh so I'm not super familiar with how it functions, but at least in BP's it works very predictably
Yeah, they don't just randomly go in a different order without some reason
No I didn't mean they aren't execute without orders. Maybe I phrase then poorly.
They are execute with the order you specified. But just that the Task B can run again while previous clean up is running or finished.
Thus, Task C getting wrong results assuming another Task B won't be triggered before the onTaskFinished is done.
I don't think it should do that
I just looked it up in the code out of curiosity
the only time OnTaskFinished is called is when the behavior tree finishes executing the task
It happens a lot for input related BP issues during early days.
so it will always run before the next task is started
I even wrote a wiki article for new comers.
That's where I am not sure/certain.
Cause BT execution the entire package I don't know the framework well enough to say yes or no.
But I just avoid depending my execution from event firing orders at all. Like never when I do things in BP
The only situation where it might not get called is if the task finishes execution with EBTNodeResult::InProgress
but I think that means it won't execute the following task
so it shouldn't really be an issue even in that case
it would break a lot of stuff if the tasks wouldn't have a predictable execution model, because even in my game I have tons of AI logic which depends on the previous task having set some blackboard state lol
Yeah, which make it really strange isn't it. If a task failed, it should never really try to run task C
If it success, then onTaskFinished should run before it runs Task C
Yeah
There seems to be some limitations with OnTaskFinished on non-instanced BT tasks, such that it should be treated as a const function in those cases
so possibly doing something you're not supposed to do, like not treating it as a const in that scenario, could cause issues I think
Could it even be possible that Task C fired when onTaskFinished is still working?
(thus data race)
I don't know if that's possible unless you're firing off tasks in different threads
I'm fairly sure the BT runs in the game thread
Yeah, someone mentioned that before.
Quote a video even.
Cause I just assume everything runs in different thread.
And got corrected.
Threading is annoying so I never assume anything is in a separate thread unless it explicitly states that it is lol
Is it stated in documents?
I think it's quite safe to assume everything you do in UE runs in the game thread
(like this function is run in a different thread, don't rely on the result etc?)
The only situation where I've seen it to not run in the game thread was when I did something with the RHI apis
I guess that's why input related events cause a big issues. Cause the input polling/firing seems to be from independent thread.
I've helped quite a couple input firing issues in the past.
Most is data race.
It's plausible it'd be in a separate thread from which the state is synchronized into the game thread
Say press A and set boolean to true/false.
And then press B that rely on the flag to do one thing or another.
So many people fails with this type of things.
I don't think that should still be a problem, unless the timing was extremely close
or the framerate was extremely poor :D
as long as there's enough delay between the keypresses that they both run in their own frames, they should still execute in the same order as they were pressed
I'd assume the order is undefined if they are both pressed simultaneously within the same frame
I think I solved my own issue, saw that some code was deprecated so I got rid of it and it appears to work.
@misty wharf that is what happens to me, the TickComponent finishes InProgress. Any idea why?
I mean if it's a BT task you created it's because the code you wrote returns that status, no?
yes but i only call FinishLatentTask when it's not InProgress, so it shouldn't finish the task move on to the next:
void UBTTask_FaceDirection::TickTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds)
{
const EBTNodeResult::Type Result = PerformFaceDirection();
if (Result != EBTNodeResult::InProgress)
{
FinishLatentTask(OwnerComp, Result);
}
}
i keep forgetting the code char in discord xD
(it's 3 `s, btw)
thanks xD
so in TickTask i keep running a interpto rotation to face the blackboard direction
Yeah I'm not really familiar with how BT tasks function in C++, but I suspect the problem is somewhere within this if they start executing out of order
I checked and the OnTaskFinished functions definitely only gets called when the behavior tree finishes executing a task, and this happens before the next task gets started
that means that there is another way to go to the next task without finishing the previous
because the first task never actually finishes
it's like it's being overriden
Yeah I think it's probably not an intended mechanism, but rather as a result of it doing something unintentional it triggers the next task to start
maybe a performance setting?
I don't think so, it doesn't care how long your task takes
I have bt tasks that never finish unless a certain condition is met
but you use bp tasks right?
yeah, it shouldn't be any different in that sense though as they inherit from the C++ classes
yeah i know, but i don't think you can access the tick event in bp
Might be yeah, but nothing stops you from say starting a timeline in there :D
iirc anyway
I don't think the behavior tree has time slicing
since it would have to be built into how the task works
and since it runs in the game thread and not as a separate thread, it can't really abort an already running tick either
i'm running out of ideas on how to make this reliable, so i guess i have to duck tape it and clear the state on the next task, which kinda sucks
I'd suggest trying to find more info on how latent BT tasks should be written in C++, and verify that your task follows the correct way to do it to a T
Sorry I can't really offer any more solid ideas on this, but I'm pretty sure that if they randomly just started the next task like this, it would break a lot of behavior trees and expectations in how that system works
thanks for your help, i'll let you know if i find the reason ๐
good luck :)
@misty wharf now sometimes the task ends twice xD
jeez lol
@misty wharf bCreateNodeInstance = true seemed to fix it (need to do more testing to confirm)
even though i don't use Memory for anything
question. what advantage do i get by using the behaviour tree in ue4 over setting up manual Ai tasks in the controller and blueprint? the latter is also easier to set up in general without relying on tick function.
You're supposed to treat OnTaskFinished as const if you're not using instanced nodes, that might be the problem
@misty wharf hope so ๐
Is it possibile to change this, area class, in runtime, and how? I need that for some kind of door when it opened there should be NavArea_Default, closed NavArea_Null?
ofc
I succeded to change it, on some very strange way, set Area Class in bp as NavArea_Null, then on begin play i save this 0 index element from Links, then on some my event (door opened) remove 0 element from Links and add new, created from saved on BeginPlay, in that case Area Class is None and that is ok but GetRandomReachabalePointInRadius still return points only inside room, like door still closed adn on NavLink still set NavArea_Null
so i need some refresh or update for nav system or nav link, i tried to set it to be dirty but nothing works
@pine steeple sorry, you wrote ofc for my question above?
yeah was meant to finish but got distracted ๐
you need to grab the link id from the array
you mean index?
nothing is exposed and can't do it is simple thing but annoying
i tried on this way and got desired result but navigation still "see" this nav link as it has NavArea_Null for Area Class
@pine steeple
no i'm not only bp, i just tried there because things usually simpler in bp, and component is added in bp
if you have some cpp snipet pls share
because i tried to add in cpp as component and there is no NavLinkComponent so i dont know how to start what is calss of NavLinkComponent
@pine steeple
FNavigationLink?
there is no navlink component but we implemented the navlinks into our door/zipline/vault actor bases classes
just basically copy past of anavlinkproxy
paste*
agrh yes i did my vaulting on same way
so can't simpler ?
ok thanks man, I will try on that way ....but tomorrow ๐ , there is more job to do than I meant on start @pine steeple
infact we did one better and made a custom component
depends how many things need a navlink
what is base class for custom component, i get ANavLinkProxy for vaulting
How to know which way AI is turning? Let's say AI roams by finding a random location. I find the location and turn my AI prior moving to the found location. Let's say I want to use that in my BS.
can someone help me im trying to make an ai that will follow me if i get into the sphere collision but my bullet is actualy pawn but i need the sphere to be pawn cause my character is pawn pls help
Join our Filmstorm Motion Library: https://www.patreon.com/filmstorm
Join us on Youtube Gaming and click join next to the like button:
https://gaming.youtube.com/watch?v=v0hB-GAEMuk
Unreal Marketplace Link - https://unrealengine.com/marketplace/open-world-animset
Get the Open World Animset today: https://gum.co/openwas
Part 2 of the Root Mot...
this is solution but for player...I used that, adapted for my AI, should have two BS, one for start and one for move (1D),
should provide input for BS, speed and direction. speed is normalized because in tutorial use speeds from 0 - 1 (axis input), direction is angle between your desired turn point and your current rotation (actor/capsule forward vector)
I don't remmeber is there how to caclulate direction but I did on this way, InitialRotation is cached capsula rotation in moment when ai decided to start with turn, and this on pic is in Tick
start turn, in my system fired from custom task in BT
@stiff gale
Thanks I will give a try
I wrote a service in c++ but not showing up when I try to create a blueprint from it. Also i added some logs in the service c++ file but they don't show up. https://gyazo.com/3becd90283be045638c43c8579cd313b
Anybody?
Your question is kind of unclear. What do you mean it doesn't show up? In your screenshot there is clearly a service?
I added some logs. It won't execute
Tick or what?
If tick doesn't execute, the problem is likely that the node doesn't remain active for 0.4 seconds. There is a separate bool flag which needs to be set for it to tick at least once on activation
So pretty much face actor task turns the player then my service suppose to play anim montage
I was going to do that in my BlendSpace. But I couldn't get the direction to work with my BlendSpace
got it working thanks anyway
ive got some obstacles that I want my AI to attack if its in their path
is there a way to code that?
like path to a player, and if there's an obstacle in the way, then hit it?
There's probably multiple ways to do it depending on how you want it handled
One way would be to have the obstacles not affect navigation, and have your AI's detect when they bump into them
Got health and damage added to NPC last night.. Now thinking about pain state. My tree splits into 2 based on target sensed (sensed/not sensed) and then each subtree is split into several states.
Should I just add pain state and add pain task, which I can then add to both sensed/not sensed subtrees ?
Seems reasonable to me
In my game I have the pain state just as its own branch, since it doesn't depend on the state of the npc otherwise, but if you needed it to behave differently depending on which branch of the logic it's currently in, then you certainly can handle the pain state individually in those too
(or if for some other reason it's easier to implement like that)
I though about it, but then it interferes with sensed/non-sensed split I have (I am not sure how I add 3rd option to that selector, other than check for whether it's sensed or not sensed AND in pain)
Anyone know if a Search Context can be used as a "filter" within EQS? I have a context that prunes some actors from the resulting actor set but for some reason EQS isn't ignoring those actors for the other tests.
hey gang, I'm running into an issue running multiple EQS Queries in the Behavior Tree
I have an Idle Task, the task uses a 'patrol EQS Query'
when in combat, I have another task that uses a 'melee' EQS Query'
however, when I run the game and I debug it, it never seems to run the melee EQS Query when in combat. It keeps with the Patrol EQS Query
am I supposed to do something in the behavior tree to clear out the previous query?
to make sure, I removed the patrol EQS Query from the behavior tree and then it used the melee EQS Query just fine, so it's not that the melee EQS query is broken
are you using the Run EQS Query node or how is this implemented?
yes. I am using the Run EQS Query node (the default one)
ah sorry, the task?
yes
okay yeah just realized that the BP node for it has the same name :D
anyway that sounds a bit odd
Have you tried setting a breakpoint on it to ensure that it's actually being ran?
yes. it is being run
in fact, I can see it in debug, but the IDLE query has priority over it and the melee one is grey'd out
What are you referring to by debug?
Ah
I use the " key and then type 4 number key
It seems to me that for some reason it's also running this one, the queries don't have any kind of priority mechanism
If you set a breakpoint on the patrol BT task, does it run when the attack one should run? or immediately after it?
it runs the idle query once and then never again.
i'm watching the points in the debug and they never update.
Does it actually run the Move To after the melee query task?
yes
I did a print statement on the query to verify it was getting a legit number
and it fires off the print statement
(i'm spitting out a vector for the melee character to go to)
well that doesn't really mean the move to runs
you'd need to set a breakpoint on it, or pause the execution and then step backwards to see if it went into the move to node or no
because to me it sounds like what's happening is that something is failing and exiting your tree branch, and as a result it ends up at the patrol part of your BT
ok
so I figured it out.
it's working, but the debug only shows one query
so I guess the queries are being used appropriately
Heh
but the debug only shows the first one
I think you may have to press * to cycle through them
I wish it would show the currently used EQS
You can also use the Visual Logger to get a more time-precise log of when they run
cool thanks zomg.
does anyone know of a good and up to date physical animation tutorial ? I need to make NPC twitch slightly when hit by projectiles or hitscan weapons.
@flint trail lots on the marketplace.
Anyone here ever try to make a replica of the Alien Isolation AI?
a tutorial on the Marketplace!? ๐
Oops. Lol. I guess I must've skipped the tutorial part.
I'd look into "Mr mannequin" add-on if your a blender user. Should have some tutorials on YouTube.
Also it's free.
I use Akeytsu to animate characters (Blender for everything else)
How well is it for rigging?
it's ... amazing
Try it, they offer free trial
it doesn't have constraints, but what it offers is super easy and enjoyable way of rigging and animation of the characters.
Thanks for the info. I'll check it out.
does anyone know how I could go about making my AI select a random EQS location without a custom generator?
or is it necessary?
I could think of either using a custom generator, or running the query in a blueprint
but I was thinking maybe there's an easier way?
Its not too hard to make a query, even with their janky tool
You can probably do most of what you'll need with their built in filters
Maybe I'm not understanding what you mean by custom generator
So I have basic roaming AI which can take damage if I hit them and flee when I am nearby. How can I make them flee when I do damage?
@rocky bison EQS can give you a random location from its result set. If that doesn't do what you need, just run the query in a blueprint using the Run EQS Query node, get its results, and pick a random value from the results.
@stiff gale You could set a flag on the actor or blackboard when they take damage, then reset it after a few seconds. Then just check that flag on a decorator
You could use EQS to get a location to flee to
So I'm passing an enum value in BehavivorTree using a decorator.
EBotBehaviorType BT = (EBotBehaviorType)Ctrl->GetBlackboard()->GetValueAsEnum(BBKeys::BehaviorType);
But it won't work. https://gyazo.com/28a94c685811631173ea83c4e544148b
I still get Passive instead FLee
Can you change the EQS context of a query at runtime? Say I want the context to be the target the ai is currently aiming at, which is stored as a pointer in a blackboard or something. Would it be possible to have that context always reflect the current target?
I guess my question can be summarized as, does the logic inside the query context run every time the EQS query runs or just once on begin play? (And for anyone curious I will be trying this later in the day when I have time)
you could have your target stored in the controller and have that as a custom context returning this value from the querier preferably via a blueprint interface and yes EQS logic runs every time on call.
Thanks for the suggestion, and info. Appreciate it.
Anyone know if there is a way to make the perception component do multiple traces to the target? It "looks" at the target's center. So if the player stands behind a low wall, obfuscating the center of the player character then the AI can no longer see you despite your torso and head sticking out.
Im not seeing any easy way of fixing it when looking at the exposed properties on the AI perception component
https://answers.unrealengine.com/questions/229043/ai-perception-only-can-detect-middle-of-player.html seems like this is the way to go
you need to implement the interface on the stimuli, and override the function IAISightTargetInterface and virtual bool CanBeSeenFrom(const FVector& ObserverLocation, FVector& OutSeenLocation, int32& NumberOfLoSChecksPerformed, float& OutSightStrength, const AActor* IgnoreActor) const override;
@olive crown
ah nvm
you saw that link ๐
Haha thanks, still
Just gotta figure out what all the params mean and how the function is actually used. CanBeSeenFrom is called when an actor with the perception component looks at you I take it? Or something along those lines.
Edit: Finding some info, so I'll figure it out in due time.
it is called ON the actor who the AI wants to see
Yeah, I got that part going now.
you just need to return the Location it can be seen from
and number of traces, and strength of the sight (normally just 1)
number of traces is purely for timeslicing/tracking
crucial is you return true if seen, and the location that it was seen at
return false if not seen
crude example is NumberOfLoSChecksPerformed = 1; OutSeenLocation = GetActorLocation(); OutSightStrength = 1.f; return true;
for example
Ah thanks. Looking around and finding others' code on how they are doing it. So I'm going through their code to understand it.
Thanks for the example too.
no traces, here, always true
if its inside the sight radius
(we use this for certain actors)
That is basically the default implementation, no?
Ah right, of course
more extensive example
FRotator EyeRot;
GetActorEyesViewPoint(EyeLoc, EyeRot);
FHitResult HitResult;
const bool bHit = GetWorld()->LineTraceSingleByChannel(HitResult, EyeLoc, ObserverLocation
, ECC_Visibility
, FCollisionQueryParams(SCENE_QUERY_STAT(AILineOfSight), true, IgnoreActor));
++NumberOfLoSChecksPerformed;
auto HitResultActorIsOwnedByTargetActor = [&HitResult, this]()
{
AActor* HitResultActor = HitResult.Actor.Get();
return (HitResultActor ? HitResultActor->IsOwnedBy(this) : false);
};
if (bHit == false || HitResultActorIsOwnedByTargetActor())
{
Listener.RegisterStimulus(TargetActor, FAIStimulus(*this, 1.f, TargetLocation, Listener.CachedLocation));
SightQuery->bLastResult = true;
SightQuery->LastSeenLocation = TargetLocation;
}
// communicate failure only if we've seen give actor before
else if (SightQuery->bLastResult == true)
{
Listener.RegisterStimulus(TargetActor, FAIStimulus(*this, 0.f, TargetLocation, Listener.CachedLocation, FAIStimulus::SensingFailed));
SightQuery->bLastResult = false;
SightQuery->LastSeenLocation = FAISystem::InvalidLocation;
}
if (SightQuery->bLastResult == false)
{
SIGHT_LOG_LOCATION(ListenerPtr->GetOwner(), TargetLocation, 25.f, FColor::Red, TEXT(""));
}```
this is not full code
but you get an idea
Perfect, thanks. I'll go through that as well. But you basically can use the ObserverLocation to trace against the actor that is running the function's mesh etc as well. To internally calculate what is seen.
right ObserverLocation is your AI location for example
IgnoreActor will be your AI's pawn
you then return true or false depending on if they are seen
and set OutSeenLocation, OutSightStrength and NumberOfLosChecksPerformed if you returned true.
Think I got the hang of it now. Appreciate the help!
remember IgnoreActor is your AI pawn, so when you do traces, make sure you ignore it
Just gonna go through your code and the others as well to get a deeper understanding.
Will do!
Yeah was thinking of whether to do from actor being seen to observer or the other way around
either way, depends what complexity you need
i normally do traces from 6 locations
head, arms, chest, pelvis
we don't bother with legs
5*
Thought of something like that too. Thanks again for the help.
So I need to have a simple NPC/background characters to flesh out a city/level environment - (nothing crazy, just simple walking) I downloaded a pack that has it setup already but I wanted to outline what I wanted to do to check if I have the right approach
just as prelim
1 - Simple enough for me to add splines to the level and modify the basic BP to randomize which skeletal mesh is used, and I would just call these Roamers
2 - But I want to make an area that a crowd gathers around close by which stops the navigation - (easy enough to cast to any AI controller crossing that boundary and setting state to loiter)
So the idea is to make a BP_Crowd that does two things - 1 - Spawns a random (and editable) number of NPC's positioned towards a "look at point" , randomizes their materials (I have 6 basic meshes but I made about 8 different skin/color TGA's for each material (and the materials themselves obviously) so I can randomize them and even reselect it it picks the same material) - this will also give them an animation sequence for loitering, things like taking a picture on cellphone or gazing far off in the distance
Finally this BP_Crowd stops any "roamers" dead in their tracks and assigns them one of the "look at animations"
hopefully this outlines what I want to do clearly enough
After my AI is dead, the Ai still rotates as it lying down. It disabled its brain logic. IDK what's wrong?
Disable it's controller or unpossessed it.
I've done it https://gyazo.com/e5532388e4744760a039fb0c1d4f34de
Is there a way to move where the ai's sight originates from? It is a bit inconvenient and appears to be arbitrarily set at an approximate "head" height. Would have been nice if you could tweak its position.
it seems to originate from somewhere to the left of manny's neck in this case
there should be an eye level property on Character iirc
or eye height or whatever it was called
Ah that is something at least, would have been nice if you could define the X and Y positions of the "eye" too.
I think there might be, see how the eye height value is being used, that should probably lead you to where that can be adjusted more
Good idea, I'll do some digging
Since as far as I know this system is inherently flawed since what if the character's head moves in some way, then, then the vision cone does not move with it.
Yeah, I think it works fine for most games tbh but there could be edge cases depending on how you've animated your character where it might look weird
Exactly, I do a trace from the actor being seen to the observer and it sometimes misses the mesh because the origin of the sight is not attached to the head joint. I guess I should trace against the capsule or something.
Gonna take a look, thanks!
This did the trick, thank you very much. Made a custom socket and it is attached to that now and moves with the head as it should. Also don't worry about his inability to hold a gun, poor guy is still learning. ๐
Can anyone here breakdown the logic of the AI in alien isolation? I watched a few videos of it on YouTube but doesn't really break it down.
That would be quite a massive breakdown I think. Maybe there are some GDC talks on the topic?
BT Run EQS Query has an option for making the query dynamic by Blackboard key. This sounds great, but I did not get use ot of it. On Blackboard keys theres no EQS Query type, I also tried some objects of Envirnment Query, but seems not correct. How do I add a EQS Query do Blackboard so i can choose that EQS blackboard key here ?
Lol. Ya I know. I'm just trying figure out how does it search a corridor. It knows which area the player is in but how does it go along searching for the player. I need your opinion, do you feel like it's giving a random location to go too when it's near? Or more of a calculated location?
Hmm. Just found a page that is a alien isolation mod that allows you to change the behaviour tree and view it of the Alien. Here a link if anyone interested. https://github.com/MattFiler/OpenCAGE
Cool find! My guess is that they use something similar to unreal 4's EQS system. Using that you can set up all kinds of searching behavior and look for potential points that the player is close to etc. https://www.youtube.com/watch?v=iY1jnFvHgbE take a look at this if you haven't already. Especially the EQS section.
In this presentation, Epic's Paulo Souza uses Unreal Engine's built-in AI features to build smart enemy behaviors for a game with stealth-like mechanics.
By relying on the Gameplay Framework in Unreal, we're able to quickly create convincing AI using Behavior Trees. Behavior Trees are great for creating complex AI that can be presented in a way...
Actually I haven't. That seems perfect for what I want to do.
https://www.youtube.com/watch?v=ii9jMKsb-vs&list=PL4G2bSPE_8un8IplTvVrqPRt7Ey8-3obR this playlist has a lot of stealth game AI stuff as well
In this series we are creating AI and player interactions for a stealth game. This will include stealth movement, patrolling guards, takedowns, and alert phases.
In Part 1 we begin work on our player's stealth based movement starting with crouching.
SUPPORT ME
Patreon I https://www.patreon.com/ryanlaley
Buy Me a Coffee I buymeacoffee.com/RyanL...
Only watched a video or two from it but seems pretty good
Also I got a question, I made AI using blueprints, which walk smoothly on a spline and its head tracks things, actors blueprints, when walking by. Would this be easy to implement into behavior tree? I'm a noob when it comes to BT.
You mean the AI walks along a spline and detects other actors?
if so, you should use the AI perception system, the playlist I linked covers it. As well as the video made by Epic.
Should be enough to get you started
Sorry what I meant was is it easy to implement my custom "move to" in BT? Id test it but not at home.
Depends on what you want to do but yes it shouldnt be a problem. You make your own custom blueprint task that runs in the behavior tree.
Thanks for your help and info.
So I've an AI controller and I've some code in it. I also want to create a detourCrowd AI controller. How can I share the same code?
I'm having an issue with a navmesh, so I have made a door that will stay closed and will open when an actor goes near it, I have made sure the door opening is big enough for the AI to walk through. When the door is open I disable collision on the door components but the navmesh doesn't seem to be updating
Here is my collision code which is called when the door is enabled using the enable boolean variable
and here is the door
hey all. Is there a way to have player controlled pawns run behavior trees?
I know it seems counter intuitive, but with the non-AI version of the task nodes I was wondering if its possible
what does MinQueriesPerTimeSliceCheck do? in AISense_sight
default value is 40
is this the rate at which AIs consider whether actors are inside/outside SightRange or PeripheralVision
I assume that you want to implement some sort of helper function, say a cortana? Also curious is your idea involve multiplayer at all?
Cause AI controllers aren't replicated. Also, I think the debug drawing might only look for ai controller run BT
(note, my info maybe way out dated since last time I touch AI is 4.16-17)
Is it ok performance wise to use DetourCrowdAiController instead of just the AIController? I know that it's mostly the same and first one helps AI navigate better when they are crowded
BT Run EQS Query has an option for making the query dynamic by Blackboard key. This sounds great, but I did not get use ot of it. On Blackboard keys theres no EQS Query type, I also tried some objects of Envirnment Query, but seems not correct. How do I add a EQS Query do Blackboard so i can choose that EQS blackboard key here?
could you go into more detail on the first point? I still can't figure out how to do that, and would love to learn a different way than running it in the BP
you can see the option in the screenshot above
"Run Mode: Single random Item from best 5%"
there's some other options for it as well
yw
Hi, so i'm working on my custom A* Pathfinding algoritm. Till now i made use of a grid of nodes (100cm each), but this seems way to expensive in memory. (a 8k map would mean 67 mil nodes)
So i thought about using quadtree, somehow
anyone could give me some advise?
I did this a while back. I think I just made a static mesh and instanced the shit out of it. Using a line trace to detect the ones next to it.
so I know this convo happened a long time ago, but just to clarify, OnBecomeRelavent() is essentially the same as the blueprint "Event Receive Activation" node right?
also I think you made a cpp ai tutorial at some point but I couldn't find it
hey guys, so im quite new to AI and im trying to get quite a few melee AI to work. its not going great xD lots of clipping and stacking and circling my player and getting him stuck ๐
i think what i need is a combat director ? something to select a few enemies, let them know they can attack. and kinda control that combat flow. is this the correct train of thought and is there a good place to find resources ? i couldnt find much, perhaps my search terms are wrong though. not 100% sure what im looking for.
Here's a really old video that I found very helpful when I first started. https://youtu.be/Uhv8ezl4uZo
So This Video Interests You? GREAT! Vote for Us on Greenlight.
Steam - http://steamcommunity.com/sharedfiles/filedetails/?id=317245256
We need more games like this around. Thanks.
In depth here at the UE4 Forum Wip Thread - https://forums.unrealengine.com/showthread.php?47183-Alice-in-Tokyo-Wonderland-Blueprint-Only-Action-Hack-n-Slash
Alice i...
Does anyone know why SetControllerRotation() isnโt working for me on my AI Controlled Character? Please can someone help me out, thank you :))
what are you trying to do?
im trying to set the rotation of my character
can you share the code ?
i just try to do this but didn't get any result
i just checked that control rotation will not rotate the player ... it will just rotate player view angle
Just set actor rotation.
yeah or you can also change it focal point... that will also work
Any idea why my MoveTo is invalid. Anyway to debug the EQS which is setting HidingSpot
use EQS testing pawn to check the points ... also debug it in play mode....i think move to is not getting location
Yes EQS suppose to set the location. WHere in the EQS test pawn you set which player to check?
its looking fine
Trying to see how the location value looks like
debug it in play mode
also check whether the nav mesh is active .... because sometimes in my case it automatically get disabled
See the dinstance to QC_FindEnemy. It won't run. https://gyazo.com/25f7416c7b1a2bcbf3a5ac67523f2395
can you tell me what are you trying to do?
because i just hate eqs because in most cases it wont give results as expected , so i just create my own logic for that
Also not a fan of EQS or even behavior tree. But EQS has its merits though it does seem costly. Is EQS actually costly? Performance wise.
It depends on what tests you're running
It also has timeslicing so slower queries won't tank your framerate so much
Would it be cheaper to just make bunch of vectors, "points", and do the same test as EQS?
And when I mean make a bunch of vectors, I mean in a custom shape needed. Instead of the ones they provide.
Is there a good way to have AI navigate large open worlds that arent entirely nav-meshed? Im using envokers to generate my mesh and cant think of a good way to get them to travel to areas outside of the generated nav-mesh
You could create splines and make it follow along those path, but anything character movement related won't work.
Im sorry, so would the player during runtime be drawing these or would I set up "roads" for the ai to follow
But it's a set path and won't be able to avoid any obstacle.
You'll have to draw them yourself.
You could make it dynamically as well, just need to know what you want.
And by that I mean how to calculate it
I was thinking of a system that would use ray traces to find clear paths with suitable terrain. Is this what you are thinking?
Ya pretty much.
Sounds like a fun challenge. Ill give it a shot. Thank you!
Lol, have fun.
If I want to set speed for the attack, roam and flee behaviors. Should I create a service, decor, or task?
What is best way to optimize nav agents? I have semi large map "World of Warcraft" style and i have couple small villages with roaming npc's then I have enemies roaming. Should I make volumes when player enter certain zone it activates all ai's (on overlap->activate all actors of class)?
can someone help me make how to make ai will chase us when we shoot him thanks
You can look into the AIPerception component. It has a sense called damage you can add
how do i make it work tho i tried it but i have fking idea
This video might be helpful
https://www.youtube.com/watch?v=g8rz7aZyDMs
yeah i follow this one but i dont use the tree thing
You should be able to do it without a behavior tree though. But its a lot harder to keep track of as your AI gets more advanced
hmmm is there like other way to make this ?
You might be able to have it trigger on this giving the location of the actor or actor that hit it and have the AI go to that location. Should do the same if its set up right
Has anyone tried using utility ai in unreal 4 instead of the default behavior tree method? There are plugins for it, even a free one. Though I cant attest to the quality of it. BTs are getting in increasingly annoying to work with. And using something like GOAP or Utility AI would have been nice.
hello can you tell me if NavigationSystem->FindPathToLocationSynchronously(this, GetActorLocation(), TargetLocation, AIController); uses the default navigation query filter that you set in the AIController?
the code probably tells you the best
i tried going inside it but i just got lost xD
I'm not sure if you can just pass the controller instance as a UNavigationQueryFilter parameter to the function
it doesn't seem to be an interface of any sorts
How do i make an AI follow a spline path?
Depends on if you want to lock it to the spline or just follow along it with regular movement
The last parameter to the function call is the filter class, UNavigationPath* UNavigationSystemV1::FindPathToLocationSynchronously(UObject* WorldContextObject, const FVector& PathStart, const FVector& PathEnd, AActor* PathfindingContext, TSubclassOf<UNavigationQueryFilter> FilterClass)
yes i know
Yeah, so if you pass the default filter as that parameter then it would use it
i was using that with AiController->GetDefaultNavigationQueryFilter()
i was asking to know if i can get rid of that
if he's already using it
if you don't supply one
and leave the parameter with nullptr
If you look at the code for the function there's no logic in there that would attempt to cast anything into AIController
i'll leave it then to be safe
It's usually a good idea to be explicit with parameters anyway so it's clear what's happening :)
thanks ๐
How big was your tests? i dont follow it really
Why would using mesh take less memory?
I'd like to try both to set how it looks
well if you wanna lock it to the spline, you'd just move the actor on tick or something and get the spline position and such and move it there... for moving along the spline, you'd just keep incrementing some value that gets the next spline position, and keep adjusting the movement target
Any good examples of this - my use case is just general pedestrians, so staying on a sidewalk - would you just recommend making a nav mesh with some target points, and weighting the street highly so they don't go on it?
That sounds like the way I'd do it at least
Is it less/more performant to do multiple nav meshes and just use exclusion volumes? is there any hit to have one over the other?
in this case, I'm going to draw one big one but I only really want them to walk in the sidewalks so I should just draw a few there then I won't need to have so many exclusion volumes?
I'd imagine it mostly affects the navmesh generation time which is in editor anyway, and some amount of memory needed to store it at runtime... I don't think the navigation itself would be any slower, since you'd specify which navdata is used and it'd only calculate on that one navmesh
I'm actually working on a game which probably eventually will have some pedestrians and such walking around so I'll need to look into this some more at some point as well :P
well if you need help jogging your own memory, I'm sure I"ll have questions soon
like : what should I look into for finding out what is not drawing the nav mesh there?
If it's not generating there's probably something that is in the way, it looks like you have some kind of a trigger volume or something in there?
it's possible that the hitbox of the streetlamp also causes it to not have as much space, which causes it to not be able to generate the mesh because of the settings
one easy way to test what's causing it is just move anything out of the way and see if it generates correctly :P
That's what I tried doing, let me try another object here
Why is she sliding across that gap like that?
so how can I adjust for that,
That or how do I set navigation stuff on a BP? do I need to set it on the static meshes themself?
I don't remember but I think it was 500x500. It's low cost because it's instance static mesh. Means it only needs to do one draw call per frame for all of it. There may be better solutions but this very simple to do and barely takes any resources at all.
Having a nightmare with the nav mesh generation and accurately being draw - anyone recommend good nav gen settings?
ah - fucking trees I knew it
Here is my problem - I have BP spline actors messing up the nav mesh - how do I fix that, when they are procedurally generated - it probably involves modifying the construction script but I'd need to know more
Splines shouldn't affect navigation unless you're giving them colliders
You can disable can ever affect navigation from them if so
Yeah it was that "draw collision below" that needed to be set on
once I did that for those power lines and the trees it drew better
if you mean them floating slightly I think it's a collision issue on the mesh
In the blueprint the mesh needs to be align with the bottom of the collision capsule.
You mean this? @night thicket
that's the BP I'm using and at runtime it swaps out the manniquan mesh to another one that uses the same skeletal mesh
I notice these are different from the epic one, epics are this -
Ya that. Probably have to find out the z value of the other one first and set it's location according.
Hmm. Does the engine put the mesh in the middle of the capsule?
theirs -
Not on my PC. But I would just change the z
epic -
Z of the mesh. Not the capsule.
And get it align to the bottom perfectly as possible.
well it's more like this on the epic one too
But because you switch out mesh, youll might get the wrong results.
Should change the mesh to the one you want and place it. Than return the mesh to whatever.
ah of course
this is rough - there are 6 different meshes i am just randomly swapping them out
so I'm going to either need to modify the script that spawns them to add a relative offset to the mesh of the BP?
I know it might sound like an hassle, but do you think anything else gonna step on charts head?
Cause if not, you could preoffset your skeleton mesh so they all use the same offset
(note, I don't know if this would break the animation or not, I assume that skin weight is imported as well not generate/bind on the fly to the standard skeleton)
I'm adjusting it after the fact on the mesh BP, adding relative offset like this
where capsule is root
You are switching to different char with different height, so you would also need some retargeting as well later.
my problem too is the idle animation seems to sit higher than the walk one
This is the tricky part @ebon zenith - it's like I have to choose between which time it should be positioned correctly - walking or idling -
You shouldn't have to. Remember to check your animation so they are done properly. If the animation is correct maybe don't mind the first idle. Ie check when you transition from walk to idle again and see if the feet floats.
Also this is less AI related, if you still have issues, #animation may be a better channel
Anyone have experience in making a director AI?
I am thinking of a simple ai which roams around map and shoot player.I am thinking of implementing it in BP.DO i have any advantage of implementing it in behaviour trees
The only difference I could tell is that BTs is more organized.
If you're good at organizing your scripts and know what your doing than BP should be fine. Also EQS can be run in BP.
I need some help to make a Ai in UE4 can anyone help m e ?
Can you anyone tell how to do this : Ai Follow Another Ai with Ai Move To Blueprint Code . If can me message me
There are a tonne of tutorials covering this kind of stuff. For instance, check out Ryan Laley's tutorials on youtube.
If you can make an AI follow the player, you can make it follow another ai character
send me video
Just look it up on YouTube. Searching it wont took more than 3 minutes, unless you have absolutely shitty internet connection.
As Brown Sugar said, if you can make AI follow the player, you can change it to follow another AI Character.
Try not to be too rigid about it 
heya, i've been having trouble implementing the attack animations for my AI enemies, i've got the movement and idle animations working by checking the velocity of the character and alternating between movement and idle respectively, but i'm unsure as to how to tell whether the character is ready to begin the attack animation. i've got a damage system already in place which uses an enum system so i tried to use that for triggering the animations but it doesn't seem to be working. would be willing to hear other approaches to this or a way to fix the enums approach
Thanks in advance ๐
i used this code to get the speed and location of the ai and the player character, and checked it against a certain range where the 'combat' enum should be triggered on
is it possible to have different cell sizes for different recast navmeshes? is so, how?
I don't need the same precision for all sizes
but if I change any of these setting the engine just ignores them
and keeps using the same ones in project settings
It's more an animation setup/blueprint problem than a AI problem. You need to learn how to setup a state machine and animation transition/blending with just the anim BP before your use the variable updates from AI to drive that animation.
Thanks for your reply.I want my ai to pick a gun and it should go to that gun location as soon as it lands..Is it possible??.It is for a battle royale game and spawn items are random
Everything is possible, just need to know how to do it. But as I said BP is a spaghetti mess and if your not really comfortable with BP than going BT is a better route.
okay
The image on the right shows an actor, there's navmesh being generated inside the actor (this can be seen on the left image), I'm trying to do a "circle" EQS around my actor but the circle locations from the EQS are being generated in the inside area of the actor, instead of the outside, regardless of the radius I give to the EQS, is there a way to fix this?
Hey does anyone know how I can add an or statement in the behavior tree because ive been using decorators but all of them have to be true to run the task
If you want an optional branch use a force success decorator on it
you can also use a Selector node and put the choices under it, since it will keep trying nodes until one succeeds
My game crashes when I try to use a navmesh beyond a certain size (across many tiles of a landscape). Can I just have multiple adjacent navmeshes? Are there any downsides to this ? Can they overlap without issue?
for static navmeshes*
does anyone know good shooter AI tutorials? I watched all of "Ryan Laley" tutorials and I want to learn more
Hi guys, I'm working on a behavior tree for a worker npc who builds structures
it works by reading the build task specifications from a blackboard variable, and then it just tells the actor to go and play some animation while keeping track of time
what i'd like to know is, is there a way to decorate nodes so that they are selected for execution only if a function called on a blackboard variable returns a value that satisfies a condition?
for example, i'd like to decorate a node so that it only triggers if the return value of the function GetProgress, called on the blackboard variable Task, is < 1.0
do I have to make a sequence which first calls service that stores the function output in a blackboard value, and then checks the blackboard value?
Why can't I find this node? I made a new in the blackboard and I can't get this condition (to then access that key) to come up - I can copy this one but I want to know what it is called - I'm confused about why I need to make a new decorator (when I dbl click on the existing conditions there, they don't take me to a new Blueprint like hitting new decorator does)
it's just called "blackboard"
ugh, thank you
I mean how do I make a new one of those? I want multiple conditions based on the enum state (i added a new enum) - I was able to get it to work but just copying that condition node there but I want to know what it's called in the menu
It's a decorator, not a task
So you need to right click one of those nodes and then choose add decorator or whatever the option is called
why wont my service run in my behavior tree?
and did they remove event receive execute?
I don't see condition here
it's called Blackboard
Less of an AI question but might be relevant - I'm spawning AI characters from random points in that collision box - but they stay floating in the air - WHY?
I've disabled "player can step on" and the box is set to overlap all dynamic - this couldn't be a nav mesh issue because this isn't navigation, it's gravity - why are they floating there?
@misty wharf can you advise?
Characters don't follow physics, they use the CMC to fake it
ah
I think there's an option to make them not simulate physics if they aren't possessed, so that could be one reason
otherwise there's probably something that collides under it
that makes sense, I'm glad you told me of that concept because it seems extremely important
So basically try to get that CMC and set it to simulate physics?
why wont my service run in my behavior tree?
and did they remove event receive execute?
I also have this weird issue when my AI are falling through the floor, as though the game loaded simulate BEFORE it loaded the ground's collision - but again, it's not everytime, so I am very confused
The CMC should have an option for something like "simulate only when possessed" or something like this... if it's not possessed and you want it to simulate you need to change that setting if it's in the wrong mode
Can you help boop_xyz if you know where he should look? he is being patient
any reason why?
what does the breakpoint show you?
I mean, does the cast fail?
Real quick - are you using F9 and setting a break point
I believe so, even if the task is waiting .1 second....
okay, so this is more important thing
select that CAST node and hit f9 on it - youll see a red dot appear
yes
then when you hit play, the game will run that code and pause there, and you can 'step' through each execution
more importantly, you will be able to view the value of variables realtime
when i click play it just plays
so you'll see if that reference is valid or not
then that cast event is never firing
so the event tick isn't runnin
so that actor doesn't exist
Anyone knows if EQS generators are instanced (same goes for the tests)
@granite robin the cast is failing
so that thing doesn't exist
so the receive tick event isn't work - go to the blueprint that is supposed to be sending that
make sure that 'expose on spawn' is checked if you are passing that owner variable
so where do i tick that>
on the item that is failing?
So, something has to be SENDING that event tick
did you watch the blueprint communications video?
Announce Post: https://forums.unrealengine.com/showthread.php?101051
This Training Stream takes a look at Blueprint Communication. We find that Unreal Developers of all levels can sometimes struggle through the concepts behind moving data between objects. So in this video we'll take a look at the different ways to make Blueprints talk to one an...
this will help immensly
no, trust me
you'll become a wizard after watching that
you've already spent 30 minutes trying to figure this out, there is so much conceptual wisdom in this video
but you can try using Get player controller and plugging that into the cast
could you tell me how? cause i don't got much time until I have to do something
then just do event tick (which you should be aware of the cost of using tick)
ill be sure to watch it
your problem is also more BP related than AI
plug that into your cast node and use event tick for now
then use get actor of class, and put first person controller
note - Get Actor of Class or Get All Actor of Class can also cause issues
think of it like duct tape - you can use it but it's better to understand where you are getting your references form and setting up your BP communication effectively
Yes, you learn Unreal like I did, piecemeal and just plugging things in until they work - my advice is to force yourself to be patient and watch some of these conceptual videos as soon as possible
when you hit begin play, is this present - you should see the name of something there
yes
@misty wharf I can't find simulate on the CMC...
it says SetFreddyVar
so the set event never happens so you go there
go to the BP that is supposed to set the boolean
pull everything out of that function
Plug it into event tick directly so you can step through it and see the values
gotcha
functions are great when everything works but when you are building/prototyping you want to not use them because you can't see variables inside of a function easiyl
Hey so in my BT Task Node c++ class in the execute task function Iโm calling AIController->MoveTo(Player) and it works perfectly fine but when I go to project settingsโ>Framerate and use a fixed frame of eg. 40fps, then my character moves at a different speed?
I want my character to move at the same speed no matter the framerate, please can someone tell me how I can achieve this, Iโm really struggling!
Any help is much appreciated, thank you! ๐ฆ
alr its taken out
this is what it's called actually
put a break on the tick see what the hit result is
and look at what it was - ah HA @misty wharf thanks for the help
how can i see what the bool is?
show me your linetrace results
no idea, fucky collisions
hover over different nodes, like the yellow vectors and it should tell you their current values as long as you don't have it inside the function still
was the cast failing?
show me
no, show me the BP
and the variable seems fine
put a break on the node RIGHT after the "get boolean value"
done
the variable is false
the Set Blackboard value says thi
"Variable is not in scope"
the string is returned as ""
when that says "no controller' does that mean player controller or any, because these have AI controllers
any
hmmmmmmm
first, rule out this as a blueprint problem - make sure you can get the one value to update on the other blueprint - for now, manually just set it via blueprints, don't use blackboard
yea the value isn't setting correctly
@misty wharf So this SEEMS hacky as fuck but it works - it's just an event I run at the end of that AI begin play
Weird ๐ค
I thought it was because I was using editor simulate mode - but it happened on regular play too
you know what - it's probably a level streaming thing
that's what it is, I'm retarded - I added these actors to my main (but empty) level, and then the other level is streamed in - so they fall because the streaming level doesn't exist when they start
Oh yeah that sounds like it could do it
yep - i moved them to the correct level and disconnected that function - whew I must be learning, in the past this would have been hours and hours
does anyone have a link for an in depth explanation of these settings?
How can I set my own AllowedTypes in FBlackboardKey in C++?
Making noise is not getting picked up by my AI NPC. https://gyazo.com/6281d0532ab7143ae00657380c9b4b50
Any idea what's wrong?
are you using AI perception?
Yes
I got it fixed. Thanks
okay I tested some stuff
the variable is correct, the set blackboard value is not working
Hello guys.I am making a battle royale game which spawns AI.It has guns in random locations.I need ai to move to that gun location using EQS.I am using blueprints to do that.Plz tell me how to do that??.Thank you
As long as you know how EQS work it's really simple. Setup your EQS parameters and than just use RunEQSQuery node.
Than pull the results you need.
Bro i tried it.But can you post some example on finding an item in a map.I tried it using some tests.But it is not working.PLz post a example or any refrence of finding an item in a map near to it
https://www.youtube.com/watch?v=iY1jnFvHgbE Someone gave me this link before. Just skip to the EQS part.
In this presentation, Epic's Paulo Souza uses Unreal Engine's built-in AI features to build smart enemy behaviors for a game with stealth-like mechanics.
By relying on the Gameplay Framework in Unreal, we're able to quickly create convincing AI using Behavior Trees. Behavior Trees are great for creating complex AI that can be presented in a way...
okay
UE4 beginner here: I have setup an AI Blueprint class and was wondering how can i make it so the blueprint class doesnt get spawned with the same mesh i gave it in the Viewport but with different meshes all using the same AI Blueprint? Do i have to make childs or can i do this with blueprints ?
it kinda depends on how you want to set it up, but creating child blueprints from it would be one way to do it yeah
you just give the child bp a different mesh
Is there a possiblitiy to make it with blueprints?
what do you mean?
for the gameplay i followed a simple tutorial on youtube which helped me build a simple horde game. He uses an array and stores the one NPC into an array and all that. So i was thinking instead of having to feed in child actors everywhere now maybe i can just instantiate the actor with a different mesh anytime he gets spawned
Right, yes it's possible to do that too
There's two ways to do it: Spawn the actor, then set the mesh on the spawned actor, or you can set up a variable in the actor which you set to expose on spawn, and in begin play or construction script you set the mesh from the variable
the expose on spawn method makes the mesh variable show up in the spawn actor node, there isn't really a huge difference between them otherwise
So the 2nd method would spawn the actor with the correct mesh right away the first one with a short delay? I would prefer 2nd then thinking of performance
There's really no delay on the first one either
since the logic gets executed within the same frame
what would the variable for a skeletal mesh look like ?
just a regular variable with the type set to skeletal mesh
or how would i get it from content browser into somewhat of an array or list
Ah okay, and this i set to list and loop through it to select random meshes for each actor spawned
i will try this
yeah that should work
there's a random from array node btw so you don't need to loop :)
nice ๐
Navmesh Lazy VS Instant ? what's the difference?
How do i get "access" to the BP's skeletal mesh via blueprint?
cast to it
i did it like this: with mesh01 being my new variable
you mean in the same bp the mesh is in? just drag it in the screen
i want to "override" it so i can add different skeletal meshes for one BP NPC class
yeah you do that like you did
not sure how you got that weird mesh node though as it should look like the mesh01 one
the target one was auto created when dragging the pin from the block before
the block before?
the SpawnActor BP_Zombie
this would be my random selection from array does that work ?
I dragged the pin from SpawnActor BPZombie and typed in Set skeletal mesh then the target self mesh got auto created
which should be fine
no you would have to provide a random stream, you should really post in blueprint for this sort of stuff send me a dm and i can help you out
Is there any way (in blueprint) to get random points in an nav mesh - I want to be able to place an AI down randomly anywhere that a nav mesh is drawn
But is it a random point IN the navmesh?
no
as far as I know you could do that ony in C++ but if i'm wrong i'd like to know
you could get a random point in navigable radius ?
but you would have to provide a validish origin point
Hey guys so am creating a projectile path using the Predict projectile path by trace channel node.
When the trace path is checked for some weird reason AI perception stops sensing the player.
Please help.
how are these determined?
how can i make someone friendly, neautral or an enemy?
It's done in C++ using IGenericTeamAgentInterface and setting an attitude solver function into the team ID system
got it. Thanks!
Why are my AI drunk ? they keep wandering OFF the nav mesh and then this insanity happens? Why would they SLIDE like that?
@misty wharf can you advise?
Avoidance would be my guess
sorry to randomly ask a question after saying nothing in this server for a year, but I'm having trouble with ai movement
I have a horse character, and I couldn't get the smooth turning I was looking for with the regular character movement rotation settings, so I set up a thing where the horse always moves toward a "rotation target", and side to side input rotates that target around the horse rather than the horse itself
this works great on the player, but the ai ignores it and uses the regular movement input that the player can't access
is there a way I can make the ai use the same movement system as the player?
What would you do to fix it?
I don't understand the sliding???
if you're not using avoidance then it's not that
it kind of looks to me like the mesh is not in the center of the actor for some reason
try making the collider visible while playing so you can see if it's in a different place
not really sure what could be causing it, unless you have some logic that moves the mesh instead of moving the actor
good idea standby
doesn't appear to be the issue - i don't understand why it SLIDES, even if the navigation is off
So I need to check the mesh references maybe?
this is what is firing on the BB on the afflicted actor
well it doesn't look like the mesh is disconnected from where the actor is, since the capsule is the root component
which I removed and added just incase the BP instance was bugged
it also is possible that a force is being applied to it via physics or some other reason
nope, not any on there
but you should try to identify what it is doing the moment it starts sliding
eg. which BT task fired just as it starts
and then find what BP nodes are being ran
this way you should be able to identify why it does that
not sure where to put a break point
if you have the BT open when it starts happening you can just pause and it should show you where it's currently active
okay that one I showed you didn't fire and I watched her slide so it's probably not the culprit
you may have to add some logging since these kinds of issues can be a bit hard to catch with breakpoints since they often fire a lot during execution
another thing could also be disconnecting parts of your BT to see if it helps
it should at least help you get closer to what specifically is causing it
good idea - originally i had bought a pack because I wanted a simple pedestrian system - it was working fine yesterday
simulate isn't an issue right?
I watched another slide before that BT breakpoint hit (it hit right after but that means it's not the culprit)
No idea, I haven't really used simulate mode much myself
why do I feel like I know this is going to be a really stupid thing when I find it
I don't think that's related, the mesh isn't moving out of the character (it remained within the capsule)
I don't really know what you'd be looking for, you just need to identify where the code is when it starts sliding
and not a nav mesh issue?
hence disconnecting parts of the BT to test if it helps could help reduce the amount of code you need to look at
It doesn't really look like a nav mesh issue specifically, since they appear to be navigating normally otherwise
what woudl PUSH it????
hard to say if you haven't got anything that would apply forces on them ๐ค
I have no clue what that is :D
are you using crowd or rvo avoidance?
nope
not that I'm aware of - I'm using a AI Queue system but I can't find anything on his BP that moves the character unless I"m missing somehting
okay, it kinda looked like the behavior of how avoidance pushes pawns around
not sure what the AI queue system is, I guess it's a marketplace plugin or something?
so guess what
first off, that wadstein guy is a god
looks at the video and after a few question says, 'is there collision on that cell phone you are attaching? "
oh
lol
I've actually had that same issue with attached actors where it causes movement to become weird
told you it was going to be stupid
well you couldn't really know it would cause that because you'd think attaching them would make them not collide with itself but it doesn't :P
Does that happen if you have it as a component on the BP itself?
I think only if it's a separate actor that you attach
I considered just keeping it on there and toggling visbility when I needed it but decided against it lol
I have a pickup system on my npc's where it just toggles physics and collisions off on held items
Is there a way to spawn AI randomly on a nav mesh? I can't get anything from the nav mesh itself and I wanted to spawn them there because I know they would be in the right spots - but I don't want to place them manually
get random navigable point in radius would probably work
I'd imagine there might be some other method for it in C++ if you dig more into how the navigation data is laid out in there, but at least that method is available in BPs
HELP: The AI stops sensing the player once i use the predict projectile path with trace path checked....is there a work around this
From what i understand correct me if i am wrong is that the AI perception uses a line trace for sight detection
And when you use the predict projectile path node with trace enabled it blocks the AI sight and sight detection is unsuccessful
Is there a way for the sight to ignore traces???
I've heard that the behavior tree/black board system isn't as performant as just using blueprints for AI. And that unreal has more or less stopped working on behavior tree. is that true?
Where do people hear these things
Sight uses a linetrace with a configurable channel in project settings. It shouldn't be affected by doing other traces, but if you have something like a collider that blocks on the sight channel, that would stop it from seeing through it
@misty wharf Thanks just realized i have a collider that is blocking it
Very doubtful, if anything its getting improved on. Unless a new AI system replaces it like a neural network one. I doubt that too.
There's some kind of a weird idea with modern development that if a feature X doesn't receive any new functionality it means it's abandoned and you shouldn't use it
Except... it just means it works and it does what it's supposed to :P
i mean there is additional overheard to using BT, sure, but its very minimal
if done properly
that too :D
DLC can be free you know ๐
Tbh I prefer to make my own BT through blueprints as I can do a lot more without going back and forth between them.
sequential abortable latent actions are not exactly fun to do in BP's
but I guess if you don't need to sequence actions in such a fashion then you might not get much benefit from using BTs
Actually I found a way to get around stopping and use a switch on enum for whatever "task" I need.
yeah, but you basically need to build all kinds of state management into the BP
where in a BT you can just put the nodes in a sequence and it'll just work
when my AI walks towards the player... it tends to try to walk through an object... is there any way for the ai to walk around the object to the player?
i turned off effects navigation on the object
but still didnt help
If you turned that off it means it will not affect navmesh generation, as far as navigation is concerned it does not exist
it needs to affect navigation, then it should prevent navmesh from being generated under it and the AI should be able to avoid it
@misty wharf if i make that true... they get stuck on the object (table) and eventually move to fails and they lose target
Where are they trying to move?
And is there an actual navigable path to what they're trying to move to? (press P when the viewport is active to make the navmesh visible)
they are trying to move to the player
looks good to me
if you stand further away from the table do they still get stuck on it?
it could be that your position is slightly outside of the navmesh
its weird that even if stand a bit far from table... it tries to colide into it
one of them doesnt because he has a clear path to me... the other one keeps coliding with table
until it slides through
if i m far far away from table then im good
Could someone help me out with AI and Behaviour Trees? I have this BT which basically moves the AI to player. Now i want to get into a new state which would be an attack state that only enters when the AI has reached the "acceptable Radius" of the MoveTo... task. How would i do that ?
You could draw out the way points to see what's it doing. I forgot what the node is called but I'm sure a quick Google search could help you there.
You'll need to add a debug point to the array.
thanks it was my custom pathfollowingcomponent
something like this so ai seems a bit more realistic rather than walking in a straight line
how to spawn many NPC, then they walking to the Player to attack?
Do you know how to spawn anything?
Is there any way to turn off "Track moving goal" on Move To in Behavior Tree from blueprints? I'm making a dash for AI but with "Track moving goal" it will track players location mid air instead of dashing in the straight line, with that turned off it works great.
@cosmic heart You could probably get that by storing your target as a location
@glossy spire What do you exactly mean? I'm storing all the targets in the blackboard, but I couldn't really do anything useful with blackboard to change that move to option.
I havent tried it myself, but you could try setting a vector blackboard value, and use Move To with the vector as the Blackboard Key target
rather than using the player pawn
Maybe I'm just misunderstanding the problem
I think you are talking about making a custom task for a move to instead of using the vanilla one in the behavior tree so I can tick off "Pathfinding" when I want which I think behaves as "Track moving goal", I was thinking about it but I hoped that maybe there will be a solution that is less of a headache
So I've an AI that checks if the player is in range moves to its enemy then starts attacking. How can I adjust its movement to its MeleeRange. If the player moves in closer to the AI, it missed most of its hits.
Depends on what move to node your using.
Also you could use a look at node on a timeline when in range and keep its rotation on the player.
How can I prevent the path from being generated so tight to the edge? Or else, how can I avoid units struggling like this to path around them? The actor is navigating around a NavModifierVolume that's generating a non pathable zone 50 units away from its true edges (As NavAgent radius is 50)
This is how I'm generating the path:
// TargetLocation is a FVector paramenter on the method
// OwnerEntity is the actor you see on the video
UNavigationSystemV1* NavigationSystem = FNavigationSystem::GetCurrent<UNavigationSystemV1>(GetWorld());
UNavigationPath* NavigationPath = NavigationSystem->FindPathToLocationSynchronously(GetWorld(), OwnerEntity->GetActorLocation(), TargetLocation);
The default NavAgent radius I'm using is 50, and the Actor on the video has a capsule radius of 50
If I use Nav_Obstacle instead of Nav_Null, the units path nicely around corners, but they are also allowed to step in. If I can prevent FindPathToLocationSynchronously from including points inside obstacles that'd solve my issue too
You can use EQS to filter out locations that it'll overlap. Here's a video that explains how.
https://youtu.be/iY1jnFvHgbE?t=1284