#gameplay-ai
1 messages ยท Page 131 of 1
What is your opinion about behavior tree performance for an RTS game?
Oh really? so I can have each unit with behavior trees?
yeah BT is pretty good
gets expensive if you have a lot of services
but that is the same as anything that ticks
Thank you so much for this information. I thought behavior trees were expensive so I was doing a lot in C++. Right now I have a AI Manager Object that tracks each unit , buildings etc and make decisions. I think I'll just nuke it and switch to BT's. All my actors like buildings, resources, weather etc derives from custom actor that doesnt tick at all so I guess I save some performance there.
you could make the manager in BT
and keep the flow organised
we did that for our mission system lol
MissionManager is a pawn with a controller, and runs a BT for the missions
made is easier to design how a mission goes
So instead of separate BTs for each unit type (like villager, militia etc), you mean a single manager class (eg: Manager pawn that runs BT) that tracks all buildings and units for a single civilization?
if you wanted to go that route
just ideas lol
if you want to make pathfinding a bit cheaper
you can run it Async
and wait for a callback
But won't that get more complex down the road since there are multiple types of units and buildings?
so you don't bog down the thread if 100 units decide to path find the same time
Is there a documentation for Async BT?
i was on about the code i posted above
you can run that async
to not bog the Gamethread if 100 units request apath the same time
it will be split over a couple of frames
I'm into AI world for the first time so lots of confusion. Sorry for all the questions hehe
Great information. I'll look into BT's more.
Thank you so much Kaos! ๐ป
That's an interesting idea to use a mission manager with a BT ๐ค
does anyone know if you can put a tick in a blueprint decorator and have it abort the running subtree? trying to not do a custom service + blackboard value + blackboard-decorator...
wouldnt that need a blackboard value, @patent hornet?
it does
that's what im trying to avoid
anyone knows if the simple parallel node runs the task on the left before running anything on the right?
it runs it in the same frame
and yes the task on right is run first
but its the same frame
left sorry*
That's an interesting idea to use a mission manager with a BT ๐ค
@misty wharf pretty common, seen BTs used for various mission/quest systems on different projects
yeah it definitely makes sense :)
Hi ! I have a problem connected with (in my opinion way the objects are instantiating) AI controller. I have a respawnable NPC during runtime and If I set up things in AI Controller , One of Ai Controller ( GetControlledPawn function) function returns nullptr unless I call delay ( around to 0.5 second ) after Begin Play
In this case everything works Get Controlled Pawn returns my NPC reference
But up here, I get every time
Who of u all know what happend here and why?
the AI controller doesn't instantly possess the pawn
the events tend to usually run in this order: First BeginPlay, then Possessed
you can use the Possessed event to trigger the behavior tree
I usually do initialization in my controllers like this
this ensures both the beginplay and on possess run before any of the following logic :)
Right I am trying it at this moment
Great, thanks for help, works
I have some BP runtime errors but should be fix it on my own
Hey, I'm trying to set up a basic IA using a behavior tree following the quick start guide but for some reason my pawn (actually a character) is never possessed by the AI controller. Any clues? Or advice for things to check, I'm afraid I'm completely lost here.
I'm confused, it looks like it was being possessed, but just not doing anything...
Got a bit of an AI doozy, having some pawns spawned for fighters and they're supposed to move and attack a target:
They all use the same pawn, the behavior tree triggers for all of them, they all have the correct vector data from key.
But only 25-50% of them actually seem to execute the move order.
The meshes and colliders have "can ever effect navigation" checked off, but it seems like they're basically in a traffic jam when they spawn.
I've also tried noCrowd AI controllers and it hasn't helped. Getting to the point of just manually transforming them instead of using the AI.
It's using floating pawn movement, like the main ships (which do work consistently)
well, I mean you'll need to debug it and see what each agent is trying to do
hello, i'm trying to use nav area and nav filters to fake some type of avoidance because using RVO and the crowd following component didn't produce any decent results. By assigning one nav area to each enemy and making a filter for each one i have it working, the problem might be that the dynamic modification is very slow, but the AI seems a bit finicky in the rotation sometimes event when they are not in each other paths. any idea on how to make it more stable?
Figured it out, a collision channel issue was causing it
heyo,
does somebody know how to use "age" in the stimulus node ? I tried to print out the realtime age of the sensed stimuli with event tick but it show's "0.0" all the time
I was hoping to use the age float that you can also see in the gameplay debugger perception category
@tranquil reef age is the age of the stimuli
okay.. but then what age?
when the AI controller sensed a stimuli, what age would it have? since when ?
I'm looking for the elapsed time since the AI sensed the last simuli. Its the same you can see in the gameplay debugger (the sphere which spawns at the location of the stimuli)
sorry for totally not getting it ๐
I think you might need to query for the current stimuli information using ontick or something
if you save the stimuli structure from the perception update, that'll always show the same because it's just a struct copy
This is how I try it atm. But I seem to have done something totally wrong^^
yeah that would be copying the value from the stimulus struct that was passed originally to that event
I think there's like.. get current stimulus or something in the ai perception component that you can use
maybe "request stimuli listener update" ?
hmm.. no... doesn't look right ^^
I mean it can't be that hard to get this value right ? ๐
Get Currently Perceived Actors should do it I think
there's also Get Actors Perception which gives sense info relating to a specific actor
@misty wharf Thank you!!! I got it ๐
this graph shows also the expiration age but I'll tweak it a little so that I'll have only the value I wanted. But anyway thank you very much!
I got the expiration age because array index 0 and 1 were printed (Sight & Hearing sense) ... so selecting the desired index number does the trick
sup
can variables using in EQS?
gun got var "isEquipped" and I wanna make next: if it true, EQS set score for that actor to 0
now 1 character try to get gun, which hold another character. It not good
I think you would have to write a custom EQS test that does that
has there been any progress regarding avoidance in ue 4? that logic seems to not been updated in ages and the current solutions aren't the best
@misty wharf that?
No, context is different
Tests are the ones you add into the generators in your query, like distance and such
I don't know if you can create custom tests in blueprints
no you can't
I get the feeling that might be a performance choice
one limitation for BP users, but it makes sense, C++ is better for tests
yes, cause the complexity would be slow in BP
if you are doing big tests that need to be run on hundreds of points (which is the norm)
so can I at all create checking for variable in EQS? Now 1 character try to get gun, which hold another character. That's critical error, which player will see
you'd have to do the check in C++, or you could first run an EQS query, and then filter the results manually afterwards
ie. you do the other rules in the EQS query, and you get the results as an array, then you foreach loop and check the equipped
"or you could first run an EQS query, and then filter the results manually afterwards" - what do you mean? Don't understand you. I used EQS only in Behaviour Tree and nowhere else (one more. start it in AI controller)
there's a blueprint node called run eqs query
and make filter in it?
node in bottom right?
you get the results as actors, and then you would have to loop the results to check whether they pass or don't pass
try now
so I made check for owning of gun. How to make that gun to set score to 0 in EQS or smth like that?
You don't, you'd make this into a function or such which returns the actor
no basically you'd have to use this instead of the query
so you use the this to get the result you want
I don't know how I can use that
it looks like I need to use it there
but don't know am I right
@misty wharf
Are you looking to use this is a behavior tree?
yeah
when AI bool "haveGun?" - false, start doing 1 line, which do EQS
then AI just move to gun
every gun... that's the problem
@misty wharf
Right, so you would need to make this into a custom behavior tree task
which runs the EQS, and then filters the result actors array based on the gun, and sets some value in your blackboard
and how I can make filter in Behavior Tree?
@misty wharf
sorry for long waiting. Busy
by "filter" I mean use a for each loop to check if the condition is right :)
if so you can set the BB value as you want from the custom task
Hello, my character doesn't move when it's told to move by the Ai controller, I can see that it can find a place to move in the navmesh, but then it just doesn't move. Any ideas?
@last panther show code
Make screen
ok
this is the Behavior tree
I'm trying to follow the quick start tutorial
I added some debug stuff to be able to see what's happening, it finds the place to go, but doesn't move, then find another place to go a few seconds later, but never moves
In which case AI need to move, but it dont?
Patrol
Nothing works actually, but I wanted to understand the patrol stuff first, because it seems to be the simpler step.
Try selector
Not sequence
I got some troubles before I understand that
It still hard for mind to me
I think Move is failing
because otherwise it would stay waiting for 4 secons, but I can see it finding another place in less than that
I added debug stuff, and can see it happening. But I don't know how to proper debug this.
does it light up like blueprints? I tryied to open the console they suggest in the turorial, but nothing happens when I press the ' key
Ok, cool, I can see it now
Yeah, it never goes into the wait after the moveTo
it goes straight into the wait at the top level
then your MoveTo return failed
Sequencers move to the next node only if success
you can Force success if you must always wait, but that should be used with caution
yeah, but why is it failing? Something wrong with my navmesh?
there ya go
i have problem with navmesh, my NPC doesnt move until you dont look on them
i have sublevel, but my navmesh is on persisten level
i tried to use navinvoker but still doesnt help
when i play i'm feelikng like navmesh is generate only whe n iwatch on him but only on the front
when i rotate is see them and after all is moving, (npc)
on the visual log, it shows astronomical values... no Idea on how it's happening... ๐ฆ
Hi to all! I wonder how to combine player attack event and NPC attack event. I have an actor component ready, in which I inherit from a Combat_Interface function called Attack (in both Player and NPC). The problem of why I'm stuck is how to convey information when a player hits an NPC so that the NPC can give him punch back (fights till one of them will die).
hey, how do you reduce the abrupt rotation flickers when using crowd avoidance?
@last panther that is AI_INVALIDVECTOR
basically Max Float
so whatever the location is, its invalid
and want me to tell you what the issue is?
you are using a blackboard key, which you are "setting"
but you never it exposed it to the Behaviour Tree and assigned it
in that task.
so its empty/invalid.
no Eye here
which means its not exposed to the BT
so it is not assigned to any blackboard value.
so your move task is using an invalid value.
Has anyone every seen the engine in a state where EQS is completely broken? I'm not sure how but currently if I create an EQS query and just click on the "Root" node it causes the engine to crash:
Assertion failed: IsValid() [File:D:\Build\++UE4+Licensee\Sync\Engine\Source\Runtime\Core\Public\Templates/SharedPointer.h] [Line: 890]
UE4Editor_Core!AssertFailedImplV() [D:\Build\++UE4+Licensee\Sync\Engine\Source\Runtime\Core\Private\Misc\AssertionMacros.cpp:100]
UE4Editor_Core!FDebug::CheckVerifyFailedImpl() [D:\Build\++UE4+Licensee\Sync\Engine\Source\Runtime\Core\Private\Misc\AssertionMacros.cpp:450]
UE4Editor_EnvironmentQueryEditor!FEnvironmentQueryEditor::OnSelectedNodesChanged() [D:\Build\++UE4+Licensee\Sync\Engine\Source\Editor\EnvironmentQueryEditor\Private\EnvironmentQueryEditor.cpp:313]
...
Running it in Debug mode and poking around, I was able to find that a DetailsView variable being null is what's causing the crash. The rest of the call stack has to do with Slate. I've tried clearing out the .vs, Intermediate, DerivedDataCache, Saved, and Binaries of both my project and all plugins being used. I've also tried disabling all my plugins. Not sure how to restore the project to working state.
what engine version?
4.25.3
I haven't tried opening it in other versions though so that might be informative.
hey guys,
may anyone help me with setting up multiple AI's in my project? I've setted up one BT one BB and one AI controller and I wan't to know if different pawns can all share the same "elements" because it looks like it doesn't work when I just copy the pawn^^
Any useful documentation/tutorial on this would be super useful. Thanks ๐
has anyone tried making flying AI (like Cacodemon from Doom) with stock AI and without digging into C++ ?
hello, any reason why the crowd following component doesn't have nearly as much intermediate points (using Path->GetPathPoints()) than the normal path following component?
i use that to determine certain things
so I need the intermediate points
i only get the start and the end points
@tranquil reef This option allows the AI agents to share state I believe
@atomic crescent that does not seem to do it. I also tried my AIController or the Pawn as the Key Type Base Class but it didn't work.
Atm both pawn's are spotting me immediately when they're placed though when I have only one pawn the BT works well and the AI is roaming till it see's me
right now my only workaround for this is using FindPathToLocationSynchronously from Path->GetStartLocation() to Path->GetDestinationLocation(), but this shouldn't be necessary
is there any reason why the intermediate points are not included? maybe some logic that the avoidance executes?
Is it possible to somehow find all references of a blackboard variable? I want to refactor a variable and need to know all places where e.g. AI Controller or Behavior Trees might reference it.
If you right click a Variable or Function (pretty much anything really) you can "Find all References"
Sadly the only options are delete and rename, hence my question
And in the reference viewer I can only see references to the whole blackboard but couldn't find a way to scope down to a single key of it
so, has anyone tried making flying AI (like Cacodemon from Doom) with stock AI and without digging into C++ ? How would I make AI fly above the obstacles like Cacodemon does it in Doom ?
Just use a movement component that has it move X units above the ground
have a nav layer that ignores the obstacles
probably simplest way without writing code. Depends how complex your world is. Could maybe just do it with a simple steering behaviour
I thought about it, but it wouldn't work for obstacles that are taller than X (even if only by so much).
not sure what you mean...you're pretty limited in what you can do without code and just using the built-in tools
it will still navigate and avoid obstacles whilst in the air
cause its moving along a path (which avoids obsctales)
but would look kinda silly
without C++, good luck
is there a copy/paste C++ code to enable Cacodemon's like movement ? ๐
@pine steeple and something like that can't be done using stock AI in UE4, without additional C++ code ?
๐ฆ
let's say I have 2 nav meshes (second nav mesh is for that Cacodemon type enemy). How can I make it where only specific actors affect second nav mesh as obstacles (same actors would still affect the original nav mesh) ?
cuz if I uncheck "affect navigation" on the actor, it will stop affecting both nav meshes
@pine steeple ^^^ any idea ?
Just create a unique nav mesh with a huge step up height and do sphere casts in front of them and have them fly upwards if they're flying into anything, and drop down if they're not... Pretty much how the cacodemon worked in OG doom lol
aye, but if I want them to fly over actors, I need those actors not to affect Cacodemon's nav mesh (while affecting nav mesh used for the rest of the AI). How would I achieve that ?
Could just leave affect navigation on for everything that should?
Thing is, there's going to be edge cases like if it hits a tall pole it should go around instead of climbing over, you could build in some logic to try to go around things while "ascending" to mitigate a bit of that but otherwise it gets complex
you've got the right idea, separate layer of navmesh with different blocking criteria, I've never set that up in unreal though, I'm sure it's possible, pretty standard stuff
the issue is (at first glance) that actor either affects all nav meshes or it doesn't
(I haven't dug too deep into it, maybe there is a way to filter nav meshes for each actor)
Read what I said again. Huge step up height.
What you actually want is 3D path finding to see if going over something is cheaper than going around it but you'll need maybe a plugin or lots of code for that
@simple crest and I'd certainly do that to allow Cacodemon to "fly" over walls and such. But at the same time I need him to "fly" over other monsters, player, weapons, tables, etc. And having huge step height isn't going to help - Cacodemon would step on those items and still be X units above them as if they are the ground.
read what I said again again 
do sphere casts in front of them and have them fly upwards if they're flying into anything, and drop down if they're not
the other nuisance is if two cacodemons are trying to fly through each other, I think I've seen them do dumb things in D1/D2 from that too
heyo!
so I read "detection by affiliation" (AI perception) can only be changed in c++. Is that so ? ๐
I wish someone made Marketplace plugin to expose all AI goodies to Blueprints ๐ฅฑ
a lot of those C++ only things are reasonably easy to implement tbh
for those who are into C++ ๐
I wish someone made Marketplace plugin to expose all AI goodies to Blueprints ๐ฅฑ
@flint trail oh yeah... that would be sweet ๐คค
...but I guess there's no way around learning c++.
speaking of which:
...some of you seem to have a lot of expierence with ue c++. Can anyone recommend good resources/documentations to learn it? Or maybe even have some tips on how to approach it ?
thanks @pine steeple btw ๐
when i get a bit more free time ill finish my AI plugin
it has team interface set up plus lots of helpful stuff missing from BP
Are you using a navmesh? if you hit P while playing in editor, does it have a hole where your obstacle is?
Okay. What node/ are you using to move your enemy character?
It should be, that's what the navmesh helps with.
Probably, one of two things is happening: your character is a different size than the agent size defined by the navmesh, so it get's caught on the obstacle due to physics interactions.
Or, the node you are using doesn't use the navmesh, and just moves the character in a straight line.
Do you know where you configure the navmesh settings for your project?
That's it.
Agent radius is the one to look at. It should be the same as your capsule collider.
AI
Yeah, IIRC the capsule for the basic maniiquin's radius is not the same as the default navmesh. Which is an annoying gotcha.
I think it's 42?
Change it in your project settings.
Project settings > Engine - Navigation Mesh
Looks good.
You may need to build the navigation again. But you should see the area around the obstacle grow.
That is odd. it should be "cleaner" than that.
Did you run through this course: https://learn.unrealengine.com/course/3318392?r=False&ts=637369963340108479
(Ai with blueprints on learn.unrealengine?)
It covers this exact task.
This is what the tutorial mesh looks like:
just press apostrophe and see if AI is using navmesh
This stuff works, don't give up yet.
oh sorry, didn't notice that 2nd-last pic
That last pic looks like a reasonable navmesh.
Yes! What was it?
Moveto in the BT should.
I think there's something else at fault but I don't know what
This is a fragment of a working BT that uses the navmesh.
Great! Honestly, what just happened to you happened to me a bunch learning this engine.
I'm 100% on the right path, I make some change somewhere that messes up my usage and I spend hours circling back around. lol.
Up to this point, I've done all of my AI in BP.
What I've heard, trolling this channel is that there are cases where you just can't do it in BP.
Yeah, that's one case.
I have a case coming up in my game where I'll need to customize the navmesh a bit, so I'll need to crash open C++ for that.
I'm working on something xcom-ish
And I want to be able to score the movement cost when the player clicks a target location.
Navmesh volumes do cause the path query to pick a good path, but I want the returned path to be marked up with cost of each path segment, which AFAICT, they don't.
That way I can show the total move cost in seconds, and visualize the points where the character is moving slowly.
There's also a few cases where recast doesn't pick the optimal path.
I really don't want to go there. I've implemented a* a million times, but my understanding is that I'd need something more complex than that to solve that issue.
There's a cheap hack I'm considering to solve the movement thing (which is to have an invisible AI navigate to the clicked place really quickly and report where it enters "slow" volumes, then draw the resulting path). But solving it in C++ before the click has nice properties.
Exactly like that.
But with pretty colors and particles, because we're in a game ๐
I mistyped. I really meant "on the click"
The game has "free" movement (not constrained to a grid), so I couldn't possibly pre-compute.
Though in essence, that's what the navmesh does for us.
Interesting, I was playing with some similar ideas as well but didn't really work much on it yet :)
anyone know how to make a patrolling npc vehicle
@Sakra Happy to! Later!
@misty wharf It's a hobby project, so it's a little by little thing for me. Click to move with predicted path, avoiding other units is working, with a spline to show movement.
Automated cover detection is in progress. I'm trying something relatively simple (a sphere trace to find possible cover near the mouse pointer and line tracing to confirm it) is in progress but not really there yet.
yo! if i am spawning a bunch of characters with the same animation, which u guys think is the best solution to avoid them to be in sync?
picking a random animation starting point maybe?
that's something I'd like to know too
I'm also curious. I would guess something like assigning an animation offset from a pool to each actor would make unnatural perfect animation syn impossible. (since random can still result in two actors assigned a very similar or identical offset).
i normally offset the spawns
by a few frames
works fine
spawn one every few frames
I recall seeing a tutorial where, with use of some basic C++ code, AI Perception was made attachable to the bone/socket.
I lost track of it. Has anyone seen such tutorial and happened to have a link ?
offsetting spawn times makes total sense, cool.
this can be done in C++, there's an interface you can implement to do custom sight check
IAISightTargetInterface
there might be another way to do it by creating a custom version of the Sight sense as well
here's an implementation I did to check from player pawn's camera instead of the center
int32& NumberOfLoSChecksPerformed, float& OutSightStrength, const AActor* IgnoreActor) const
{
FHitResult HitResult;
const bool IsHit = GetWorld()->LineTraceSingleByChannel(HitResult, ObserverLocation, Camera->GetComponentLocation()
, ECC_Camera, FCollisionQueryParams(SCENE_QUERY_STAT(AILineOfSight), true, IgnoreActor));
OutSeenLocation = HitResult.Location;
NumberOfLoSChecksPerformed = 1;
OutSightStrength = 1;
return IsHit && HitResult.GetActor() == this;
}```
you could probably do something similar, but you'd just do a sphere trace instead of a line trace
you can also do multiple checks and do traces to things like arms, legs, head, torso
using the same logic as above
recall seeing a tutorial where, with use of some basic C++ code, AI Perception was made attachable to the bone/socket.
I lost track of it. Has anyone seen such tutorial and happened to have a link ?
anyone?!
@delicate hazel why would you want to change to a sphere trace though
I think you want to do what jonimake said instead
@flint trail just to teach a person to fish, google c++ ai perception socket answer is second result
sorry, what's google? /s
I saw that one last night
that's not the one, but I guess it's the same thing essentially
@Sakra I solved a similar problem by creating a custom EQS context that returns the location where the weapon fires from. Units implement a BP interface that can return that value, the context just returns it as a location. Then I can build a query that tests if the trace hits when starting from that context. Never thought of modifying perception for that task, that's a neat way to do it.
Hi!
This might have been asked before here, but can't find an answer for it: Detour Crowd Control, how to register/unregister ai agents?
In our game we have something we call Distance Based Optimizations. It's a process we run that checks how far AI is from the player and, depending on the distance, we apply different settings. When close everything fully works, when far, we disable ticks and other things.Now I'm playing around with the Crowd Control and I want to un-register the AI (or pause, not sure the right terminology here) when it's far from the player, enable it again when it's closer.
But I'm failing. I can't figure out the right way to re-enable it.To enable crowd control, I found thin in the wiki (RIP wiki, thanks a lot Epic....)
: Super(ObjectInitializer.SetDefaultSubobjectClass<UCrowdFollowingComponent>(TEXT("PathFollowingComponent")))
You have to place this line within the AI controller constructor.
Good, that works.
The Register/Clean functions are within that component and they are protected, so I wrote an extension with public wrapper functions that call those protected functions.
So the line looks like this now
: Super(ObjectInitializer.SetDefaultSubobjectClass<UMyGameCrowdFollowingComponent>(TEXT("PathFollowingComponent")))And this are the wrapping functions I wrote and that I call
void UMyClassCrowdFollowingComponent::RegisterAgent() { Initialize(); } void UMyClassCrowdFollowingComponent::UnregisterAgent() { Cleanup(); }But this doesn't work. The Unregister works but, when I call register (initialize) I can see that AI doesn't behave the way it should again (avoidance is missing).
Also, it feels like I'm re-inventing the wheel.
@slow bobcat hey man did you find a solution?
Hey guys, I'm having some issues with my AI clumping together too much, how would I go about forcing a rule or something to make them spread out while moving about in an area?
any suggestion on how can I make an AI jump towards a target/enemy respecting nav mesh?
Has anyone done work with SmartAI by Defuse studios?
you just change the simulation to off @slow bobcat
@lyric bone
CrowdFollowing->SetSimulationState
disabled will make it use regular path finding
Hello. Similar question to @mild olive . Wanted to ask if anyone had any experience with AI Behavior Toolkit. I'm asking before buying it. Thanks for your responses.
hey @lyric bone yes, found the solution long time ago. Sorry I forgot to post it.
I did our own extension of the CrowdFollowing component and I added this function in it
void UTACrowdFollowingComponent::SetCrowdManagerEnabled(bool Enabled)
{
if (UCrowdManager* crowdManager = UCrowdManager::GetCurrent(GetWorld()))
{
ICrowdAgentInterface* agent = Cast<ICrowdAgentInterface>(this);
if (Enabled)
{
if (!crowdManager->IsAgentValid(agent))
{
// warning: the order matters. Simulation must be enabled before registering the agent
SimulationState = ECrowdSimulationState::Enabled;
crowdManager->RegisterAgent(agent);
bRegisteredWithCrowdSimulation = true;
}
}
else if(crowdManager->IsAgentValid(agent))
{
crowdManager->UnregisterAgent(agent);
SimulationState = ECrowdSimulationState::Disabled;
bRegisteredWithCrowdSimulation = false;
}
}
}
It's was some time ago, but I remember debugging and profiling this and stopping the simulation was not enough, you also need to un-register the agent. Otherwise it's taken into consideration when other agents move
you also need to manually set the bRegisteredWithCrowdSimulation for some silly reason
I still think I re-invented the wheel there and there's probably a function somewhere doing this, but I couldn't find it. This works and it's efficient so I stick to it
CrowdFollowing->SetSimulationState
Had to look for this @pine steeple . Yeah, that works but it has a problem I wanted to solve: the registration part. I wanted the AI to be completely gone from the system. That allows you to have a smaller number of simulating agents in the settings when doing the distance based optimizations I was talking about (btw, we now use the significance manager for all the distance optimizations. It's easy and multi-threaded. I recommend it very much)
On the same topic, the thing I haven't managed to get to work is AI avoiding the player. I added it to the crowd control system but nothing. Followed the scarce documentation available and I can't get it to work. Never put much time in it (not a big deal for now), but I will have to fix it at some point. Feels nice when the game has AI avoiding the player, like the civilians in CrackDown 3
How to Report Damage Event in C++ to be visible for Ai Perception Damage config. I tried with UGameplayStatic::ApplyDamage so forth but without expected results
I have a function TakeDamage which is a overrided
https://docs.unrealengine.com/en-US/API/Runtime/Engine/GameFramework/AActor/TakeDamage/index.html but it's call cannot bring to life my Damage config
Apply damage to this actor.
any idea of how to make each AI have different waiting time on patrol ? so they don't both go to the waypoint or spline point all together ?
simplest way, insert random time wait nodes in BT
@patent hornet I did try that, but the issue is when they start heading for the first waypoint, they are all heading together to it, I need to separate that
to make it simple, I'm looking for a way where they won't collide with eachother on the waypoint
If you dont want them crowding around the waypoint then maybe set a random offset around the waypoint as the destination for each bot so they spread out. You can do it with GetRandomReachablePointInRadius.
Hi there, i made this fox a Behaviourtree, the thing is he dont play the rotation animation. I set it up in as usual. Anyone csn help?
@robust kelp Maybe in the character movement, you have to set it to desired control rotation or maybe for interpolation time in blend-space might need to be a bit larger.
@paper axle thank you but the detour control fixed the whole issue
Im trying to make a simplified version of the AI like splinter cell but I have a doubt.
what is the best approach for an AI to alert other AI if they spot the player.
For example on guy spots you and the rest nearby are somehow aware of your location.
Im fine with doing C++ if needed
there's multiple ways to do this depending on how you want it to work
one way would be to for example get all nearby AI chars when you spot the player, and call some function on them to trigger it on them as well
triggering is one part. what if I evade one of them and the rest of the ai can still see me? In such a case this ai could go into a search while the others still shoot me
hmmm
also people talk about reducing or disabling tick on ai at larger distances. what would be a good way to calculate distance for this?
has anyone figured out a way for AI to curve around the corners, not just turn abruptly ?
does blackboard not hold arrays?
i am updating the boolean from my pawn, but when i update it doesnt break the cycle, it really waits on "wait" node and i have to wait until its search for location to run
how can i make it break if boolean updated?
there should be an abort option on the check if in danger decorator you have there
if you set it to abort on value change, that should do what you want I think
only related thing about "abort" this i guess
i've added decorators to wait tasks too, but i dont think this is the real solution ๐
yes, have it abort self
that should make it so that when the value changes, it aborts the entire subtree
oh also what I meant by "value change" is the above choice, notify observer.. the "result change" option on that should work
When I spawn a character, it also spawns an AI controller every time and they start to really stack up. Is this intended behavior from the engine's part?
Oh, figured it out. Auto possess was set to spawned.
how do i deal with a blocked navlink, for example, i just want the navlink to be active if nothing is in the way, like a player or an obstacle..
so, has anyone figured out a way for AI to curve around the corners, not just turn abruptly ?
@flint trail It probably depends on your character movement parameter setup. You might even use splines at places such as corners that kinda guide proper, consistent (desired) movement, without tweaking characters individually. I've seen people use spline for ai movement before
that's not really a solution - placing curves around every possible corner would be a nightmare. I am surprised Epic didn't include some math module to calculate a curve automatically for any character.
When a path is calculated, Path Points are created. You can calculate a curve from two points using spline as a data-only projection.
Which involves dynamically creating curves, if pre-spawning it around every corner isn't suitable for your game. But how could you know if the curve trajectory interferes with any obstacle? It requires more run-time effort
is it safe to assume all that needs to be done in C++ ?
There is a good foundation of K2 nodes for manipulating splines out there. I think most of it can be done in the blueprint editor
I guess I'd be better off hiring AI pro to deal with this when I have base stuff working ๐ ๐
does anyone know a way around recast navmesh failing when you increase navmesh bounds to very large height? if i go beyond 50k unreal units in height it can only generate my navmesh if I increase cell height to like 700 resulting in super imprecise / inaccurate navmesh
@noble minnow you'll probably need to break the level up into streaming tiles, each having their own navmesh volume. It would be easier to say for sure knowing exactly what the error is.
I guess I'd be better off hiring AI pro to deal with this when I have base stuff working ๐ ๐
@flint trail you can't do it out of the box. You need a custom path follower, the default one just directs the pawn directly point to point along the navpath
Why does have around 40+ AI drops server performance insanely.
is there a way to work around it?
Read someone saying to do it in a threaded way, but i got no clue what that is.
Why does have around 40+ AI drops server performance insanely
For you to say looking at the profiler, but biggest offenders are usually:
- Actors ticking
- components ticking
- physics calculations with very big colliders and/or checking against many things (i.e: 1500u radius sphere checking overlaps against static and dynamic and pawn on every tick)
- Skeletal mesh updating (aka animations) due to bad configured anim tick options
- BT's running expensive logic (specially within services)
- "shape" traces (sphere casts for example)
is there a way to work around it?
many. Tweaking all of the above.
Read someone saying to do it in a threaded way, but i got no clue what that is.
no clue what threaded mean or no clue what the way to do it is? (I'm guessing you refer to the significance manager)
EDIT: very well appointed by @simple crest the character component. That thing is definitely part of your problem.
tbh, probably just the default character movement component hogging too much CPU
how do i deal with a blocked navlink, for example, i just want the navlink to be active if nothing is in the way, like a player or an obstacle..
hey can anyone tell me how to fix a spawn to move in a particular direction when game starts
Is there a Spaw AI from Class in c++?
@stiff gale Construct Object from Class might be what you're looking for, though I'm not sure if AI has its own construction methods
Ok thanks and how do I fix this?
https://gyazo.com/0a37dd5520c88ea28d1d507025745a07
I was talking about doing it c++
that ActorToSpawn isn't a pointer to an actor so it wont work
it looks like ActorToSpawn is a pointer to a class
If I change ActorToSpawn to AActor* then SpawnActor() doesn't work
So I'm trying to use SpawnActor and DestroyActor in c++
SpawnActor takes a class and DestroyActor takes an actor
yeah that makes sense.
So on your SpawnActor, store the result to a new variable of the class you are spawning, or just an AActor*, then that is the actor you want to destroy
so
AActor* SpawnedActor = SpawnActor<ActorToSpawn>(foo bar yadda yadda);
...
...
SpawnedActor->Destory();
SpawnedActor = nullptr;
no wozzas
So I got to spawn but won't destroy
void AAISpawner::OnOverlapEnd(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex)
{
if ((OtherActor != nullptr) && (OtherActor != this) && (OtherComp != nullptr)) {
Char = Cast<ACharacter>(OtherActor);
UE_LOG(LogTemp, Warning, TEXT("...........................end Overlapped"));
if (Char && SpawnedActor) {
UE_LOG(LogTemp, Warning, TEXT("...........................end Overlapped CHAR"));
//World->DestroyActor(SpawnedActor, false, true);
SpawnedActor->Destroy();
SpawnedActor = nullptr;
}
}
}
SphereCollision->OnComponentBeginOverlap.AddDynamic(this, &AAISpawner::OnOverlapBegin);
SphereCollision->OnComponentEndOverlap.AddDynamic(this, &AAISpawner::OnOverlapEnd);
show us the spawning code?
also if you wrap your code in ``` when posting it here it will be more readable ๐
void AAISpawner::OnOverlapBegin(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
if ((OtherActor != nullptr) && (OtherActor != this) && (OtherComp != nullptr)) {
Char = Cast<ACharacter>(OtherActor);
if (Char) {
UE_LOG(LogTemp, Warning, TEXT(".......................Overlapped"));
const FVector Location = GetActorLocation();
const FRotator Rotation = GetActorRotation();
SpawnedActor = World->SpawnActor(ActorToSpawnClass, &Location, &Rotation);
}
}
}
@obtuse marlin So my character has a sphere collision. WHen overlaps with the spawner it spawns two AI which is an issue, and when I leave the area it doesn't destroy them not even show the message in end overlap.
throw a log outside the if(Char) and see if that fires.
Got it fixed. I had billboard as root then arrow and sphere collision as children. After removing arrow and billboard, now it works.
Wonder how to set arrow comp as root though
interesting :/
Hello! Whats the damage event to be "visible" "reachable" through the Ai Damage Config?
Currently I have a function called "TakeDamage" but at working with Ai debugger inside the Editor I dont see a "sphere" which exists for Sight Config
any ideas?
Via Blueprint this works like this and it works, but how to create this report event in cpp?
Heya all. Would it be appropriate to ask here the question that relates to blueprints in editor and pathfinding? )
I'd like to have a pathfinding:
- with slope costs so that AI prefers to move flat land before going to climb a hill (most important),
- with surface costs based on a landscape so AI wouldn't walk into the swamp on their heels unless they don't have a dry way (less important).
The project:
- is a huge realistic world;
- i'm trying to go blueprint-only;
- the runtime navmesh generating is not necessary for me (might become later, but now i'm making editor widget).
As far as I understand it is only possible to:
- Use navModifiers to set cost for specific volumes (actors): i can't afford to place volumes on every slope fragments of a landscape manually.
- Go into the deep programming to override pathfinding/casting: would be heavily time-consuming and frustrating for me.
And it is not possible to:
- tell the navmesh to generate areas with different costs,
- use any kind of external editing for a navmesh,
- place navmodifiers procedurally on the slopes or specific landscape surfaces.
Am i right or are there any other possible solutions?
Maybe someone did publish a code snippet or a plugin?
Any workaround ideas?
huge realistic world + blueprint only aren't compatible I'm afraid
you will need to get into code
yeah I bet you could do that slope cost stuff in c++
Guys any idea why my navmesh doesnt work in world comp?
I have one persistent main level with just sky and lighting and a nam mesh bounds volume
and my sublevels have landscape geometry in them
so when those landscape chunks load , and when i go near my AI, they dont move
i think you need to enable dynamic navmesh
in general, look into navmesh invokers
very useful for open world nav
how do i deal with a blocked navlink, for example, i just want the navlink to be active if nothing is in the way, like a player or an obstacle..
you'd probably have to detect the block state somehow, eg. with a trigger box.. and then turn the link on/off based on it
am i supposed to use these?
im trying to have certain pawns only travel certain navlinks/areas but those doesnt seem to be used anywhere
found it, placed on project settings
still no idea how to make a certain pawn not use a certain area tho
One way is add a NavigationModifier volume, and use a NavigationQueryFilter on your AIMoveTo for the pawn that excludes the pawn from that Modifier volume.
@opal crest thanks
Anyone know good AI tutorials for FPS games? Got one right now based on BT's but well, needs a bit more punch to pose a tad of a challenge for as a bot for an MP game.
hello, i've created simple project using the third person template and create a basic AI that just follows the player. i've set a nav modifier with null area around the player and for some reason the AI is ignoring the null area and going to the player. What could make the AI do this?
Your AI is probably not using the navmesh to navigate. The gameplay debugger can give you some more detail on what's going on. The AI with blueprints course on learn.unrealengine.com covers this pretty well.
@opal crest i'm using a behaviour tree to do a move to, so he needs the navmesh to be able to navigate
Yeah, the BT node should work, and should not navigate outside the mesh.
You are using move to and not move directly toward?
move to
just doing this
really basic stuff
it's a fresh third person project
i just created the bp for the AI and the BT
and a differnet material
to distinguish
I just tried this, and I ran into the same issue.
The get stuck in the null volume.
@storm zephyr the solution for me was to disable "Track moving goal" in the move to node.
Seems to prevent the AI from getting a target location outside of the mesh. (This feels like an engine bug, but there might be a good reason for it).
unfortunantely the AI in the engine is really wonky overall
it doesn't seem like a big priority for the developers
it doesn't seem like a big priority for the developers
@storm zephyr its just bad documentation, AI is actually pretty good if you know what you are doing
@hearty niche that is also true
i've been trying to get avoidance to work well, but there are always cases that things just break and configuring the crowd avoidance values is just putting random values and see if it looks better ๐
well yeah if onky epic documented this stuff better I mean there is a ton of functions which one has to figure out what they do.
also can any help me understand how I could use multithreadin to optimize AI?
also can any help me understand how I could use multithreadin to optimize AI?
@hearty niche you write your own multi-threaded systems, basically.
planners lend themselves quite well to multithreading as they have an abstract world state representation that you can easily synchronise
Im very new to the concept of multithreading I was thinking maybe I coukd use it for calculating the distance to thr player for reducing npc tickrates at far off distances
well, you don't need multithreading for that, calculating distances is pretty cheap
You can use timers+eqs for that (time spliced) or async tasks
But yeah, if you stick to squared distances, super cheap
Guys, how to tell which sense we percepted after OnTargetPerceptionUpdated? We have FAIStimulus, but I can't see where to take sense type from it.
iirc there's like.. get sense id or something which is a node on the stimulus object
But how to convert it to sense? It's just ID and we can't compare it without having an UAISense ref.
Is there a way to get ID for particular sense without creating one?
ofc you can
Found : Stimulus.Type.Name.ToString() == "Default__AISense_Hearing"
Or Hearing -> to sense you want
{
if (SenseID.IsValid()) {
FString SenseName = SenseID.Name.ToString();
SenseName.RemoveFromEnd(TEXT("_C"));
int32 SeparatorIdx = INDEX_NONE;
const bool bHasSeparator = SenseName.FindLastChar(TEXT('_'), SeparatorIdx);
if (bHasSeparator)
{
SenseName = SenseName.Mid(SeparatorIdx + 1);
}
return SenseName;
}
return FString(TEXT("None"));
}```
i just do this
but i made a enum to make things easier
{
if (SenseID.IsValid())
{
FString SenseName = SenseID.Name.ToString();
SenseName.RemoveFromEnd(TEXT("_C"));
int32 SeparatorIdx = INDEX_NONE;
const bool bHasSeparator = SenseName.FindLastChar(TEXT('_'), SeparatorIdx);
if (bHasSeparator)
{
SenseName = SenseName.Mid(SeparatorIdx + 1);
}
if (SenseName == TEXT("Sight"))
{
return EPerceptionSense::EPS_SIGHT;
}```
for example
In BP, I've been doing this.
@rocky raptor you could also match sesnse ids
Woaw, thats cool!
Thx guys, I guess get sense class for stimulus is what I was looking for
if (SenseID == UAISense::GetSenseID(UAISense_Sight::StaticClass())
for example
also another route you can use
the above one is quite cheap also
ah yeah the get sense class was the node I was thinking of
since it immediately gives you something that you can easily compare
if you like to compare classes
i prefer enum
allows me to use a switch ๐
can do things like this ๐
Yeah, I can't say I'm a fan of all the branches in the BP to deal with different senses. Anytime you can get a switch is ++.
@pine steeple I remember you said you need to finish your AI plugin.. I am wondering if your plugin has something to allow AI steer around corners naturally and not turn abruptly, like in stock UE4
Hello! My AI gets stuck from time to time roaming around my map, I want to implement a solution that has him back up and try again. Does anyone have any advice? I'm currently trying to set up a bool that sets to true when his movement speed = 0 for X amount of time, but I'm not sure how to define time.
@flint trail no its just more a utility library to help with common AI stuff in UE4
I have multiple pawns that I duplicated. They all have similar controls. I would like them to all use the same hud. They have the same Health & Stamina values. Is this possible? So far I've onyl seen tutorials that only allow references from one pawn/character.
I don't want to copy and paste the same HUD 5+ times
@old hinge set it up so that your HUD / Widget has a variable for your pawn, and read the health and other values from it. Then, when a pawn is possessed, assign the correct pawn into the HUD.
You could also probably use Get Owning Player -> Get Possessed Pawn (the nodes might not be called exactly that) or some other method to read the player's current pawn
Hey ! this may seem like a dumb problem but im honestly at a loss here, ive made an ai that attaches to a spline to move around, but im having a problem reattaching the ai to the nav mesh they where on previously.
@misty wharf so say I have 3 different pawns. Would I need references to all three and I would pass them to my HUD bp??
You can handle it easily in your player controller
the player controller has an on possess event which gives you the pawn it possessed, so you can just assign it from there
I am somewhat new to all of this, is there a proper video/tutorial on how to accomplish this? I tried searching, but I guess I don't really know exactly what to search for.
Whats the proper way to get reference to your ai?
i have an ai spawned when i spawn the level
doesn't really make it easy to get a reference for its hp widget
because if i want each ai to use their own hp widget not quite sure how i should go about getting their references
Figured it out no worries
Is it possible to know if AI path is going through a link/smart link ?
No idea how I can pull that info from here? :/
is this another thing only available to the c++ masterace ?
not sure if that's available so yeah sounds like it
you would be able to determine when a smart navlink is being traversed but not sure if up front
mmmmmmmm. thanks, I guess I have to find a hack of some sort :/ How would you determine if a link is being traversed? maybe I can do something with that
iirc when a smart link is traversed it can trigger an event
been a while since I did anything with that though so I don't remember the specifics
mmm I see, that's pretty useless then haha ๐ thanks anyway !
I am trying to do a shooter AI but I want to make sure that the AI don't block each other leading to friendly fire.
What would be a good way of doing this?
EQS testing the Line Of Fire when they choose a vantage point to shoot at the player. That's how I do it at least. Basically, when chooseing a vantage point, I check what would happen if the enemy, standing there, would do a perfect shot to the target. It's just a line trace with a custom channel (bullets) that checks for blocking collisions. If I get one and it's, in distance, closer than the target, it means I will fail the shot (a wall, other enemy etc). That means that vantage point is not good.
On top of that, I have an octree to quickly set and remove locations. It's for enemies to say "hey, I choose this point in the world as my vantage location" or "ok, I arrived to my location, it's not reserved anymore".
That's another test in the same EQS where I say "you can't pick a point that is closer than 300 units from a world reserved location".
I do the same test with other enemies.
And I check dot products.
So, to recap:
-
line of fire (line trace)
-
do not pick a point that is close to any other enemy (I use 300u)
-
do not pick a point that is close to any world reserved location (300u)
-
Dot product between EnemyRunningEQS-Target and ReservedLocation-Target. Make sure it's bigger than 0.8 (I think, might be 0.7 or 0.9, can't remember now) + the reserved location is not closer to the target than me. This is basically saying "hey, make sure I will not be standing behind an another enemy in a queue"
Additionally you can make the same DOT test against other enemies, just in case the LOF passed very close. We have accuracy parameters that we can't predict in the eqs, so there's a chance that the LOF says "all is good" but then the bullet doesn't fly in a perfect trajectory, hitting someone else in the meantime
another noob question i am using the ALS pawn and makimg an AI controller posess it. How do I calle input for actions like sprint on it like one would do with a playwr controller?
EQS testing the Line Of Fire when they choose a vantage point to shoot at the player. That's how I do it at least. Basically, when chooseing a vantage point, I check what would happen if the enemy, standing there, would do a perfect shot to the target. It's just a line trace with a custom channel (bullets) that checks for blocking collisions. If I get one and it's, in distance, closer than the target, it means I will fail the shot (a wall, other enemy etc). That means that vantage point is not good.
On top of that, I have an octree to quickly set and remove locations. It's for enemies to say "hey, I choose this point in the world as my vantage location" or "ok, I arrived to my location, it's not reserved anymore".
That's another test in the same EQS where I say "you can't pick a point that is closer than 300 units from a world reserved location".I do the same test with other enemies.
And I check dot products.
So, to recap:
line of fire (line trace)
do not pick a point that is close to any other enemy (I use 300u)
do not pick a point that is close to any world reserved location (300u)
Dot product between EnemyRunningEQS-Target and ReservedLocation-Target. Make sure it's bigger than 0.8 (I think, might be 0.7 or 0.9, can't remember now) + the reserved location is not closer to the target than me. This is basically saying "hey, make sure I will not be standing behind an another enemy in a queue"
Additionally you can make the same DOT test against other enemies, just in case the LOF passed very close. We have accuracy parameters that we can't predict in the eqs, so there's a chance that the LOF says "all is good" but then the bullet doesn't fly in a perfect trajectory, hitting someone else in the meantime
@slow bobcat how would I run an eqs relative to another enemy? would I have to store all enemy pawns as context or something? eqs has been kinda confusing
yep. We have an Enemy Manager that already has an array with all the enemies spawned in the world. Then we have a context we use in the EQS generator to get all enemies in X radius. We just need to loop the actors in said array instead of do the "GetAllActorsOfClass" which is always slower
so all enemies in radius will be called per query?
Yes.
Every time we want an AI agent to choose a vantage position, we do a query request that:
- Generates a list of points around the target with X units radius target
- Test Line Of Fire
- Dot Tests against all the enemies in radius (provided by a context using our Enemy Manager)
- Other Tests mentioned before
so some deviation would be needed so that this eqs is not called multiole times in one frame right?
Edited my last answer.
yeah, ideally you only call that when you actually need the AI to move to a vantage point.
We have a service checking if they lost the Line of Fire and the Line of Sight for longer than X seconds, then we evaluate a new vantage position based on what we know
ok this is gonna take a while to execute thanks man
also one more question
another noob question i am using the ALS pawn and makimg an AI controller posess it. How do I calle input for actions like sprint on it like one would do with a playwr controller?
@hearty niche .
Depends. If the AI should sprint under X condition, it will be something driven from the BT. If it's action related (i.e: this attack makes the AI sprint towards the target), then the attack would modify the speed I guess?
there's no golden rule really. It depends a lot on how you do things
ok this is gonna take a while to execute
that's fine. EQS are time-sliced (hence the async aspect of it), so it's not super demanding. You want them to be as optimal as possible, but this is the intended use expected
I mean the pawn is reused for AI but I ant to simulate the key press from the AI controller instead of writing separate logic to do so considering the complexity of ALS
right... you are using the Advanced Locomotion System... no clue. I have never considered "key simulation" for AI. Never plan it as such since you have to stick to NavMesh, Crowd Manager and what not at some point
I mean it would still act like a function call to increase or decrease speed or should I just copy the funxtions called on input.
Any idea why I'm getting no nav mesh under this AI?
https://gyazo.com/b8b6ce7391c2e3c1213a4433bb96a8db
there's a checkbox called affects navigation or something like this in collider settings
turn that off if you don't want it to affect navmesh generation
Yea thanks
Sometimes I wish you could have reroute nodes in behavior trees... :D
I guess you could probably nest selectors or sequences with just one child but not sure if that's a good idea
Hi guys, I'm working on an AI and I wonder how do you make it maintain a certain distance from other AIs whenever it moves
I was thinking about using some vector math on my target location with respect to other AIs being nearby before I give it to the Move to node
Heya all. I'm not a programner, but i'm trying to figure out how to add one more navarea to recast navmesh based on slope.
I've found a recast.h file which shows some functions setting area type to walkable or nonwalkable triangles based on slope angle.
I suppose calling rcMarkWalkableTriangles one more time with different settings could do what i need.
Am i right?
Is it possible to override recast.h at all? It doesn't show in c++ classes in editor. Maybe it's another kind of file?
Any tips on how to advance into this matter?
The Recast code is under the NavigationSystem.h
You can get at the unreal wrapper for the recast navmesh like this:
#include "NavigationSystem.h"
#include "NavMesh/RecastNavMesh.h"
...
auto NavigationSystem = UNavigationSystemV1::GetCurrent(GetWorld());
auto NavData = NavigationSystem->MainNavData;
const ARecastNavMesh* const RecastNavMesh = Cast<const ARecastNavMesh>(NavData);
If you are looking to work directly with the recast code, you'll need to dig a bit deeper into the engine code, but I'm pretty sure that should get you started on the path.
I'm not sure what it means yet, but thank you :-)
yw and Good luck! I am a programmer, and some of the Navmesh code can be a little arcane even for me.
Hey i am currently trying to get started with AI. I created my first AI and assigned the Starter Content Mannequin Mesh and Animation Class to it. I configured the behavior tree so that the AI moves to random locations. Everything works but the animation is bugging out and I dont get why.
https://streamable.com/uiqccr
Everything was build on a fresh ThirdPersonBlueprint Template
Can you show me your movement logic?
It seems like it's messing with the rotation, the animation itself is working fine.
@tall bloom
Problem solved.... ๐ The AI Mesh was not facing correctly :S
@little pendant thank you anyway ๐
np
Ah, yeah, I remember rotating my mannequin 90 degrees for my AI last time I used it. Was it that? @tall bloom
Yes exactly ๐
Gotcha
what's the correct way to listen and respond to events in ue4 behaviour trees? A service that adds/removes a listener when it starts/exits, and sets a flag that a left-hand child responds to?
it probably depends on what exactly you're trying to do
For example, I have event listeners in my AI controller which sets values in the blackboard
when my character gets punched, I want to abort the current task so the character won't continue pathing during the got-hit animation
then the character can re-evaluate the tree and decide if they want to do something else
but I don't want to poll for a flag
I'll look into the AI controller method you mention. What's the syntax like, foo->getAIcontroller->getBB->set(foo, 3) ?
I actually did that kind of damage handling in a project
I think the way I set it up was I had the AI controller listen to when its pawn gets damaged, and it would set a flag "damaged" in the blackboard
this would cause a decorator to abort and jump the tree into a damaged state which would handle that logic
that's 100% what I was looking for, thanks
Hi everyone! I'm trying to learn about AI with ue4. Does anyone know a really good resource to start with? I prefer if it's with C++. Thanks!
Hello! Look at this. How can i make them stop immediately? StopMovement Node isn't working!
@cursive marten Could try changing it's MaxWalkSpeed to 0 instead of Stop Movement Immediately.
Done it at this moment! It helped!
Looks pretty cool with them sliding
So ive been trying to do navigation with a navmesh, but im having too much problems...
some context: my game is really dynamic, and i have to regen links, modifier volumes, and navmesh every few seconds,
links can get obstructed, or not be valid anymore, my characters can also navigate almost freely 3d
so im thinking on alternatives, voxel navigation maybe? what u guys think
General question:
In a level where you have lets say a big house with doors, whats the best way to make the AI know the best way to reach the player and open doors (?)
Make the doors don't affect the navigation and then open them at move ?
Or you make some fancy system to know the distances linking or having references between doors ?
@cunning vault one way to make it is through links, lets say your door BP have a smart navlink, the AI will assume the link to be just another path it can take
then you can have the navlink reached event play a open door montage etc
and the link can have a specific navarea, for example Door links have a cost 1, AI will prefer it, Windows links have a cost 5, AI will try to not jump the window unless its a shortcut
yeah my main issue is how to solve the path from Ai to player
if there are links etc
like if for example get a path using the doors as reference, then get the best path from Ai to player
yeah my main issue is how to solve the path from Ai to player
i dont get it, its done automatically?
if you try to move to the player, it will choose best path already
I mean you can get a path using the given system and the navmesh, but when the navmesh is cut in areas or whatever then there isn't a direct way
that's why they suggested navlink
actually while I'm thinking of it: what I've been curious about before is if you had a bunch of locked doors with different keys... how would you set something up so that certain AI could only use certain nav link proxies if they had the specific keys or something
@simple crest by using Excluded areas and area flags
i have some navlinks that only certain pawns can go trough, so i exclude the others etc
i think it can also be done with area flags, but they look kinda broken, or at least i havent managed to get them working
cool, thanks I'll have a look around
yeah the navlink can be totally disabled isn't it ?
well, will try that thing then
ty
does the AI walks normally across the link ?
yep it will move just like it was a green tile
then u can use the OnReached event to do specific actions
and what happen exactly if on middle collide with a player or something ? keeps moving forward or return or get stuck?
never tried that tbh
i think it gets stuck
but im not '100% sure
AddMovementInput moves my character always parallel to the ground despite the forward vector is aiming towards the sky, why?
isn't add movement input handled by your movement component?
so if you have a character movement component, it probably treats it as regular walking
can it fly and that ?
@simple crest NavFilters are your friend with NavAreas ๐
we use them extensively
ah, thanks. I still haven't gotten around to fine tuning any movement yet with AI ๐
yeah i have around 15 filters
and 12 area classes
we use them to enable/disable things like doors, window vaults, obstacle vaults, etc
and obvs stop certain ai from tranversing
transversing
most basic monsters, just use the basic monster filter, as most of them can vault over obstacles
//TODO:(Kaos) Maybe we can check if this link was on their path.
for (UPathFollowingComponent* Comp : NearbyAgents)
{
if (Comp->GetPath().IsValid())
{
Comp->GetPath()->Invalidate();
}
}``` really should get round to doing this
{
if (Comp->GetPath().IsValid() && Comp->GetPath()->ContainsCustomLink(GetNavLinkID()))
{
Comp->GetPath()->Invalidate();
}
}```
there, just need to test it ๐
just saw this - that's wonderful to know it exists, I was worried I'd have to roll something myself
Hey !
How are you guys ?
I'm having troubles with the navmeshes in my projet, and I really cannot get why it doesn't work...
It works perfectly in the editor, perfectly standalone, but once I build the game, it breaks :/
My game is supposed to be out in 3 days but i'm stuck here, any idea ?
@edgy hull do you have dynamic navmesh or static?, you could try to delete the recastnavmesh in the world outliner and rebuild the navmesh
It I a dynamic one d@shell dock
I'll try !
no problem ^^
I can't show my nav mesh preview using the P key. Is there any other way to show that?
Yeah here :
I have that on. Strange! Is there any reason that my nav mesh not previewing?
Are you in game mode ? (G)
No
Restart the engine then ahah, I had this a few times
It doesn't for me. It was working yesterday.
can someone help me with the ai?
My navmesh looks like this but when I start the game it get's bigger
turns into this
i make an ai that doesnt follow me i want it to follow me
I want it to stay thin like in the first ss, any help?
Anyone know if there's a way to customize how BT nodes are displayed? It's kind of annoying when sometimes they become really large like this :P
just turn off
show description
only way to customize it is custom C++ node
and write your own GetStaticDescription function
ah, never occurred to look on the node within the BT itself, thanks :)
Hey guys I'm trying to make a flying AI and I don't have much time like 3 days tops what do you recommend ?
don't make it?
https://en.wikipedia.org/wiki/Boids
Anyone knows about this?
I'm looking forward to implement this model to UE4 and it would be great to take ideas and tutorials if you guys have
Question: is there any way to know which behavior tree is currently running?
Where's Meiszko!
I'm looking forward to implement this model to UE4 and it would be great to take ideas and tutorials if you guys have
@celest python it's very simple, you may as well implement it yourself. Plenty of examples out there if you just want to copy some code though
@verbal yoke what you mean? use the gameplay debugger/
No, I mean with BPs. Just trying to switch between Behavior Trees within a given condition. Btw, the workaround I found was to set an enum (blackboard key) on every switch to track which one is active at the moment, but I was hoping to find if there's another way or to do it better, or like a "get currently active BT" node or whatever.
Maybe put that function into BT
So when BT runs you know which one is running
@floral mango I researched the first two pages of Google but couldnt find anything :\ I only found some broken-codes and plugins about this, can you link me one please?
Plugin is not free ๐
I just heard its very expensive to implement and its very advanced thing but also heard its not that hard, intermediate-skill person could implement it etc. So I wanted to ask here nothing more
I am into AI, wanted to implement to my game and learn about it
There's definitely at least one free unreal plugin that implements it
But if you want to learn about it, I'd suggest just writing it
It's the perfect bite-size programming exercise. Just a handful of lines of code. Lots of scope for optimisation too
My main idea was making 50 AIs act like one AI and move spontaneously, like Talewords did in Mount and Blade, then I found "Boids", I'll definitely practice on it
Thanks
Hi, I'm writing an AI similar to the alien in Alien: Isolation. I have a small question on how I could implement a behaviour.
I have this code that checks if a pawn is in the peripheral vision, and if so, I want the AI to stop and wait. I want the AI to slowly get more aware of that pawn.
Like if a pawn stands too long in the peripheral vision, the AI will see him.
Hi! I need some help. I set up my nav query filter. And it all works good when I use costs of the areas and stuff like that, but I need to do something very specific, and it doesn't seem to work. What I need to do is to set up filter where NavArea_Default is EXCLUDED, so that my AIs only work in the areas that I tell them to. Like roads etc. And I have it set up this way, but when I exclude default nav area AIs won't move anymore. I guess it's not possible to exclude default one? Maybe because the modifiers are on the top of it?
And yes - I can make default area cost so high, that AIs will always select my road area, but I need to prevent them from ever using the default area and this cost stuff won't do, because they will still use default area when no road is available
Also, using splines won't do, as my roads are generated by the player at runtime
Hi everyone! I'm trying to create a BTTask Node and I'm getting this error:
have you added AIModule to your deps in the build cs file?
Going to ask there then, thanks!
You need to add as well the "GameplayTasks" module โ๏ธ
any way to change a NavLink relevancy at runtime?
My AI still snaps instantly instead of turning slowly when I do this, does anyone else experience this?
My AI still snaps instantly instead of turning slowly when I do this, does anyone else experience this?
@cerulean sky I just keep it as Use Controller Desired Rotation. Usually does the trick, other points could be with animation itself.
IDK what other "rotation" stuff can effect it
@obsidian topaz thanks for the help, this was the problem
I had to disable controller yaw
I had to disable controller yaw
@cerulean sky Yeah no problem, I keep forgetting that since I always disable yaw from the start. Automatic . Mainly cos I like doing first person style camera views.
anyone has any idea why its failing?
i know what you mean but i dont think its it
Yeah that does not change the value, that checks the condition.
The one about, the pic I sent is the one that changes the value
Where did you set the gun in hand to false?
nowhere
the value of the bool is what i think by default false thats why i dont bother setting it to false in the beginning
but when he picks up his gun i want it to set it to false
Ok I guess the variable name is just confusing to me because usually it would be gun in hand set to true if the AI is holding a gun.
Hmm... What is the move to task, a custom one or a built in one
custom one, sorry for the name i shoudl change it to something like "gun NOT in hand"
Yeah. Also open up the Move To Task, I wanna see the code.
I wonder if it is the layout... Do you have the event execute AI and finish execute (successful set to true)
move to is a built in
Ah ok
I wonder if it is the layout... Do you have the event execute AI and finish execute (successful set to true)
@obsidian topaz hmm you mean this?
That is usually needed in all the BT Tasks
No, the execute AI and finish execute are in custom BT Tasks
oh now i see hahah sy my bad
wher should i look for execute ai
cuz its a built in task
i cant see the code
Alright on a side note, Remember that this side of the code won't run until the Value Gun is hand (or whatever your variable name will be) is false.
The right side will always keep running.
If it is a built in code, then it won't be broken, so you won't need to change it
This is the only code being run on a loop
If you want to alter between the two, you are gonna have to make sure that once the player is not holding a gun, it is set to false.. I am trying to explain this as best I can, I just keep getting confused by the variables.
i understand : D no worries i can change them if you'd like me to
Yeah, probably best to do so
do i need to set the var to a value when i start the game like in begin play set "guninhand" to true
i changed it to his
Yeah if the gun is in player hand at start make sure to set gun in hand to true.
Once AI drops gun, make sure to set that to false.
And if it picks it up again, it will go back to true etc
yeah
this is super weird
i added this
@obsidian topaz hey i didn't solve it but i find a clue
when i added this, it worked
I guess that also makes sense cos you need to first get the coordinates and then the move to node will work so it can move AI to the coordinates
yeah
ill try making a new task and see if it works
i guess the problem is getting actors location
cuz thats making it fail
Hrms, mildly annoyingly it seems a Composite decorator cannot abort its tree
Oh nevermind, it's just hidden inside the composite editor on the individual conditions
which seems to work but is a bit confusing :P
So I'm using dynamic nav mesh. When I spawn AI into world using an ai spawner it doesn't create nav mesh. It only creates when I drop an AI from the editor.
@olive delta ive had some gotchas with a blackboard decorator not being observed, and not aborting self, often when i have a child task that includes within it some kind of Async task like MoveToLocation or MoveToActor
doesnt look like your current problem
but something to be aware of
maybe the delay node in the task is bugging with it
@cold trout I will check in on that later today and see if that might be the probelem
Some of you have requested a way to leave me a tip so I've created a PayPal and a Patreon.
PayPal: https://paypal.me/reidschannel?locale.x=en_US Patreon: https://www.patreon.com/reidtreharne
Discord: https://discord.gg/PdvudWx
Navigation3D Plugin: https://github.com/reidtrehar...
I'm seeing different nav mesh generation results depending on whether the landscape Navigation Geometry Gathering mode is set to lazy or instant. Specifically, with lazy it's skipping a lot of tiles(but only on the landscape; its generating navmesh on static meshes in those tiles), even ones the navigation invoker is sitting on top of. Is there some obvious explanation for this?
Hi guys, whats the best way to build a NPC which has kind of a life (needs like to drink, eat, work, etc.) I tried it with behaviour trees, but its gonna be huge and the blackboard variables are already 50
You could use the BT to organize the overall states and tasks
But store most of the data in the AI controller or inside the pawn itself
if you implement custom BT tasks and decorators, you can use those instead of the blackboard values
thanks! i thought i could just access blackboard variables in the BT
@mystic solar you keep track of that stuff in a component
use the BT only in high-level logic
BTs can get out of whack real quick
custom nodes too
@near jetty i see! even I lost already track of my BT
you may have an example on how I can do it with a component? cant find anything with google
you create a component class, give it blueprint exposed functions that do all that needs/stats things
has anyone seen any tutorials about aim offset and AI ?
@flint trail there is a tutorial in the documentations thats really good for aim offset just not for ai
in the ai i'd imagine you do the same thing
anim graph
my issue with AI and animBP/graph is always about having AI driving animation. With player it's super easy. With AI, not so much ๐ฆ
tbh the general goal should be to design your character so that the animation BP works equally for either
(assume they are both the "same" character, i.e. humans)
it's possible, but in my case not needed.. Still, the point is it's easier to get input data from player (human) than AI Controller (especially because docs are scarce).
Hi.
Does anyone know who efficient is EQS?
Lets say i have 100 minions on map with EQS.
and its MOBA game.
It probably largely depends on what you're doing with it
If you're doing ridiculously big grids and complex tests on them, it'll of course perform worse than if you do small simple queries
@misty wharf its a simple query to find Players?
It doesn't sound like it should be very expensive
You can probably use it and if you find it's too expensive for your game then you can replace it with something else, shouldn't be too complicated to do I think
thanks
i use EQS for a lot of things
150 monsters running a eqs every .3 seconds is about .04ms
game time
obvs its a rather cheap tests it does
but doing tests like traces, path finding, etc
gonna get expensive
I have a small AI character that is wandering around and I want the player to be able to pick it up. Just doing an attach to actor gives me weird behavior because the smaller AI's location doesn't move to the socket I'm specifying on the character picking up. I stop all logic from the AI when it's being picked up. Any reason it wouldn't attach anywhere close?
let's say I want to have NPCs that are neutral, hostile and one that follows player around. I am thinking that it would be nice to have BT that is generic to all of them (like basic movement and stuff) and then each type would have also its own BT with logic specific to the type of AI (like neutral NPC will have no combat in their BP; hostiles won't have friendly behaviors; etc.). Or perhaps I'd have combat tree which I could use in any of BTs for any type of AI ?
What's the best approach here? (I'd hate to make one BT for one AI and then duplicate it and tweak it for another AI, and so on)
How would you configure an AI to move somewhere when it doesnt have a movement function? (For example, using the rolling template player BP with an AI)
Are there any good tutorials for that? ๐ค
I think you have to have movement component for AI to work (and use character actor)
I'd imagine if you need to reuse substantial amounts of a BT you could probably use the run behavior BT task
since that'd allow you to run a whole BT, but I think it has limits to the blackboard you can use with it
I've seen that there are sub-trees and I was wondering how that works. I've never seen anyone using them in the tutorials.
With BP, I can just make a base class and then create children. I don't know how something like that works with BTs
iirc the subtrees will have to use the same BB as the main tree
otherwise I think they work as they would otherwise
I don't think you can user inheritance with BTs
An alternative to subtrees might be to make custom BT Tasks which are sort of "high level" tasks
where the task itself could contain the logic of what might otherwise be multiple BT tasks
I see
So let's say I have the main tree. How do I "wire" it so that every NPC runs it + it runs its respective subtree ?
I haven't used subtrees but I'd assume it works as any other BT task does
As in you just wire the run behavior task into the tree where you want the subtree to run
oh, also was wondering which controller should be used for an AI NPC - AI Controller or AI Controller Detour Crowd
I don't plan on having 100's of NPCs, but if Detour Crowd has no cons compare to AI Controller, why people don't usually use it ? (I assume it should have better avoidance capacity)
you can do a lot with a single behavior tree
and it does make it easy to debug
one tree with many states in it
@cold trout it's kinda hard to navigate massive tree and I recall someone said it doesn't perform as well as several smaller trees ๐คทโโ๏ธ
AI in UE4 is such a black box because lead AI dev at epic doesn't really do much of cohesive training streams
there's a bunch of ai related modules that have no info on them either
and the code for them is like yeah I don't know :D
...it's still a 100x better than "AI? what's that?" which is the Unity offering :P
haha, true
so, back to my AI Controller vs AI Controller Detour Crowd - which for what use ?
Not sure if detour has any differences besides the crowd system stuff ๐ค
I'd imagine it might be slightly more expensive to use since it would affect the crowd system when it moves but I haven't looked at it in that much detail
hi guys!
do you guys know if there's a way to generate NavModifiers along a spline?
thanks ๐
It's been a while since I came here offering rather than asking, so I thought someone might appreciate this: I found how to grab and draw an skeletal mesh pose at a specific position in the VisualLoger and/or using DebugDrawMesh.
It's something I've been wanting to do for a long while and I finally had time to look for it.
Here it is (sorry, I can't show images due to NDA and I don't have other project to test right now)
The function to implement
bool UTAEnemyMovementComponent::GetVerticesAndIndicesFromSkeletalMesh(USkeletalMeshComponent* SkeletalMeshComponent, int32 LODIndex, TArray<FVector>& OutVertices, TArray<int32>& OutIndices)
{
OutVertices.Reset();
OutIndices.Reset();
if (!IsValid(SkeletalMeshComponent))
{
return false;
}
FSkeletalMeshRenderData* skMeshRenderData = SkeletalMeshComponent->GetSkeletalMeshRenderData();
FSkinWeightVertexBuffer& skinWeights = *SkeletalMeshComponent->GetSkinWeightBuffer(LODIndex);
const FSkeletalMeshLODRenderData& dataArray = skMeshRenderData->LODRenderData[LODIndex];
const int32 numSourceVertices = dataArray.RenderSections[0].NumVertices;
const FVector skeletalMeshLocation = SkeletalMeshComponent->GetComponentLocation();
for (int32 i = 0; i < numSourceVertices; ++i)
{
const FVector skinnedVectorPos = USkeletalMeshComponent::GetSkinnedVertexPosition(SkeletalMeshComponent, i, dataArray, skinWeights);
OutVertices.Add(skinnedVectorPos + skeletalMeshLocation);
}
//get index buffer
FMultiSizeIndexContainerData indicesData;
dataArray.MultiSizeIndexContainer.GetIndexBuffer(indicesData.Indices);
for (int32 i = 0; i < indicesData.Indices.Num(); ++i)
{
OutIndices.Add(indicesData.Indices[i]);
}
return true;
}
How to use it
TArray<USkeletalMeshComponent*> skeletalMeshes;
enemyBase->GetComponents<USkeletalMeshComponent>(skeletalMeshes);
for (USkeletalMeshComponent* mesh : skeletalMeshes)
{
TArray<FVector> vertices;
TArray<int32> indices;
UProceduralMeshComponent* proceduralMesh = nullptr;
if (GetVerticesAndIndicesFromSkeletalMesh(mesh, 0, vertices, indices))
{
// Pick your flavour: Visual Logger or good old Draw Debug
//DrawDebugMesh(enemyBase->GetWorld(), vertices, indexes, FColor::Red, false, 60.f);
//UE_VLOG_MESH(enemyBase, TEXT("NavSuicide"), Error, vertices, indices, FColor::Red, TEXT(""));
}
}
Another version for the ones (like me) that only want to use this as debug and the lowest LOD is perfect
bool UTAEnemyMovementComponent::GetVerticesAndIndicesFromSkeletalMesh(USkeletalMeshComponent* SkeletalMeshComponent,
TArray<FVector>& OutVertices, TArray<int32>& OutIndices)
{
OutVertices.Reset();
OutIndices.Reset();
if (!IsValid(SkeletalMeshComponent))
{
return false;
}
FSkeletalMeshRenderData* skMeshRenderData = SkeletalMeshComponent->GetSkeletalMeshRenderData();
const int32 lowestLOD = skMeshRenderData->LODRenderData.Num() - 1;
FSkinWeightVertexBuffer& skinWeights = *SkeletalMeshComponent->GetSkinWeightBuffer(lowestLOD);
const FSkeletalMeshLODRenderData& dataArray = skMeshRenderData->LODRenderData[lowestLOD];
const int32 numSourceVertices = dataArray.RenderSections[0].NumVertices;
const FVector skeletalMeshLocation = SkeletalMeshComponent->GetComponentLocation();
for (int32 i = 0; i < numSourceVertices; ++i)
{
const FVector skinnedVectorPos = USkeletalMeshComponent::GetSkinnedVertexPosition(SkeletalMeshComponent, i, dataArray, skinWeights);
OutVertices.Add(skinnedVectorPos + skeletalMeshLocation);
}
//get index buffer
FMultiSizeIndexContainerData indicesData;
dataArray.MultiSizeIndexContainer.GetIndexBuffer(indicesData.Indices);
for (int32 i = 0; i < indicesData.Indices.Num(); ++i)
{
OutIndices.Add(indicesData.Indices[i]);
}
return true;
}
Ooooh thank you (and sorry also). Didn't know about it. AfK now, will fix later
I didn't know about it either until you posted a wall of code ๐
Know about what?...
how to post walls of code as collapsible box
How??
link is right above your head
That's just a support forum request
oh well, then look for it yourself
...??? Lol
Too bad it really would be a good feature
Can I run a behaviour tree from an actor?
@cerulean sky u can get ref to ai controller and call function with runBT
afaik it should be possible without an ai controller too but you might need to add some components to the actor for it to work
(I don't know the specifics of it though)
Hi! How to mark an actor to be visible for Ai Sight like an enemy?
I would like to set up the player as a Enemy only and NPC's as a friendlies
you need to register it as a stimulus source
there should be a component for it
for the affiliation you need to do it in C++, think you need to implement GenericTeamAgentInterface for that
or whatever it was called
Which is more optimal , stimulus source or EQS?
To me it seems like whatever I can do with EQS, I can do the same with stimulus source too.
To do what exactly?
Stimulus source would make it automatically register with the Sight sense
so I don't really know EQS factors into that ๐ค
@misty wharf I could use stimulus source for query for players around me in range.. EQS can also do the same for me
Ah, not seen that as something you'd do with stimulus sources but tbh haven't looked at what you can do with them that much :)
Most of the YouTube tutorials using stimulus for querying players around them and then follow and attack
And I have seen only few using EQS for the same..
Ohh right I see what you mean
So I was wondering which is optimised
stimulus source makes the actor trigger automatically from the AI perception system if you have sight enabled
so when you walk into the line of sight of an AI, it automatically registers you as having been seen
with EQS, you make separate calls to check stuff like "what's nearby"
so if you want to have it so that when your AI sees something it automatically triggers, stimulus source most likely is a better option
Hmm makes sense.
As per my understanding EQS does line trace to find player in range..
So it's a bit expensive
It depends on how you configure your query, it can do different types of tests
Looks like I need to do more research
@misty wharf thanks brother for explaining to me.
np
Eqs creates a grid where you can calculate stuff such as distance to point, is there any path, is visible. Eqs can score the grids and give you the best 25% , 5% and the one best option
So the eqs is related to the environment while the stimulus is only vision and sound
It doesn't just "create a grid" either. It creates a set of sample points to test. Those points might be a grid, or a circle, or the locations of some special entities in your game world, whatever you tell it to do
EQS is also "CPU time sliced" - it may take a couple frames to run in the background so it doesn't hitch the game too bad
Yes, if you go into your eqs and drop down an arrow you will find those grid options, they have different shapes etc
The main difference is that stimulus only deals when there is some stimuli. Eqs can deal whatever you give to it without a stimuli
In my experience you can't check if an AI isn't seeing a pawn with the AI perception
You can check what the perception system reports for a given actor
If it doesn't report anything for sight, well, then you don't see it
EQS is an Environment Query System, not a replacement for perception. Perception is like Sight, Damage, Smell, etc. EQS is like "is there a chest i can loot near me, is there a barrel i can throw at a player nearby, is there a place i can find cover?) kinda stuff
Hi! Someone knows correct list of FGenericTeamId?
friendly matches 0 and so forth?
By my deduction which prompted me that 0 == hostile. If someone had a experience with Detection by Affiliation I will be grateful of informations
I would like to set Player Character to be an Enemy and NPC's to be Friendly/Neutral (I know 255 == NoTeam)
I think the way it works is that you define what attitude the teams have to each other
so any team can be hostile to any other team, or friendly, or neutral
So If I add my Player Character to Team )
0
NPC to Team 1
then My Ai Sight config will be able to determining how is friend (team 1) and how is a possible aggressor (team 0)?
I think you can override GetTeamAttitudeTowards
hey guys!! ๐ wanted to know if there's any way to make a Spline to use a NavModifier accross it's extension?
or something near to that? the idea is that splines will be representing vehicles routes and we want the AI to know that those routes are expensive for them to cross to the other side unless they go through a crossing that will have another NavModifier making it cheaper ๐
You could possibly generate nav modifiers along the spline's path
not really sure how well it would work if your spline is very curvy though
So my AI runs to a random point and stops abruptly at the destination. How do I make it decelerate before stopping ?
is it a well known secret that variables in an AnimationBlueprint dont replicate?
despite there being a checkbox for it etc
or am i just missing something completely
@flint trail some combo of settings in the character movement comp, bUseAccelerationForPaths, bRequestedMoveUseAcceleration, float Braking Deceleration Walking
@undone hull maybe use a nav mesh obstacle on a spline mesh with a custom nav area set to it, thats not totally costly
@cold trout doesn't seem to be doing anything ๐ซ
is it a well known secret that variables in an AnimationBlueprint dont replicate?
despite there being a checkbox for it etc
or am i just missing something completely
@flint trail some combo of settings in the character movement comp, bUseAccelerationForPaths, bRequestedMoveUseAcceleration, float Braking Deceleration Walking
@undone hull maybe use a nav mesh obstacle on a spline mesh with a custom nav area set to it, thats not totally costly
@cold trout yeah dude, i'm setting up my custom NavAreas for that and added a NavModifier component on the BP.. the problem is that the NavModifier it's only applying on a collision volume i've got, instead of the meshes
the way i'm fixing this is by adding collision boxes along with the splines meshes (with collision checks on overlaps and events shut down), but i hope there's no performance issues when adding lots of collision volumes
Is there a stock function that returns distance to the destination when called ? (while Ai is on the move to the destination)
Nothing I can think of. You could use "Path to location synchronously" and total the distance between points.
Cheaper might be line trace to destination. If the trace is unobstructed + less then your threshold, you could decelerate.
hm.. I see. That was my first thought, but I was hoping for something built-in for AI specifically (hopefully more performant than trace)
AI Controller has a move completed, but not a Move Update event. You'd probably need to go deeper and extend the PathFollowingComponent to return a distance remaining estimate.
Interestingly, Path Following component already has a braking distance that it must get from somewhere.
And DecelerationSegmentIndex.
So it is already capable of planning a deceleration.
Appears to have worked for someone.
I wonder if it's broken in 4.25.3 cuz I tried doing some of that yesterday (not from that post) and that didn't work.
Works in my 4.25.4 test project.
if you have the location of your destination and the current location you could calculate it
d = ((x2 - x1)2 + (y2 - y1)2 + (z2 - z1)2)1/2
Had to set all of acceleration for Paths, use fixed braking distance, and a distance to start braking.
thanks, will try that
@obtuse sleet I think there is a node in BP for calculating distance between source and destination point..
How do i get a AI to see another AI
The AI perception/Sense system works for AI pawns the same as for players.
so would i use AI perception to sense other AI
because pawn sensing only detects players
Yes. That's what I use for similar things (sensing AI goals in the environment). I started using UE after the AIPerception system landed, so I've never really messed around with Pawn Sensing.
so with AIPerception how can i get it to see another Ai like how the pawn sensing can see players
You just need to have the AI have a AISenseStimuliSource component, with at least one sense type defined.
And a AIPerception component with that sense.
Then you can start getting events about when the AI "sees" other AI's.
Pretty good basic intro here: https://isaratech.com/ue4-ai-perception-senses-and-stimuli-source/
when using AIMoveto function, and two actors from the same blueprint with it bump into each other, they get stuck in each other for some reason, and only start moving once I destroy one of them. I was thinking I could make them bounce off each other if they touch, but I realized I have no clue how to get a blueprint actor to check overlapping components of the exact same blueprint. is there a common workaround for this?
...huh?
aha, I guess there is a bug in AIController Detour Crowd - braking doesn't work and acceleration is out of whack.
that's why none of those parameters had any effect on my AI NPC
switched back to regular AI Controller and it works now ๐
Is Detour Crowd AI Controller broken or incomplete ? Has anyone dug into it?
anyone?
I've noticed that a lot of AIController things are "Except for Detour Crowd", so I suspect getting good crowd behaviour involved a number of sacrifices of other expected features.
I see
I guess I just use RVO then
I don't plan on having more than 5 NPCs at a time available to fight player
how can I make NPC turn on the spot to face the destination and only then have it move toward it (and also to kick off turn-on-the-spot left or right anim) ?
With RVO, sometimes your actors will get pushed out of the navmesh, so you'll need a strategy to get back onto it.
I'm not sure. I'd probably define a sequence in my BT, with a custom "Turn toward" action, followed by an AI Move To.
right, but how does one turn character in BP, smoothly ? Rinterp or something else ?
RotateToFace might be enough? Though I think you need something setup in the MovementController for that to work right.
Movement Component ?
Yes. Use Controller Yaw maybe?
yeah, that need to be disabled
also there an option in rotations "something something rotate smooth toward movement direction"
hey all, just getting started with AI and i was following this tutorial on youtube
https://www.youtube.com/watch?v=eLI6TOXaG5k&t=1012s
unfortunately, despite doing everything this person says, i do not get the same results and my NPC doesn't move at all
some thoughts would be helpful :)
In this episode I show you how to make a NPC patrol a route; travelling from point to point.
Support me on Patreon and get access to videos early, join our developer community on Discord, get exclusive behind the scenes videos on my projects and much more over at https://www....
adding on to this, i looked at my behaviour tree while the game was running and it showed that all was well except the IncrementPathIndex
this is what my blueprint looks like:
added that now, but i run into another issue where the npc moves to one point and stops there
So, it worked fine before and when you got to that part where NPC patrols between nodes it stopped working ?
so there are 3 points on the map, the ai finds the first point in the list and moves toward it then repeats it for the other 2 points
but it just stops on the first point
hey guys, in my BT I seem to have nodes that active by aborting others with decorators. but then when the decorator condition is false the tree does not reset to its default state... what am I missing?
what do u mean reset to default state, jump out of the decorated nodes?
yeah as in go back to the least resistance path
click the decorator then choose
self, will abort all nodes below it, lower prio will abort all nodes to the right
I got aborts lower on for when the decorator condition is true (which is desirable). but equally when the decorator condition is false it does not return out of the node
I was thinking if I need another decorator node that aborts self on the inverse decorator, but in that case the node gets skipped entirely