#gameplay-ai

1 messages · Page 130 of 1

south palm
#

@solar bronze can you see if I did anything wrong cause I checked everything and it's the same

solar bronze
#

but can you actually show me YOUR behavior tree?

south palm
#

Uh currently I'm on phone

#

Can u wait pls

solar bronze
#

ok

#

i can wait

hexed spade
#

the AI is walking in circles because it drops the ball, looks for it, grabs it, drops it again repeatedly every 0.3 seconds because its tied to MoveToLocation, how do I make it delay so this won't happen?

lyric flint
#

U can add a cooldown decorator so it cant enter the node if thats the case

hexed spade
#

ah I will give that try

old adder
#

Hello guys, do you have example or way to make group of AI swarm the player in a tight circle for melee attack?
I tried the CrowdController for AI and EQS but they still get stuck on each other or move really slowly when colliding each others.

hexed spade
#

hi guys I opened UE4 today and behavior tree is disabled??? how did this happen and how to fix? thanks

lyric flint
#

did you even made a behaivior tree ? go to the tree and check there if the tree has this blackboard or something idk

hexed spade
#

yes i was working on it until last night. shut down computer, open it today and it wont let me switch

#

I guess I will just have to start over but maybe this is a bug?

#

what the now i have it

#

i just opened the tree and its fine now lol

lyric flint
#

yeah

real spire
#

Maybe you had a bug but what's for sure is that if you open a Blackboard asset in the content browser without first opening a tree asset linked to that blackboard you'll get the blackboard asset with the tree link at the top right greyed out because the Tree-Blackboard association exists inside the Tree. The Blackboard doesn't know which Tree it should open. I guess having it like that allows a blackboard to be used my multiple trees?

misty wharf
#

Are there any best practices in terms of organizing AI logic between pawn, controller and behavior tree?

#

Or is it all sort of "it depends" thing?

#

Just wondering as I'm working on some semi-complicated AI task logic and it feels like I'm constantly tweaking something in it because it feels like it's not set up in a nice way :D

south palm
#

how would you make AI open a door?

#

unreali need to know

#

nobody is talking lollll

gaunt kite
#

@hexed spade Just go to the Behaviour tree and remake a BB again, it usually buggs out

pine steeple
#

@south palm not everyone is around when you are, also not many people do AI or talk in here. complaining within 10 mins is kinda silly

south palm
#

True

#

my sincere apologies

solemn nova
#

Can I run a behavior tree from a playercontroller?

wicked flint
#

I don’t believe so, the whole point of the behaviour tree is to act as the “brain” for an aicontroller

solemn nova
#

hmm, ok thanks, I need to continue the BT logic after possessing a pawn... I guess I can just posess it later

#

I'm guessing it would result in some lag compared to local but maybe that could be hidden with animations

#

I'll need to revisit this when I look at the animation system properly

thin hatch
#

Hey folks new to the discord, so if this isn't the right place to post about this, please tell me. I'm having an issue where my navmesh will not draw on the landscape but will on the surface of static meshes. I'm using navigation invokers and everything works fine in other areas of my landscape. At first I figured it must just be a collision blocking that area. But there's nothing there and as this screenshot shows the navmesh still draws on the top of static meshes.

sturdy iron
#

You need to define in your navmesh how high the steps can be what angles etc

fiery leaf
#

How would I go about specifying different "zones" for an AI? Like I want them to be able to navigate outside of a room, but once they enter the room their navigation should be limited to that area. I'd also like to specify places they can't go in that room. If I use one giant navmesh for inside and outside, it will still look outside when using Get Random Reachable Point.

#

Never mind, a NavLink seemed to do the trick 🙂

midnight dune
#

I have a simple behavior tree with a task that finds the nearest player then moves to the player, how do I get the ai to break out of the move to and check if another player is closer? Right now the ai will run right past player 2 if it’s in the “move to” chasing a player 1 that ran past player 2

#

Looks like a parallel might be what I need, it’ll be tomorrow before I can try it out

misty wharf
#

Another option could be a BT Service

#

You could have it activate when the chase branch is entered, and then it can run at a certain interval to scan for other players

lyric flint
#

Yo i have a question cause i had my ai's on aicontroller i changed it to detour they were not spawning and then i switched it back wasnt working also, restarted still not working so idk what happened

last river
#

Does anyone know if EQS can have manually placed points of pathing? I am looking to have many simple minded entities (will spawn groups if near player) moving between these points of interest based on some sort of factors. Currently though I am stuck even finding an example or tutorial of EQS points being anything other than a grid or some sort of procedural formation. I was hoping there is a way to have the points be dynamic over a large map and AI could add more of these points during runtime but the initial points of interest would be manually placed by me.

misty wharf
#

@last river one thing that comes to mind is you could place your points as actors of a certain type, then use EQS to query for actors of that type. This way the items would be those points instead of a generated grid or such

last river
#

@misty wharf thank you, I'll see if I can find any information on how this performs since I plan on having many entities on a large world map deciding to move to and from these points and performing some sort of check if they win/lose against another entity already occupying a point. Hopefully all of this can be performed by one eqs and if the player is close to one of these interactions then I can have one of these entities spawn however many pawns that entity is supposed to represent and then I can have a more detailed EQS start on each of them.

#

I have a feeling that performance may not be too great on this, so I am also looking into if I could maybe have an AI manager blueprint that holds a very large array of each entity + their locations/destinations/and timers for each of the entities

misty wharf
#

Yeah not really sure about the perf side.. You can filter it by range for the query too so you could only query for actors within a certain proximity which would probably help

last river
#

Yeah, I was thinking about doing that, I do not know enough about EQS yet to know how that works or the expense. Right now I am also looking into what I might be able to pull off in blueprint concerning the large amount of dynamic variables in arrays I might try in keeping track of these locations and entities

misty wharf
#

I'd just go with whatever is simplest to get working :)

#

I'm using EQS for a bunch of random things in my game right now because it's so simple to utilize for those tasks... it might not be the most efficient way, but because it's so simple, it would be very easy to replace later if needed

gloomy vector
#

Does playing sounds with the PlaySound task in the AI Behavior Tree work differently? it just doesn't seem to work like other tasks like Wait or MoveTo.. I can't find any docs or tutorials about using sound with AI..

#

What i'm trying to do is when the enemy sees the player, it plays a sound once and moves to the player, if it looses sight of the player is plays a different sound and starts roaming. move and roaming works, but sounds play constantly.. if I use a Cooldown decorator, but it will just repeat less often.

misty wharf
#

are you sure the BT isn't just repeatedly activating the node?

#

in a situation where the AI moves a short distance, it would then finish the move task and possibly repeat the whole graph from start again, also triggering the sound along the way

gloomy vector
#

ya it could be,, but how would you debug that? there's no print string I can see..

misty wharf
#

You can add a breakpoint into the BT

#

or you can make a custom BT task that prints a string every time it runs or something :)

#

or a custom decorator could do that too

gloomy vector
#

ok thanks! you're right it is repeating. I have Ignore Restart Self checked but it doesn't seem to work or doesn't work the way I think it should : ) shouldn't that only play the sound if it's not playing already?

misty wharf
#

it depends on how the sound is configured and how the node works

#

you could structure your BT so that it doesn't exit when the movement has finished, and would instead just loop

#

you might have to set up some way for it to abort if needed (eg. using a decorator that aborts lower prio), but that would be one way of doing it at least

gloomy vector
#

cool, how would you setup a loop? I'm just getting into AI.. I kinda wish they had just made BP nodes for everything : )

misty wharf
#

you could do it in BP's too if you want

#

there's equivalent or close to equivalent nodes for most of the BT stuff

#

anyway, for looping, there's a decorator

#

so for example you would set it up so that you have a sequence, which first has the play sound in it, and then another sequence

#

you put the other nodes like the movement inside the nested sequence

#

and add a loop decorator on it, so that way it would only ever play the sound when it first starts this branch, and then keep looping the other nodes

gloomy vector
#

ok I'll try it, thanks!!

lyric flint
#

Yo i have a question cause i had my ai's on aicontroller i changed it to detour they were not spawning and then i switched it back wasnt working also, restarted still not working so idk what happened
@lyric flint 😦

misty wharf
#

TFW you go to google to look up some BT stuff, and find an answer from 2015 from an Epic staffer saying "wil will add array support to blackboards in 4.8"

#

5 years later feature does not exist :P

polar furnace
#

hi i need nav mesh in sea for fish

#

i dont want fish stick to the ground

#

how can i do this ?

#

tag me please if you have any idea

#

🙏

gloomy vector
#

try using the nav mesh for location and randomized z for height, maybe? or search for flying ai..

misty wharf
#

Anyone know what "project goal location" in the BT Move To task does specifically? I was trying to get the AI pawns to move to an actor, but they just wouldn't... until I turned "project goal location" off

#

I was under the impression that it projected it to the navmesh meaning it should work better for points that might not be directly on the navmesh, but it seems like the opposite based on the above result?

charred ruin
#

Guys, sorry for dumb question, but how do you check if a bool is true in a behavior tree?
Do you create a decorator that checks if a value is true, or compare the bool with a always true value? Or is there another way?

idle widget
#

@charred ruin are you talking about a bool that is a blackboard key or not?

charred ruin
#

Yes, I basically want to pass a bool from the character to the BB

#

and check if that bool is true in the BT

idle widget
#

so the decorator "Blackboard Based Condition" will compare if a BlackKey is set(true) or not set(false). Boolean Blackboard keys are always set to false by default

charred ruin
#

Oh, so Is Set actually means is set to true? I just thought it meant if the value is valid or not

idle widget
#

Oh, so Is Set actually means is set to true?
Well you can set a boolean to either 0(false) or 1(true)

#

so boolean are always set to false when you first declare them in member and are always valid because zero means false to a boolean.

#

that is the same for all primary data types in C++

charred ruin
#

I know but I thought Is Set was meant to be used as if a value has been set since the BT started running

#

like how it can take in a FVector

idle widget
#

that is true for any User Define Type like any class, structs

#

but not the case for integers, floats, and bools because 0 is valid for them

#

the blackboard declares the keys as variables when it start up and the actually value of them are 0(which for User Define Type like any class, structs is nullptr)

charred ruin
#

So is it basically if(condition) ? like if(bool) or if(pointer) or is it if(object.IsValid())?

idle widget
#

bingo

charred ruin
#

if(condition) or if(object.IsValid())?

idle widget
#

so they use a condition
for UClass:
return (Op == EBasicKeyOperation::Set) ? WeakObjPtr.IsValid() : !WeakObjPtr.IsValid()

WeakObjPtr is a weak pointer to an object
for boolean:
return (Op == EBasicKeyOperation::Set) ? Value : !Value;

Value is boolean

#

and in both Op is Set or NotSet

charred ruin
#

Kinda got it, but how can Op be NotSet? when does that happen?

Let me know if I am wrong:

#

If a value is never set, it will always return false

But if it was set, if the value is bool, it will return the value. If the value is an object it will return if it IsValid, right?

idle widget
#

Op is based on what you select in the decorator node details

charred ruin
#

Oh right

#

got it

#

Not used to using anything other than C++ lol

#

thanks a lot, I understand it now

idle widget
#

you welcome

charred ruin
#

Where did you find this by the way:
`return (Op == EBasicKeyOperation::Set) ? WeakObjPtr.IsValid() : !WeakObjPtr.IsValid()

WeakObjPtr is a weak pointer to an object
for boolean:
return (Op == EBasicKeyOperation::Set) ? Value : !Value;`

idle widget
#

return (Op == EBasicKeyOperation::Set) ? WeakObjPtr.IsValid() : !WeakObjPtr.IsValid()
is found in BlackboardKeyType_Class.cpp method: TestBasicOperation line 56

return (Op == EBasicKeyOperation::Set) ? Value : !Value;
is found in BlackboardKeyType_Bool.cpp method: TestBasicOperation line 40

charred ruin
#

I see, thank you!

idle widget
#

the decorator does eventually calls those methods when the BT evaluates the node

deft hound
#

Hi, I'm having trouble with an "AI MoveTo"/MoveToLocation when the place it's going is close in terms of vertical distance. If someone could shed some light as to why it could be failing that would be much appreciated. I have explained the issue in detail on Answerhub here: https://answers.unrealengine.com/questions/981036/view.html

#

Thanks

thorny jay
#

Hi all, is there a way to have a smart link only useable if an AI pawn meets a certain condition? I want a smart link to only be available if the bot is on a particular team, as some doors can only be opened by a defending team

pine steeple
#

you would need to use C++

#

and create your own smart link base

lyric flint
#

Yo guys i need help, my ai mysteriously stopped spawning in the world and when i even manually dragg them in the level while playing they are in the level for a second but disapear after

pine steeple
#

Ah with my power of mind reading, i know the answer!

#

You did not connect Node A to Node B and Node C never got executed.

lyric flint
#

yes, mind reading

#

well it actually stopped working after i changed the controller to detour and yeah i tried changing it back to the controller that i was using but nothing changed

pine steeple
#

what does the Gameplay Debugger say?

#

or the Visual Logger?

#

those are your best friends with AI

#

if you don't know what they are, google them, learn them, and then come back to me with some more info.

lyric flint
#

ok googled it

#

but i have no clue

pine steeple
#

your supposed to press start

#

then play the game

#

then it logs any issues

#

but it seems like you are starting your BT too soon

lyric flint
#

yeah i did press start and played the game for some time

#

i did that couple of times and it was the same

#

i just put on npc to log the location

#

but since he despawns like .0001 s after spawn then yeah

#

and i know that the npcs are spawning cause they do print string on begin play

thorny jay
#

@pine steeple Thanks! C++ doesn't bother me :-) I'll take a look

thorn ginkgo
#

Hihi! I'm looking for any reccos on the marketplace for non combat ai systems. I'm making something that needs an ai to explore/ meander from one point of a procedural landscape to another. maybe stop and smell the roses type stuff. Let me know if you've seen something neat! thanks!

thorny jay
#

@pine steeple I can't seem to find any useful documentation on doing something like this. Do you know of any links I can read, or happen to know how I can set a nav link proxy to be conditionally active for a particular AI? I can see a function called IsNavigationRelevant, but this appears to not take any parameters, so I'm not sure how I would check the AI's team and return true/false accordingly

#

Thinking about it, I could maybe do it using supported agents, but both team 1 and team 2 would have the exact same agent attributes, so I'm not sure how I would override UE4's default agent profile assignment behaviour to set it based on the pawn's team

#

By default it's set based on the width/height of the agent

deft hound
#

Hi, I'm having trouble with an "AI MoveTo"/MoveToLocation when the place it's going is close in terms of vertical distance. If someone could shed some light as to why it could be failing that would be much appreciated. I have explained the issue in detail on Answerhub here: https://answers.unrealengine.com/questions/981036/view.html
Thanks

bleak iron
#

Maybe the acceptance radius is too high?

#

Is the character failing to move? Or failing to arrive?

#

I have an issue with deceleration. I want my characters to slide after they stop moving. But no matter what value I input, the result is that they stop instantly

#

I've set all deceleration and friction to 0 and they still instantly stop

thorny jay
#

@bleak iron I think you also need to modify "Braking Friction" and "Braking Friction Factor"

#

By default "Use Separate Breaking Friction" is ticked

#

I have a setup for cavalry where the horse gradually slows down over time, and this is what it looks like:

bleak iron
#

Hmm and this works?

thorny jay
#

Yes, I modify the slowdown using "Braking Deceleration Walking"

bleak iron
#

Because I've tried this and even 0 friction and friction factor and still nothing

thorny jay
#

If i set it to 0 then the horse just runs forever

bleak iron
#

Still stops instantly.

thorny jay
#

Hmm

bleak iron
#

Must be something else going on...

thorny jay
#

I do have some custom C++ code in my movement component, but that was mostly to create tank controls and prevent players from strafing or turning the horse more quickly than they should. I don't think I modified the braking/friction cod

#

Maybe try copying mine exactly and see what happens, set braking deceleration walking to something like 1 and see if it works

bleak iron
#

Still no luck

#

Thanks for the help, I must be overwriting it somewhere

thorny jay
#

Ok best of luck! I wish I could be more specific, but I did this over a year ago so I've forgotten the finer details

pine steeple
#

hmm

#

@thorny jay what might be simpler

#

is changing the navigation area of the link and use filters

#

so like RedTeamArea and BlueTeamArea and NeutralArea, then if its RedTeam only, then give the link that area class

#

and the navfilter applied can be determined by the team they are on

fiery spoke
#

What could cause AI to stuck when he runs and shoots at my player? It does this on the clean landscape; it stuck and kinda jitters for a couple of seconds, and then again walks and shoot at me.

signal tangle
#

are you using a behaviour tree, is there any kind of timer in there? have you brought up the debugging ' then 4 on the num pad to see what state he gets into?

fiery spoke
#

@signal tangle Yes it has behaviour tree. I use AIBehaviourToolkit. There are some wait time nodes.

thorny jay
#

@pine steeple That's a great shout, I'll look into that 🙂 Thank you!

deft hound
#

@bleak iron Hi Breezy. Yep the character still moves, it seems to go to the first waypoint but then on the way to the second it ignores the smart link proxy to the top platform, runs past and runs on the spot at the end of the platform, before stopping after a few seconds.

#

@bleak iron I have tried different Acceptance radii in both AI move commands, I've tried 100, 50, 20, 10, 5, 2, 1, 0 and -1.

#

In the words of The Fifth Element herself: Pleaaese Halp

wicked flint
#

Hi guys, can someone show me how to assign an aicontroller to my pawn when it is spawned? I'm not sure how to get the aicontroller to possess my pawn at BeginPlay()

idle widget
#

it is the AI controller Class property in APawn, you set this to the correct AIController, than if the auto possess is set the "Placed in world",. the controller will be created and the pawn will possessed by that controller when the pawn is placed in the world

wicked flint
#

thank you, i will look into this

idle widget
#

@wicked flint if you are spawning this APawns vs placing them in the world than you want to change the Auto Possess AI to spawning vs place in the world

bleak iron
#

@deft hound Looking at your question, I'd say the problem is not with the AI, because it works when the platforms are higher apart. The problem is with the nav mesh. Play around with the NavMesh's size and sensitivity settings.

#

My feeling is that the character's head is close enough to the upper nav mesh for him to think "I'm in this nav mesh" even though he's on the lower one

deft hound
#

Thanks Breezy I'll give that a go. I feel that you may be right. I've tried some settings, but also tried shrinking the AI character right down to 0.1 without luck.

stark zealot
#

I'm trying to make my AI do a jump attack. The animation works but I was wondering how to add more movement to it. For example in this attack he jumps up into the air with his sword and then slams down on the ground. I want to add more air to the jump and then make him come down at the target players location. Do I use an animation notify to add more input to him? Or is there another way?

tiny comet
#

@stark zealot if you are using root motion, then you can modify the attack animation. If you are procedurally moving character (eg using jump or launch), then you can modify the forces to jump or launch.

stark zealot
#

@tiny comet I'm not using root motion because I read that it's trickier with multiplayer. I've been playing around with it today and wound up using an anim notify that then executes a timeline that lerps the location of the character. It looks really good so I guess I'll keep doing this for more attacks lol

tiny comet
#

so if you are using a timeline to lerp the location - then you should be able to modify the location of the jump so the position of the character is correct. If the animation doesnt quite look right after this- maybe split it into 3 parts start/loop/land and the if the jump is longer play the loop longer

stark zealot
#

The only thing that seems inefficient is having to hand tailor a timeline for each attack and using trial and error tweaking with the timeline length in order to make it look right. I guess that's the drawback of manually doing it vs using root motion

tiny comet
#

yeah - and even with root motion you still have to do that work editing the animation.

stark zealot
#

Yea. Well as long as it's working I'm happy lol. It takes a little fine tuning but the results are worth it. 🙂 Thanks for your help

fading grotto
#

I'm working on a multiplayer game. I want my AI enemies to move to a set goal object, and when a player tries to get in the way basically they get the aggro of the AI monster. The problem is Behavior Tree seems very impractical for handling multiple players and network replication. What should I do?

fading grotto
#

@fading grotto If you AI Pawn is replicable and you can replicate movement, you can just basically replicate the position of the AI Pawn, from server to all players
@ancient grove I have issues with target selection too

#

Well it seems like its working.

pine steeple
#

use distance squared

#

its cheaper

#

and tbh that is ok, tho i prefer to have a service run every .1 to .2

#

and update blackboard variables

#

have the decorator just check those BB keys

#

a decorator should NOT ever EVER set a blackboard key

#

that is what tasks/services are for

autumn kelp
#

Hey I have a question regarding AI simply not moving

#

So on simple AI MoveTo Node it always gets aborted and I don't know why
If I get close enough it succeeds but still doesn't move

#

I have AI actors that work just fine with the same setup

#

Can't quite figure out what the issue is

#

When setting acceptance radius value to -1 it moves for a brief second then stops

#

The error was simply me not initializing the character movement speed :)

hexed spade
#

hi guys im not sure why my AI has stopped moving to the ball. what could be going wrong here? why is there a hole around the ball?

#

hmmm now it works....but the ball is clipping the ground slightly

thorny jay
#

@hexed spade the ball is affecting navigation, and since the ball is placed in the editor, the navmesh generation assumes its a permanent fixture and therefore doesn't generate a walkable area under it

#

There should be a way to set it so the ball actor doesn't affect navigation, not sure off the top of my head what it is though

misty wharf
#

it's called "can ever affect navigation" or something like that ^

#

it might be in one of the advanced settings drawers that you have to expand

lean cliff
#

It is, it's under collision, and then under the advanced bit that's collapsed 🙂

hexed spade
#

thank you for your answers. it is behaving correctly now 😄

rapid ridge
#

it's the first time I'm going to dive into AI, any resource recommendation? My goal is to make a challenging AI for a topdown ARPG

charred ruin
#

Hey, when using AIPerceptionComponent, how do you know if an actor is sensed using a particular sense? So how do you know if it is sensed through sight or hearing?

pine steeple
#

need to grab the class

#

and check if class is Sight

#

its a bit crap in BP

#

in C++ i made some nice functions to convert to a ENum

charred ruin
#

@pine steeple how do you grab the class? Using OnTargetPerceptionUpdated or OnPerceptionUpdated I don't get any class which I can cast.
I can use Get Perceived Actors and use a specific sense, but then I have to do a loop on all of them.

#

Also it'd be nice if you could share those C++ functions or point me in the right direction

lusty egret
#

How can I associate a pawn to a specific nav agent? (so I have my default agent for the humanoid pawn and an agent for the car pawn)

twin loom
#

What are the benefits of EQS?

thorny jay
#

@twin loom EQS is asynchronous, so it avoids clogging up your main thread and causing hitching

twin loom
#

Does it have good performance?

thorny jay
#

Yes, it generally tries to be smart about the order in which it performs tests so it can discard items early, and it timeboxes the tests so they don't drag down framerate if you're doing a lot of them

twin loom
#

ok thanks

thorny jay
#

No problem

rapid ridge
#

An Environment Query is actually made up a number of different pieces. You can call an Environment Query from a Behavior Tree, and then the actual Environment Query will use its Generator , reference its Contexts , and use its Tests to give the Behavior Tree the highest weighted result.
Couldn't find performance wise differences but is this the main difference between EQS and AI Perception?

pine steeple
#

they are different

#

no way related

#

Perception is for the pawns to percept things in the world

#

EQS is to query things in the world

#

EQS can be used for many things, like grabbing all chests in range, generating points in the world, etc

#

nothing to do with perception.

thorny jay
#

A common use for EQS, for example, is to let an AI determine a good vantage point to attack the player from, that is in line of sight, not too close etc.

mighty light
#

So basically i have an ai which will chase me if i stand in his pawnsensing how do i make it so he stops chasing me after 5 seconds of not being in his pawnsensing?

pine steeple
#

A: Don't use pawnsensing, B: There are many ways to do it, could start a timer when not sensed, 5 seconds later, go back to roaming, when sensed, stop timer and start chasing.

rapid ridge
#

Just to be sure AI Perception's PeripheralVisionHalfAngleDegrees means 360 degrees when set to 180 right? That's how I understood it but want to be sure

pine steeple
#

its half angle

#

so yes

#

45 would be 90 (45 left, 45 right

rapid ridge
#

okay tyty

#

the SetBlackboardValueAsVector needs a key, and it can be a variable that is named as the key in the blackboard is named right?

pine steeple
#

you assign it

#

in the BT

#

on that node

#

to whatever key

twin loom
#

I'm using the same BT on multiple objects. The BT currently only makes the objects wander around using EQS. The problem is, that both objects are behaving the same way. I don't know if this is a BT problem or the EQS problem that decides the location.

#

This is the EQS, both test's are filter only. My hope is that since nothing is scored, the AI will choose a random spot to go to

misty wharf
#

You could probably write a custom test that gives items a random score if something like that doesn't exist yet 🤔

#

dunno if that makes sense, just a thought

twin loom
#

rn, I just wanna know why both my objects are moving to the exact same spot

twin loom
#

Just a quick question, can I have multiple BTTasks and services in 1 script? I wanna avoid making 20 different scripts for like 5 lines a class

#

@misty wharf There is a random option, I just didn't see it. It also fixed the problem of why the objects were going to the same place

oak pendant
#

so i am experimenting with EQS and it seems very cool for certain things. i noticed in the code that the GamePlay Tag query test does not "work" at run time.

#

meaning that if you add tags at runtime. they do not effect the test results.

#

it appears that the results of the query are cached the first time it is run so any new tags wont be on the cached objects.

#
class UEnvQueryTest_GameplayTags : public UEnvQueryTest
{
    GENERATED_UCLASS_BODY()

public:
    /**
     * @note Calling function only makes sense before first run of given query
     * by the EQS manager. The query gets preprocessed and cached then so the query 
     * value will get stored and calling this function will not change it (unless 
     * you call it on the cached test's instance, see UEnvQueryManager::CreateQueryInstance).
     */```
#

a bit stuck atm as i want my AI to respond to events in real time. imgine i want an NPC to use a certain attack if you are close enough and stunned. (where stunned is a GP Tag)

#

i mean i can return the list and filter myself but thats seems counterproductive. any thoughts?

twin loom
#

In my blackboard, I have some variables that I set at runtime, where would I set them? Begin play in the character or begin play in the AI controller?

twin loom
#

Just a quick question, can I have multiple BTTasks and services in 1 script? I wanna avoid making 20 different scripts for like 5 lines a class
Still have this question as well 🙂

simple crest
#

haven't done it myself but it should be fine to put multiple BTTasks or other classes in one pair of .h and .cpp files. UE doesn't really care about matching file names to type names or anything

twin loom
#

ok, thanks

dire frigate
#

Hey all, just curious if someone can help me out with something

#

The chase works, but the patrol doesn't and as far as I can tell, everything seems to be identical to what is on their documentation

#

It seems that the Set Blackboard Key as Vector is where it is failing. The Vector itself is updating, but it isn't setting it to the blackboard key correctly

#

I update a new location to this Blackboard Key, then I print it immediately after and the value isn't changing at all. Even though I have printed the vector that I am feeding into the "value" and that is changing.

dire frigate
#

Ok, I figured it out. It needs to be set as "Instance Editable"

dire frigate
#

Now I have a new issue though. At the game start, all of the Enemies Patrol Location is the same location at first until they reach that destination. Then once they get there, they move around

twin loom
#

How would I get the controlled character location from a BTTask's execute function in c++ or BTService's OnSearchStart function in c++?

midnight dune
#

I have two services, in the first i find the closest of the player characters that spawn into the game. In the second service I'm trying to get the value of the closest player from the first service. Is this possible if so how can i accomplish this?

patent hornet
#

you get the pawn from the controller

#

and get its location

#

@midnight dune set it as a blackboard key (object)

#

in the first service, access it from the 2nd

midnight dune
patent hornet
#

google WFT is? videos for AI and watch those

#

its explained in good amount of detail there

#

from what i can eyeball you probably didn't set the key selector in the instance of the service in the BT itself

midnight dune
charred ruin
#

Hey, when using AIPerceptionComponent, how do you know if an actor is sensed using a particular sense? So how do you know if it is sensed through sight or hearing?

rapid ridge
#

Is there a AI Perception setting to stick to one target? it gets a bit wonky when it senses more than 1 enemy in radius

tidal void
#

I'm working on AI Navigation but I'm having an odd issue with finding a path to a point that should be navigable. At first I thought it might be that the point was too far away but testing shows distance (and thus number of nodes computed) seem highly unlikely. My next thought which I can't seem to find a way to debug and verify is that the grid nodes are too far apart, so some generated goal locations might be to far from a navigable node (if thats how it even works). Here's a video. You'll see two green debug spheres (one is the goal location, the second lower one is the goal projected to the nav mesh), the red sphere when present is the found goal path with each small blue node being a waypoint. Any insight would be greatly appreciated! https://youtu.be/riCzlpn1XCk

Agent is unable to find a path to an open spot on the navigation mesh. No idea why. I'm find a random spot, projecting to the nav mesh, then calculating a path. Sometimes it succeeds, sometimes is fails. But why is the question

▶ Play video
tidal void
lunar bone
#

Heyo! I'm setting up a fairly simple AI. Here's what I want. If the AI has line of sight to an enemy. It should wait for 2s, then get the target location and move to that. If the AI doesn't have line of sight, it will continue with a simple patrol. As you can see in the picture, I have a Blackboard Based Condition on a sequence, that tells the sequence to abort self if Line of Sight is not set. I'm guessing this would immediately abort the whole sequence? That's not really what I'm after. What I want is that if the line of sight is broken during the Wait time, then abort the whole sequence. If the line of sight would be broken during the BTT_GetTargetLocation or BTT_WalkTo, then I want the AI to complete those tasks, and then continue with normal patrol. Anyone knows how I would set that up?

urban wadi
#

Anyone know how to chain montages together without using a delay?

#

I am trying to set up a AI node in which has a bool decorator in a sequence which plays a turn animation and then a roar animation, then enters the attack phase

#

I tried using a sequence but that did not work. I have it working with a behavior executed that plays the Rotate montage followed with a delay and then plays the roar montage. But i dont want to use a delay.

tidal void
#

@lunar bone I think you can move your Blackboard condition from the Sequence to the Wait node. That way it only aborts itself while its running, and not after. It also won't run the sequence if the condition is not met, so you get the same overall effect

dim sable
#

Hi Yall, Wheres a good place to look for learning how to program AI behavior?

#

Im kinda new To Unreal, ive taken some basic stuff, but im looking into making Coding my main path

sand barn
#

@dim sable Look up Ryan Laley AI on youtube

#

He has the best tutorials for UE4

rapid ridge
#

is there a way to make a AI character not rotate towards movement?

simple crest
#

search in the MovementComponent for "rotation" and play with some of the settings @rapid ridge

#

may also need to mess with Pawn "Controller Rotation" settings on your pawn itself

rapid ridge
#

already tried various combinations using those settings without achieving what I want

simple crest
#

then you have some custom code causing your character to rotate

#

or you missed the one setting

#

orient rotation to movement or something iirc

rapid ridge
#

that is disabled,

fiery spoke
#

How to force roaming NPC to turn in place and then continue to walk. My NPC turns but at the same time moves forward which creates this weird sliding movement.

midnight scroll
#

@fiery spoke You kind of already answered your own question by asking it. Do exactly what you asked for. Make a turn then move sequence. Make them turn towards their destination, then once their rotation's Z nearly equals the look at rotation Z from them to their destination, successfully finish that execute so that the moveto will be played next in the sequence.

#

Alternatively, you could also make some logic in the character itself. Set it's movement speed to near zero or something until it's facing it's desired movement direction. But that's going to take a lot more resources than a simple BT sequence.

vagrant skiff
#

Anybody have an issue of identical AI placed in a level and some refuse to move? AIMoveTo function returns failed and "blocked" is the enum output for the reason why, i've yet to identify why the ai end up having this happen but generally it does not happen when i initially place a new one into a level, after a few seconds my ai are going into a randomly moving around state to test this and the "older" ones constantly fail to move, if i continue to just do stuff in the level editor eventually the ones that are working properly will not work anymore once played, in editor or standalone (not tested after build yet), its very confusing

not my best example gif but;
https://gyazo.com/d7f363506732f96722e34d6d1c624e89

#

im just trying random stuff now to try and reproduce the issue but ive got no clue why some just "dont work" when they are literally identical alt dragged of eachother / drag dropped from content browser

#

google also hasnt really yielded any helpful results

pine steeple
#

that looks like your using detour (crowd avoidance)

#

the way they are twitching whilst moving

vagrant skiff
#

ive tried it with and without enabled

#

in character movement component correct?

pine steeple
#

thats RVO

vagrant skiff
#

oh

pine steeple
#

crowd avoidance is in the AI Controller

vagrant skiff
#

roger

pine steeple
#

but

#

i would recommend running the visual logger

#

and finding out what exactly is happening

#

run that, and let me know the results

vagrant skiff
#

yea ill dive in tonight for awhile

#

ty

pine steeple
#

i know UE4 ai system quite well (been working with it for over 2 years :D)

vagrant skiff
#

yea ive meddled with ue for a few years but this is my first time doing ai stuff

#

and your suggestion above has already fixed the problem

#

i swapped to the basic ai controller from the crowd avoidance one

#

but ill be looking at the visual logger aswell

pine steeple
#

yeah i knew it was crowd avoidance

#

by the way they jittered

vagrant skiff
#

yeah

#

its weird because i could drag one of them away alone

#

still was "blocked" permanantly

pine steeple
#

thing is, the crowd system really has nothing exposed to BP

#

and in default state, its terrible

vagrant skiff
#

i can imagine

#

good insight

#

i thought it would help with them running into eachother

#

xD

pine steeple
#

well

#

it does, but you need to tweak some stuff

vagrant skiff
#

yh

pine steeple
#

i use it, but after a lot of tweaking

#

and its still not perfect

#

just haven't got the time atm to make a better avoidance system

#

and RVO is a no go for us

vagrant skiff
#

planning on having very sparse groups of ai so i dont think ill need much of what it has to offer anyway

#

hopefully

pine steeple
#

i am going to try experimenting with RVO when they are off camera, and switching to Crowd Following when near players

#

might offer what i need lol

vagrant skiff
#

ye

#

ty for help and gl with that ;p

pine steeple
#

behaviour trees get fun tho 😄

#

thats just one part of a massive BT

#

8 subtrees on 1 BT

vagrant skiff
#

whats the endgoal of that ai?

#

err what is it for

pine steeple
#

oh i have around 30 different monsters

vagrant skiff
#

ah

pine steeple
#

all with different abilities

vagrant skiff
#

nice

pine steeple
#

some burrow underground

#

some jump into ceilings

#

jump through windows, etc

#

then they have ranged/melee attacks, etc

tidal void
#

Wow that BT is intense. Easy to follow for the most part though, you managed to keep it super clean despite the number of paths

silk spear
#

is there a way to set acceptance radius in a MoveTo node as a variable?

#

so i could set it depending on the weapon range

inland hatch
#

@vagrant skiff Could you have exceeded the maximum agents for crowd AI? You can change the value in your project settings here.

#

That would explain why some of them refused to navigate despite being away from the other agents.

fiery spoke
#

@midnight scroll Actually i was asking for some tutorial about this. Preferably video tutorial.

patent hornet
#

simplest way with turn in place then walk?

#

make a task, have it fetch desired rotation from the blackboard, interp current rotation to desired rotation on Tick and FinishExecute(success) when you're close enough to desired rotation to call it done

#

and put it in a sequence before the MoveTo

#

@fiery spoke

simple crest
#

You have to somehow calculate and store the full nav path, then move the character to each point individually, rotating towards the next point before continuing on

#

Not reeeally helpful but might help you plan your approach

verbal violet
#

@patent hornet FinishExecute finishing task? should call it in Tick or sowhere else?

#

I used FinishLatentTask but that is something about template tasks

patent hornet
#

if you dont' FinishExecute, BT gets stuck in that task forever

#

this use case, on tick you check if rotation is close enough, and if it is, FinishExecute

#

as the RInterp is done on TIck as well, it only makes sense

verbal violet
#

I do that on wrong way. when my rotation was close enough i called ExecuteTask AGAIN and return succes but when that didnt work i called FinishLatentTask on end ExecuteTask

#

🤦‍♂️

#

@patent hornet i can't find FinishExecute ?! that is bp method, i did it in c++. Is OnTaskFinished same thing?

simple crest
#

I bet you could ghetto hack turn in place by setting max walk speed to 0 or "very small" while the actor direction doesn't match the input direction... Lol

torpid juniper
#

Hi all. Is there a best practice for integrating behavior tree logic with animation blueprints?

E.g. in my current setup, I want to make an animal yell, and when the animation is finished, walk to a location. I have a bt task which sets the animation state to yell. Then the animation bp has a notify event at the end of the animation which updates a bool in the blackboard. The bool allows the behavior tree to progress further.

This works, but it feels bad. After the task tells the animal to yell, it just sits on a wait node until the task is aborted due to the bool changing. Feels gross to me.

#

Example: The task on the left tells the animal to yell, then wait for 10 seconds. When the animation is finished, the blackboard value is set to True, so the task on the left is aborted, and the tree moves the flow to the task on the right.

I dislike how this setup has a task which is doing everything its supposed to progressing to the next task because it gets aborted before succeeding....

fiery spoke
#

@patent hornet I have an AI which just walks around, turns, etc. And i need to synchronize this turning with animations.

misty wharf
#

@torpid juniper the way I've set up that sorta stuff in BT's is using an event on the pawn. The pawn has a func that triggers the anim, then the anim notify is triggered in the pawn, which then calls the event dispatcher. The BT task for running this action binds an event listener into the dispatcher and finishes executing only after the event fires

#

this way it won't advance to the next task until the action has been fully performed

torpid juniper
#

@misty wharf Hmmm.. oh, I think I get it. That's a big brain moment.

I've been thinking of tasks as single async functions. You're saying the calling of "Finish Execute" doesn't need to come from "Receive Execute", and you can instead make "Finish Execute" only accessible from custom bound events. Is that correct?

And the state of the behavioral tree will just sit on the task with nothing happening until that event is fired?

misty wharf
#

Correct

#

If you bind events in the task like this, make sure to also unbind them. Otherwise the results can be unpredictable

#

Eg. Receive Execute -> Bind Event Foo
Event Foo -> Unbind Event Foo -> Finish Execute
Receive Abort -> Unbind Event Foo -> Finish Abort

torpid juniper
#

Got it. Makes a ton of sense.

If that were not done, does a task have the ability to execute anything when it's not active on the behavior tree? E.g. if the tree were doing another task, and the event were triggered, could it run?

misty wharf
#

afaik it can but I've never actually tried if it would :D

torpid juniper
#

haha ok.

Thank you, this was immensely helpful.

misty wharf
#

👍

vagrant skiff
#

@inland hatch yea i have quite a bit more then 50 sitting around, after work today im going to look into it further

verbal violet
#

I have custom task for Jump, for small enemy who jumping on bigger and attach, in Tick i am checking is location of small enemy close enough to socket and when that happened i call OwnerComp.OnTaskFinished(this, EBTNodeResult::Succeeded);
Problem is when i have multiple small enemies who jumps, when first come on goal and call OnTaskFinished that finish my jump task on ALL small enemies ?
What i do wrong? Sorry i am pretty new in unreal and AI in general...

#

blue sphere is sign that task is finshed

torpid juniper
#

I would post the Jump Task implementation

verbal violet
#
if (SelfActor.IsValid())
{    
    SocketTransform = SkeletalMesh->GetSocketTransform(SelectedSocket);
    JumpEndPoint = SocketTransform.GetLocation();
    SelfActor->SetActorLocation(FMath::Lerp(JumpStartPoint, JumpEndPoint, JumpAlpha));
    JumpAlpha += DeltaSeconds / JumpDuration;
    Distance = FVector::Distance(SelfActor->GetActorLocation(), JumpEndPoint);
    if (Distance < 10.f)
    {
        
        UE_LOG(LogTemp, Log, TEXT("+++++++++++++++ JumpFinished [%f] "), Distance);
        //DrawDebugSphere(GetWorld(), SelfActor->GetActorLocation(), 12.f, 22, FColor::Yellow, false, 1.f);
        //JumpFinished = true;
        OwnerComp.OnTaskFinished(this, EBTNodeResult::Succeeded);
    }
}
#

it;s only part, I have some things bellow but it's about playing proper montage when jump reach some limit, i have JumpStart, JumpIdle and JumpLanding

verbal violet
#

anyone, please?

verbal violet
#

i found what is problem if anybody interested in. i had some fields in bttask for caching some values for example

TWeakObjectPtr<AActor> SelfActor;
FVector JumpStartPoint;
FVector JumpEndPoint;
FName SelectedSocket;

when each of them (modules, small enemies) get SelectedSocket in ExecuteTask
SelectedSocket = BlackBoardComp->GetValueAsName(SelectedSocketBlackboardKey);
and continue to do logic in Tick, there EVERYONE has value of last selected socket, SelectSocket was everytime overwritten and and always was used last value.
like some kind of shared variables ! ? ?

solution is (probably bad) to get that values from blackboard in each tick frame .... some of them, but JumpStartPoint is cached vector so i can't get it from bb, or i have to save that in bb.

Is this really works on this way or I something really fuckup with references or whatever ....??!

smoky summit
#

Does SetSmartLinkEnabled actually work for disabling smart links at runtime?

wraith anvil
buoyant geyser
#

@simple crest how do you handle assigning units to combat in your AI?

#

say you have 8 units, the enemy has 4, 2 on the north side of the map and 2 on the south

#

your units are clumped together on the northwest

#

suppose 4 of your units can eliminate 2 of the enemy's units

#

so the ideal solution is splitting them in two groups and sending one north the other south

#

how do you handle that?

simple crest
#

you're talking about if "I" was an AI trying to determine how to send off my 8 soldiers? I haven't actually gotten that far ahead in my AI dev... but, maybe a couple of thoughts from a very high level to ping-pong an idea or two

In my system every unit ultimately makes their own decisions but part of that decision making process can be influenced. for example each of my AI units maintains a list of known targets in a KnownEnemies set, but a squad leader might assign some specific target(s) to the unit which get stored in another set AssignedTargetEnemies. When the AI is performing decision making, it scores which enemy it wants to attack from KnownEnemies... but if that enemy happens to be in AssignedTargetEnemies it gives it a big score boost.

As for the "upper" side of that, I would assume some kind of cost based system... maybe one could create some clever use of influence maps somehow. if squad leader AI knows about a strong enemy force, it might build an influence map with hotspots at clumps of enemies or at strong enemies. the squad AI could plan to "cool off" the influence map by sending friendly units into the area to fight? if AI sends VirginPeon to [X,Y] it will cool off the influence map by a small amount, if AI sends ChadTrogdor to the same spot it cools it off a lot. repeat until either all friendly units are occupied or there aren't any hot enough grid points worth cooling down.

I'm really just making all this up off the top of my head, it might be all BS. there has to be some smart blog about this somewhere on the net...

#

@buoyant geyser

#

an RTS could easily get extremely complicated and I would not envy anyone trying to make an AI for one 😛

#

Influence map -> process it to pick attack points -> figure out which ones to focus on including how many the AI side can handle -> use something like bin sorting to assign units into teams and then send them off to their doom

buoyant geyser
#

@simple crest sorry got sidetracked by dinner - I guess what I'm struggling to figure out is how to prioritize what task gets which units

#

cost-based system for sure, it's relatively easy to calculate the fighting force or power of a squad

#

and it's not that difficult to cluster units into groups either

simple crest
#

so basically the massive topic which I conveniently summarized with the two words "bin sorting"

buoyant geyser
#

friends and foes alike

#

yeah exactly

#

bin sorting

#

might be a good keyword

#

attack task needs 8 units -> only gets 6 -> calculates if it's worth doing the attack w/ 6 -> no -> some other task gets the 8 units -> etc.

simple crest
#

gets extremely complicated if you "want" it to... is there a rock-paper-scissors element in there for example

#

yeah

buoyant geyser
#

for now all the units are the same

#

well and I have a mech but whatever

#

I'll look into bin sorting

simple crest
#

it's complicated because first you have to figure out which bins (tasks) you actually have, then you have to figure out a reasonable way to fill them

buoyant geyser
#

yeah exactly

simple crest
#

"Bin Packing" another useful keyword. once or twice I've used "first fit decreasing algorithm" - it's simple enough for a 5 yr old to figure out and implement and gives "OK" results.

imagine if the "groups" in this example were like your Unit Strengths (Mech might have a strength of 6 and other peon units have a strength of 1) and the "minibuses" were your Task Requirements (big enemy group has a cost of 10, and needs 2 mechs or 1 mech + 4 peons)

https://www.youtube.com/watch?v=kiMFyTWqLhc&t=4m40s

Powered by https://www.numerise.com/
This video is a tutorial on the Bin Packing Algorithms (First fit, first-fit decreasing, full-bin) for Decision 1 Math A-Level. Please make yourself revision notes while watching this and attempt my examples. Complete the suggested exerci...

▶ Play video
#

little different because you want to make sure you fill/overfill the bin

#

@buoyant geyser ¯_(ツ)_/¯

buoyant geyser
#

checkkking

#

hm he said "decision maths"

simple crest
#

google -> looks like A* and stuff like that lol

buoyant geyser
#

too many math words in too little time

#

google trying its best to dissuade

verbal violet
#

when i write custom task, extended from UBTTaskNode with ExecuteTask and TickTask, it's mean to all my characters which has this task in its BT execute same instance of task (script) ? For example if use some FVector as field in task script to cache start lerp position, and in tick use it to lerp from that 'start' to 'end', 'start' will always last written value, overwritten every time for each char

#

Is this really works on this way?

patent hornet
#

that depends

#

if you set the task to be instanced, no

#

if you didn't, then yes

verbal violet
#

@patent hornet where i can set it? this flag bCreateNodeInstance?

patent hornet
#

sounds right

verbal violet
#

thanks a lot @patent hornet

thorny jay
#

Hi all, I have a really frustrating problem when trying to debug my AI. If I have a PIE session running and I open up the behaviour tree, only a handful of the AI actually show up in the debug menu. For example, I might have 10 AI running, but only 3 will show up in the drop down list for me to view

#

Whenever my AI starts doing something weird and I need to see what they're actually doing, they never appear in that drop down list. It makes debugging so much more time consuming because I have to keep restarting the session and waiting for them to get stuck again

#

I'm on 4.24

odd tide
#

hello, How i can destroy async function object if it is not already executing in behavior tree

ripe whale
#

Has anybody managed to start a behaviour tree using AAIController::RunBehaviourTree in 4.25?

#

I have code that was working in 4.21 but I can't seem for the life of me to get it to work in 4.25

#

I searched online and it seems most people use blueprints to do this but I would really like to have as much as possible in cpp

misty wharf
#

Have you checked how the BP node for that works?

#

Perhaps it does something in the C++ side that might point you in the right direction

ripe whale
#

That's a good idea

#

I'm calling the same function that BP calls

#

So weird

misty wharf
#

Could be a race condition? Depending on when you're calling that

#

Not sure tbh, I've only ever ran BT's from BP's BeginPlay

ripe whale
#

yeah if I can't get it to work soon I'm going to switch back to doing it from BP BeginPlay

#

in cpp I am calling it inside of OnPossess

#

I guess I can try to move to BeginPlay

verbal violet
#

@thorny jay maybe to press apostrophe while looking in AI that doing something weird ? in that case BT automatically show controller/character you are facing and looking at

thorny jay
#

@verbal violet Ah interesting, I didn't know that

#

That will help, though it still doesn't explain why their behaviour tree instance isn't debuggable sometimes 😦 But thanks, it should prove useful anyway

misty wharf
#

^I've noticed this sometimes as well, haven't really figured out why it happens 🤔

glacial vale
#

Hello do you know If I have multiple AI running around

#

Can I set dynamic obstacle on them?

#

If I do, the AI auto conflicts the path of the Controlled Pawn..

#

and RVO avoidance is a bit weird

#

The sphere Collision with navmesh_Null conflicts with his own path

rapid ridge
#

This conditional loop is only executing the first node in the sequence, if I want all nodes in the sequence to execute what do I need to do?

pine steeple
#

@glacial vale you can't do that

#

@rapid ridge ofc it will, that is by design

#

it will only execute that one node and loop it, not the sequence

glacial vale
#

@glacial vale you can't do that
@pine steeple I’ve found a way of doing it

#

Hacky but working

pine steeple
#

always risky doing that, cause you can mess up its own path finding

glacial vale
#

I put spheres around the shape leaving a path forward ... and path finding works almost totally fine

frosty skiff
#

When my character is standing on a blocking volume, all ai in my game stops following my character, but when my character is standing on anything else, my ai will follow. Navmesh surrounds my whole level. Anyone know why?

honest whale
#

Looking for some debugging tips on pathfinding. Ive got an AI that isnt moving around the level because when I send Pathfinding requests it fails due to "Start point on NavMesh"....which fine, makes sense. But from the best I can tell looking at it in the Gameplay Debugger the AI is fully on the NavMesh and the NavMesh covers the whole space.......

celest python
pallid atlas
#

You're not using a behavior tree, @celest python ?

celest python
#

Yes

#

I will use "simple move to" later -- project shouldnt have any Behaviour Tree

#

I just move my pawns on AIController

atomic hill
north vapor
fierce zealot
#

@atomic hill could you show me the navmesh?

hexed spade
#

why can't I extend the nav mesh to completely cover the floor here? no matter if I scale, it doesn't seem to cover the edges

fierce zealot
#

since your agents need to be able to stand in front of your wall

#

so positions too close to the wall are invalid anyway and thus not part of the navmesh

hexed spade
#

@fierce zealot I see...what happens is that they seem to get stuck in the walls

simple crest
#

usually that's because you've made your agent radius too small (you've tried too hard to make the nav mesh extend to the walls, lol 😛 )

twin loom
#

How do I pause/stop the behaviour tree from running? In my AI_Controller, I've tried BrainComponent->PauseLogic("Dead"); This gives me an EXCEPTION_ACCESS_VIOLATION crash. Do I need to do anything special to set up a brain component?

midnight dune
#

I'm looking for a way to get my zombie AI to quit attacking after one player is dead and move on to the other players. Any suggestions?

misty wharf
#

That largely depends on how your zombie AI works to begin with

#

I'm assuming you have some kind of BB value or such controlling which player it's attacking - you could use for example a BT service to keep checking if the target is alive and if not switch it

midnight dune
#

Yes I’m using BT to move to the closet player, the part I having difficulty with is getting the variable from the player that died. I’m about to crash for the night. I’ll try to post some screenshots tomorrow.

rapid ridge
#

any resources on how to debug AI? My code seems to run fine with 1 AI but when there's multiple AI it seems to be bugged

simple crest
#

are you sharing a blackboard

midnight dune
dusk kelp
#

Hey, guys, cant understand how to generate NavMesh with WorldComposition

#

I just made a NavMesh in my level inside PersistentLevel. Works good if Im testing AI directly on level, but when Im trying to run a game from Persistent level its just not working

plush pasture
#

why would my ai get stuck like that?

twin loom
#

@plush pasture Maybe the wall isn't a navmesh obstacle?

#

So the AI doesn't detect it

plush pasture
#

navmesh isnt generated where the wall is

#

so its not the issue

#

i dont get it

#

@twin loom plz halp

#

anything else i could be missing?

#

releting recastnavmesh

#

omg bugs

lyric flint
#

How would you make a pawn path find to the player using add force instead of using movement from a character blueprint?

#

I know I could do this but I'm not using a the native movement system and its a sphere actor with physics... (I am using AddForce to replicate a bunch of my own physics)

rotund magnet
#

the on fail doesnt occur, it keeps trying to succeed and go to the player even when it cant

#

this is the on fail stuff

#

he just stands there

celest python
#

Whats wrong?

#

but it only return false in BT

pine steeple
#

you cast is wrong?

#

error message clearly states that

celest python
#

ok yeah

#

i should learn English again

#

😄

random jay
#

In a behavior tree I want a node to only activate once ever. Is there node to do this for me? (Or do I just set a boolean flag to "has activated")

#

(Relatively new to trees so this prolly is a dumb question)

misty wharf
#

I think you'd need to use a BB value and a decorator to check for that

#

There's some other ways to do it as well but that's probably the most straightforward way to do it

lyric flint
#

Hey Can I make my opponent car racing player

misty wharf
#

it's possible yes

charred ruin
#

Hey guys, using AIPerceptionComponent, how do you know if a specific sense STOPPED sensing something? Like with the sense sight, once the MaxAge is reached, how do you know the AI stopped seeing the player?

#

using that specific sense

wary ivy
#

there should be an event that is fired when something goes out of sight for example

#

though I'm not sure if that takes age into account 🤔

charred ruin
#

Yes the event is fired, but I can't find a way to know which sense triggered it

wary ivy
#

anyway, there's the OnTargetPerceptionUpdated event and if you break the AIStimulus struct it should have "succesfully sensed"

#

in the case of sight that is true when something comes into the sight range and false when something goes out of sight

charred ruin
#

For example, when something enters in sight, I use LastSensedStimuli[0].WasSuccessfullySensed to know if the sense in index 0 is sensed

#

but if I have 2 or more senses

#

LastSensedStimuli[0].WasSuccessfullySensed will return false if any of the 2 senses fail

wary ivy
#

yea I haven't really looked into it that much :\

#

you doing it in c++ btw?

charred ruin
#

yeah

wary ivy
#

looks like there's a non UPROPERTY FAISenseID Type; that might tell you which sensory even is which

#

in the FAIStimulus struct

#

it's a bit odd that some of those fields aren't exposed to blueprints 😄

charred ruin
#

I'll look into it, beats having to switch on an integer to know which sense is used

misty wharf
#

^I used tags for this when in BP's

#

Sight just works automatically usually and you can't give it a tag, but when using sounds for example you'd usually trigger it via calling the report noise event or whatever it was called, and you can give those a tag

#

so if tag == '' then it's sight, otherwise something else etc.

#

but using the SenseID or something in C++ is probably more robust

charred ruin
#

@misty wharf I think you can only add a tag for noise events

#

or did you do it with another sense?

misty wharf
#

just noises in my case but I'd assume any sense that you have to manually report for would support it

charred ruin
#

Just checked, only noise event asks for a tag

misty wharf
#

hm maybe it's just for that then

charred ruin
pine steeple
#

i will get this small AI utility plugin out

#

which will have a whole bunch of stuff to make the perception system easier to use

#

plus other AI stuff (some custom BT nodes and decorators0

charred ruin
#

That's awesome, any ETA?

pine steeple
#

towards the end of next week

charred ruin
#

looking forward to it

celest python
silk spear
#

How can I make AI avoid an obstacle? I ticked CanAffectNavigation on my spikes

#

but the AI still charges into them to it's death

lyric flint
#

How to make an opponent car racing

#

Can anyone help me

verbal violet
#

Anybody experienced in modular characters, Mesh Merging? Some recommendations, links, I've just started with official docs and there some compile errors
https://docs.unrealengine.com/en-US/Engine/Animation/WorkingwithModularCharacters/index.html

Take a look at the TArray declarations and notice the missing types in all of them. I can not compile my code without these TArray types and I can not figure out what types they are?

Describes the different methods you can use to create modular characters comprised of multiple Skeletal Meshes.

ripe whale
#

Can you download the version of the engine that the docs were written for and follow the tutorials like that? Maybe intelisense could help you find the types once you had compiling code as well?

pine steeple
#

@verbal violet please don't post in multiple channels, especially channels that are not relevant. #old-rules

ripe whale
#

Is there a way to get my nav mesh generation tighter so that it goes right up to the tree and the cube in the photo above? I want my character to be able to navigate right up to the bounds of these objects but the hole that they place in the nav mesh prevents that

pine steeple
#

adjust your capsule radius

#

it looks like it is fairly big

#

this is what out navmesh looks like

ripe whale
#

by capsule radius do you mean the collision bounds on the static meshes shown in my screen shot?

#

I was able to get a much better result by reducing the "Cell Size" in the RecastNavMesh instance

pine steeple
#

what was your cell size

#

here is our settings

#

maybe it will help you out

ripe whale
#

That does help me out thank you, my cell size was 40 before

#

I've put it at 20 now which is much better

ripe whale
#

I'm still having an issue getting my character to navigate to one of these actors, basically I am getting the actor location and then I put that into a a MoveTo BTTask and the EPathFollowingResult I get back is always just "Invalid"

#

I would have thought that the code would have been smart enough to project the location given onto the navmesh and then use that, or use a partial path or something to get as close as possible

#

How is this case usually handled? It seems like people would want to move their actors close to static meshes that have collision pretty often, how are you suppose to do this in a reliable way?

pine steeple
#

turn on partial path

ripe whale
#

It is on..

#

Do I just need to increase my "acceptable radius" enough so that it covers the gap in the nav mesh?

#

actually even that doesn't work I still get the Invalid PathFollowingResult

#

The only thing I can think of doing is adding an offset off of the actors location to put it ontop of the navmesh but that seems like a really shitty solution

pine steeple
#

does it move

#

if you choose a location on the navmesh

ripe whale
#

yeah my character does move to any other location

pine steeple
#

turn off Project goal location

#

cause if that fails, it will throw a invalid

ripe whale
#

ah ok let me try that

#

bingo that worked

#

Pretty silly that that one checkbox cost me like 3 hours

#

oh well

pine steeple
#

:/

#

been there many times in the past 3 years

#

with UE4 and one silly checkbox issues 😄

ripe whale
#

haha

misty wharf
#

the project goal location is weird

#

I thought it should help with cases where the target isn't on the navmesh because it projects the point to the navmesh

#

but it literally seems to do the opposite and stop it from working :P

#

I had the same problem at one point as well

#

I must be misunderstanding its purpose but never could really figure out what it was really for

ripe whale
#

Maybe it is for locations that are directly above or below the navmesh? Like maybe it only projects along z axis?

#

I guess I could look at the code and figure it out

#

I just did a simple test, moved the actor way above the nav mesh on the z axis and project goal location did nothing, still got invalid with it both on and off shrug

pine steeple
#

you can't have the goal be too far above the navmesh

#

nor the moving player

ripe whale
#

So what does "Project Goal Location" do? When would you want to use it?

ripe whale
#

So I found out some stuff, basically the "Project Goal Location" will take the "Default Query Extent" specified inside of the Navigation System Project Settings and use that volume to project the supplied point onto the navmesh

#

For example I was able to solve my "Invalid" path following result issue by making the "Default Query Extent" large enough to include a portion of the valid nav mesh

misty wharf
#

Interesting

#

I wonder why does it navigate mostly correctly with that turned off though 🤔

#

I guess it might be generating an incomplete path, and with that turned on, it's not generating anything at all if it can't project it correctly?

ripe whale
#

Yeah if it is turned on and the projection fails it doesn't do anything

#

If it is turned off and partial path is enabled then the projection doesn't happen at all so it can't fail from projection failing

misty wharf
#

that makes sense, good job looking into it :D

pine steeple
#

i coulda told you that

#

but i was afk lol

hexed spade
#

hi guys how do I increase the radius on a navmesh where the AI can't go?

#

I want to increase the area around the pole that the AI can't go to.

lyric flint
#

@hexed spade That's actually intentional to prevent characters from clipping into obstacles

rapid ridge
#

If I have a bunch of AI following me, and when they reach me, the ones behind still try to move to me, how could I stop this movement if they are as close as they can get

#

anyone dealt with this?

lyric flint
#

@rapid ridge are you using the detour crowd ai controller?

rapid ridge
#

nope

#

can't seem to be able to make a new c++ class based on Detour Crowd

misty wharf
#

@hexed spade you can add a collider into the pole actor to act as an additional hitbox, or you can add a nav modifier volume

hexed spade
#

I can make the AI chase the player but how do I make it run away from the player?

#

like if the AI has posession of the ball how can I make it intelligently avoid, run away from the player while moving towards the goal?

bitter veldt
#

what have you tried? that's not straight forward to answer in a few discord messages

pine steeple
#

EQS

opal crest
#

If you are using environmental queries, create a grid of candidate points, choose one that is far from the player (and toward the goal) and navigate toward it.

pine steeple
#

or get the dot product of the normalized vector of Enemy and Player, and choose a position that is not in that direction

#

EQS is probably the best though.

hexed spade
#

hmmm I like that dot product approach as well

rich marsh
#

One thing I am confused about, with the C++ UBTDecorator class, is that methods such as OnNodeActivation(), OnNodeProcessed(), etc., mention that they should not modify the object's state

#

I wanted to have a shared parent class that some of my decorators inherited from to set some common properties - based off of the documentation, am I not allowed to do that?

#

For example, several decorators need to have a weak object reference to the specific AI character pawn class that I created. Instead of setting that every single time the condition is checked, I was hoping to have that value populated when the decorator gets created

pine steeple
#

use setpawn node

#

and make it createinstance

ebon zodiac
#

Are BehaviorTreeComponent and BlackboardComponent intended to belong to a Pawn or an AIController?
Updated:
(it's AIController)

{
    Super::OnRegister();

    AIOwner = Cast<AAIController>(GetOwner());
}```
rapid ridge
#

Is there something wrong with my BT? node #3 is interrupted before it finishes the movement completely

misty wharf
#

MoveTo SelfActor?

#

Isn't SelfActor usually a ref to the actor whose BT this is?

#

oh nvm I think I was looking at the wrong node because I got confused about the nodes being selected

#

:D

#

The MoveTo shouldn't finish before it has reached the destination, if it finishes before that then it seems the path it would've found was incomplete

rapid ridge
#

it stops in the middle of the movement, is there a way to debug it?

hexed spade
#

okay when I set FindPlayer EQS query to the AI character "CH_AltPlayer" it now works....but why won't it work on the player (CH_Practice)?

hexed spade
#

the problem is I have a PlayerStart actor that loads the player (CH_Practice) .

#

so when I set the FindPlayer EQS query to CH_Practice it won't show the debug sphere

#

even when I drag the CH_Practice actor onto the map, it still won't show the debug sphere ... what could be causing this

#

I mean it traces it fine in the editor....but not when debugging in real time

hexed spade
#

wtf now it works...i changed radius to small figure, ran into it, and then changed it back.....what did I do differently lol...or is this just it bugging out?

#

this is so bizarre

#

when I add a cube run and then remove the cube, the debug is gone

#

then I have to reduce the search radius to a low number run it again, the debug sphere is still gone

#

and then i stop. increase the search radius of the EQS query to a large number like before and then run it, the debug sphere is back.

#

wtf now it doesn't happen when i run through above (adding cube deleting and then starting again)

#

this is a complete mystery lol

#

bug?

storm zephyr
#

hello is there a way to say that a particular AI instance uses a certain navigation query filter? i'm asking this because i want to reuse the same behavior tree but have some instances that use the filter and others dont

#

if that is not possible then i need to make my own move to task that takes in a blackboard filter query and set it there

twin loom
#

OnTargetPerceptionUpdated, I'm trying to set a blackboard value to an object. The problem is that it isn't getting set. this is how I'm setting the value GetBlackboardComponent()->SetValueAsObject("TargetObject", Actor); Actor is the actor that was sensed

#

Setting the object works from a BTTask tho. I'm not sure why it isn't working OnTargetPerceptionUpdated The only thing I can think of is that in the BTTask, I have a blackboard key selector. But there aren't any blackboard key selector's in AIController so I'm not sure what to do

storm zephyr
#

fyi AAIController has a DefaultNavigationFilterClass variable that can be used for this exact purpose

twin loom
#

I'm having some trouble with the behaviour tree. I want to do something if the enum is set to Passive or Neutral. That's waht the node on the left checks. If that's false, I check if it's aggressive. The problem is that when the first check fails, it doesn't seem to check if aggressive. If I put the aggressive check first, it works for aggressive creatures but not for passive/neutral. How do I fix this?

pine steeple
#

you are using sequences

#

your top one should be a selector

#

i suggest learning the different types of composite nodes

twin loom
#

ok, I'm new to AI so I'm just using tasks and sequences for now

pine steeple
#

well then struggle ahead

#

or actually read up and learn about them 🙂

#

you can't just use Sequence everywhere.

#

your top sequence is going to exit out as soon as the decorator for Is neutral or passive returns false

#

meaning your Aggressive will never execute.

twin loom
#

ok, I'll read up on the different nodes

pine steeple
#

selector will continue till something succeeds

#

so change your top node to selector

#

and it will work.

twin loom
#

yeah, it worked

#

Thanks

pine steeple
#

highly suggest learning the difference tho

#

cause it will be beneficial

twin loom
#

ok

pine steeple
#

in a nutshell, sequence will execute left to right, till something returns false or there is no more tasks

#

selector will run a node and keep going left to right till somethiing succeeds

hexed spade
#

hi guys I see this on top of the EQS docs "You can try out this Experimental feature, but we do not recommend shipping projects with it." how serious is this warning will it break stuff randomly?

#

or has anybody shipped stuff fine with EQS?

pseudo grotto
#

Hey how to add combat mode

floral mango
#

@hexed spade it's pretty solid at this stage, I wouldn't worry too much about the experimental tag

pine steeple
#

well if Fortnite use EQS for nearly everything in the world... To me that means its pretty solid 😄

buoyant geyser
#

@simple crest did you know that Dave Mark is on the gamedev.net discord btw

pine steeple
#

whois Dave Mark?

simple crest
#

Did not know there was a discord!

#

One of the prominent "inventors" of utility ai

thorny jay
#

Hi everyone, I'm having a really infuriating crash in my AI blueprints. From the stack trace it seems to be a crash in an AI service, but I can't see what function actually causes the crash. The stack trace has two "unknown function" calls right at the end

#

The service is in blueprint, but it does call some functions I've defined in C++

#

So I assume the service is trying to run some code I wrote in C++ that crashes, but I can't figure out what

#

I can't even see which service it is that crashes, it just has UBTService_BlueprintBase::ReceiveTickAI() in the stack trace so I assume it must be one of my AI services

#

Does anyone know how I can debug this a little better? The crash is really intermittent, sometimes it happens after a few seconds of starting the game, sometimes it's after 10-15 minutes

patent hornet
#

what build @thorny jay ?

thorny jay
#

4.24

#

@patent hornet

patent hornet
#

i mean packaged/PIE/Standalone, what binaries?

thorny jay
#

Ah sorry, it's in PIE, running standalone

#

Windows build

#

I haven't tried running it with a dedicated server, but this is meant to be an offline mode so it wouldn't make much sense to do so

patent hornet
#

c++ ?

thorny jay
#

Yes, mostly C++ but the AI is mostly done in blueprint. All of my AI Services are in Blueprint, but they call C++ code that I've written

patent hornet
#

build DebugGameEditor

#

run the editor from your IDE

thorny jay
#

Ok

patent hornet
#

and just work normally until it crashes

#

when it does though, IDE will hit a breakpoint

#

and you'll be better informed after

thorny jay
#

Fantastic, thank you. I'll give it a try

patent hornet
#

as you'll be able to see which service, which AI... etc

thorny jay
#

Nice

patent hornet
#

in your Locals/Autos

#

also, if you don't have editor symbols for debugging

#

its time to install those now

thorny jay
#

Hmm, running it from the editor using the debugger gives me an error

#

Cannot find Engine\Intermediate\Build\Unused\UE4.exe

#

Does it have to be a source build?

patent hornet
#

no

#

right click on your game project in solution explorer

#

set as startup project

thorny jay
#

Ah there we go 🙂

#

@patent hornet Fantastic, it actually helped me fix a separate problem, now I just need to wait for my AI crash to occur. Thank you so much for walking me through that process

patent hornet
#

@thorny jay thats my default working mode

#

i always do a round of tests on the code making sure breakpoints hit when theya re supposed to

thorny jay
#

@patent hornet I'll be sure to use this in future. One of the downsides to being a self-taught programmer is you often miss some of the basics

patent hornet
#

@thorny jay one thing worth noting: editor started via .uproject file uses DevelopmentEditor, so if you re-compile DebugGameEditor then start the editor by doubleclicking .uproject, your changes won't be there

thorny jay
#

@patent hornet thats good to know, thats the kind of "gotcha" that would drive me crazy xD

thorny jay
#

@patent hornet Just to let you know that thanks to your help, I found the issue, and it was a doozy. My AI operates in squads, and sometimes it will issue individual orders to squad members. When a player joins the server, a bot will be removed to maintain team balance, and I was forgetting to remove the destroyed AI Controller from the squad array, so if it just so happened to try and issue an order to that squad member, it would find garbage data instead. Would never have figured that out without the debugger 🙂

deft siren
#

Hi. Please help a poor noob, is there a way for a pawn to detect if another pawn is blocking his path? I use detour crowd manager, with or without RVO but my pawns are still clumping toghether if it happens to have the same goal.
I would like to have some way to check if a pawn's path is blocked by another pawn to change its goal.

fallow hound
#

I don't think easily. Not saying it is impossible but it isn't a built-in feature.

#

Prob not a noob kind of problem to tackle tbh

hexed spade
#

thats a major relief that Fornite uses EQS lool

#

will ignore the experimental warning

fallow hound
#

yeah its been experimental for a long time

twin loom
#

not sure if this should go in this or #legacy-physics but basically, I've got a 4-legged character that is controlled by ai. The collisions work perfectly except when I have the ai go to the player location when attacking. The player is meshed into the creature. Is there any way I can force the creature to stop going inside the player? The yellow capsule is the capsule component found inside the creature.

thorny jay
#

@twin loom one idea is to create a new "creature" collision channel and make the creatures capsule component use it, then add a capsule to the player which blocks only that channel

#

It won't interfere with player movement but will block the creature

twin loom
#

The collision works just fine except when the creature ai controller is moving the creature to the player location

#

The yellow capsule is what's being consided the creature's position

#

And the creature's trying to reach the player causing the player to ignore the normal creature colliders that are shown in green

#

@thorny jay

thorny jay
#

@twin loom Unfortunately, the character movement component in UE4 only takes that capsule component into consideration when moving

twin loom
#

I just changed the capsule component on the creature too be giant so the glitching isn't happening but theres some clear problems with this

thorny jay
#

So one option is to place the player and creature's capsules on separate channels, have all the capsule components for the creature block the player's channel, and add a big capsule to the player to block the creature so it can't get close enough

#

Or you will need to write a custom movement component

twin loom
#

I think I'll go with the first option

rapid ridge
#

I'm using AAIController::MoveToLocation/MoveToActor but the acceptance radius is wrong, the AI stops before the acceptance radius is met, not right at the radius

#

is there something I can do?

twin loom
#

@thorny jay Would I create a new channel for the player and a new channel for the creature?

thorny jay
#

@twin loom Hey there. Yes, you would create a new channel for both

hexed spade
#

With EQS I have been able to make the AI run away from the player. How do I make it favor grid locations that is close to a fixed location (ex. goal)?

#

My thinking is adding another distance test to the goal from the AI player should modify the grid on top of running away from the player

misty wharf
#

yeah if you add a distance test comparing to goal and scoring points that are closer to goal higher, it will add that score into the total score for each item

#

and as a result it should start favoring ones closer to the goal since their total is higher

hexed spade
#

@misty wharf hmmm seems like it is still giving a higher score to where the player is

#

the distance to test set to goal works but something is wrong with my scoring here....it is giving highest score to where the player is when it shouldn't

#

im gonna try fiddling with the goal distance to see if it changes things...

#

yes it works as it should but now the AI seems to prefer to be right under the net

#

I thought about putting an invisible cylinder around the goal post but then it wont pick up the ball again if it just lands inside the cylinder

#

(side note: EQS is powerful stuff!)

#

this is what I mean. it'd be nice if I could add another distance test to the area behind the backboard....AI guy thinks he MJ 😂

uneven shell
#

hey guys, I have a question. I would like to position enemies on radius around the player, when they approach him, so each of them has clear line for shooting and won't fire at each other. Any smart ways to achieve it?

uneven shell
#

thx

whole steppe
#

can't you use EQS to find the closest spot to the player

#

rofl he left the server

rapid ridge
#

wouldn't that have the same result as a regular MoveToActor? I don't know if it would be any different

charred ruin
#

Any one have any idea why navmesh characters get stuck here?

#

they get stuck on all stairs in my game, I tried disabled the stairs from affecting navmeshes and using blocking volumes but they still get stuck in the stairs

pine steeple
#

your collider seems to be creating a hump

#

from what i can see

charred ruin
#

fixed the bump still the same problem

#

they get stuck at the bottom of this one

pine steeple
#

probably to big a capsule

#

(ai has a capsule too big that the one the navmesh has set)

charred ruin
#

nope, tried making it smaller and they still get stuck at the same spots

misty wharf
#

yeah I wish there was some easier way to debug navigation

#

I just created a new character in my game and it completely refuses to move even though it's essentially identical to my previous npc's :P

#

with BT's the navigation system just doesn't tell you anything, it just silently fails

#

I should have tried the visual logger before complaining about this...

#

turns out it actually does tell you what's up :P

hexed spade
#

how can I see the EQS grid while playing the game? I press apostrophe and toggle between numpad but I only see nav mesh being generated in real time .... I need to see what the new EQS grid values are that depends on a location that changes

#

like I need it to respect a certain radius around the hoop

#

I guess I could measure the distance between the hoop and the player and if it falls underneath the threshold have it move back outside and shoot the ball

#

in the behavior tree is it possible to collapse a branch? its getting quite large

floral mango
#

if you have the gameplay debugger open and select the pawn, you'll see the EQS results

#

or you can use the EQS testing pawn

hexed spade
#

yes! ty

slow bobcat
#

hello! long time no see!
We want to have areas where short enemies can go through and tall enemies can't (they will go around).
The "problem" is that we use NavWalking (which makes AI to not collide against World Static / World Dynamic) + crowd manager

Reading about how to handle this I saw that some people use NavArea_LowHeight. I can see it in my level (in editor) but I have no clue how to use this. When using it, AI that can fit under, just goes around.

So here are my 2 questions

  • Does anyone use this or knows about documentation that explains how to use it? I can't find anything anywhere except mentions to it
  • Does anyone know if crowdManager actually supports this?

Just so we are on the same page, having an AI that fits under the grey block, I would expect it to pick the pink arrow path, but it picks the red path.

Any clues will be appreciated!
Thanks!

opal crest
#

I haven't dealt with this specific problem, but have you set up your Agent for the shorter AI to be able to crouch? I think that's what the nav system uses to allow an agent to cross a Low_Height area.

#

Really just a wild guess on my part.

wild plover
#

Hello. i have a simple AI (it is waving at the player when it see it). how can i make it call functions on his own actor, ? should i create a new Bttask for each function ? or there is a way to do it other way ?

slow bobcat
#

@opal crest yeah, they are able to couch, couch capsule height is smaller that the gap under the grey block and I confirmed (printing on tick for debug) that is crouched

graceful saffron
#

I've got a voxel block world, but AI just won't walk up the blocks. They're stuck on whatever level they spawn on. No matter what I set the Recastnav settings to, they simply won't walk up. I think it's because the block is a 90 degree world like minecraft and nav only works up to 89 degrees? Not sure what to do

#

AI moves fine in the green, but will never move up a floor or walk down. They just get stuck :/

pine steeple
#

you need to set the step height

opal crest
#

@slow bobcat I took a moment and prototyped a way to do this, because I don't think you need LowHeight volumes to accomplish this. I set my AI Pawns to use the AIDetour controller. I created a short pawn with a capsule 96 high, and a tall pawn with a capsule 192 high. In Navigation System I set up two agents (Short and Tall) whose height matched the pawn capsule height. I made sure my nav volume was high enough to cover the areas they needed to get under. (The top down sample starts with a low navmeshvolume, so this was a brief gotcha). Once I got everything set up, short agents go under arches, tall agents walk around.

#

Once this is set up, you can use the RecastNavMesh-Short and RecastNavMesh-Tall to toggle the visibility of the two navmeshes independantly. to verify that there's no walkable mesh for tall underneath the low areas, and that there is a mesh in those low places for low agents.

#

Having collision disabled for your moving pawns should make this easier, rather than harder (since then they won't get stuck on geometry that disagrees with your what your navmesh tells your AI it can do).

slow bobcat
#

Ooh thanks. The only thing that doesn't add up here is that you are using 2 agents and Detour crowd control doesn't support it. If you look into the header file of the crowd control, you will find this (image), but I will try what you did anyway. Will be back with results. Thanks!

opal crest
#

Oh, yikes. I read about that, but it seemed to work anyway on 4.25

#

Maybe my setup was too simple to trigger the issue?

slow bobcat
#

In the movement component of your AI, is it set up to use NavWalk? If you play and look into the physics config of the root component at runtime, is it set to Override world dynamic and world static?

opal crest
#

It's not. I managed to add a little more complexity to my setup and you're absolutely right. Detour breaks as soon as there are multiple agents.

#

Maybe you could use NavLinks, conditionally enabled for the shorter agents, but that seems like a lot of trouble.

#

Or a custom nav modifier volume that is ignored by short agents?

#

I'm going to see if that second makes sense.

opal crest
#

Yeah. NavQueryFilter's are the trick.

#

These are both subclasses of NavQueryFilter. NavArea_short is a subclass of NavArea (no implementation at all)

#

Should work just as well with the LowHeight areas, but I wanted to try custom volumes since it looked like something I could use for a different project.

hexed spade
#

hi guys my character refuses to run into the wall on the left (checkered) is there a way to make this possible? adjust the grid?

robust kelp
#

Hi Guys, is somewhere a Tutorial or BP for the Combatreaction/System like Hellsplit or Blade and Sorcery?

lyric flint
#

hi, how can i move AI and make it jump in order to reach the clouds?

misty wharf
#

you can probably use a nav link proxy, with a smart link you should be able to trigger actions like jumps

glossy flame
#

is there a way to make the "Move To" node brake slowly when reaching the end and not just abruptly stop? (please ping me with answers)

pine steeple
#

set the braking

#

in the CMC

#

also i know in BT the moveto nodes have a braking thing

glossy flame
#

@pine steeple thats the move to node, none of those influence braking in any way

#

and i already tried setting the braking friction in the charactermovement but they get completely ignored for some reason

pine steeple
#

there is something somewhere for the braking

#

i haven't got UE4 open atm, but i am 100 percent sure there is something for braking

dawn crystal
#

Hello everyone! I have a problem strictly connected with Spline Line and NPC behavior. Before that I have created a patrol path and if my npc saw me, he immediately changed himself position (in the area of navmesh) to mine position (player position). As following, I wanna to create a Splite Line (done) but if my NPC sees me, he is following splite line still. He cannot go out from given splite line. My question is following: "How to force NPC's to follow me (FindPlayerPosition and then Go to this location)

low path
#

Hi! I am attempting to make a chase and roam AI for my game.
I follow a tutorial but it just doesn’t work. This is my first time using AI and was wondering if anyone could redirect me to a better tutorial or give me any material to help. Thanks!

tranquil reef
#

@low path

low path
#

No, will watch that. Thanks

tranquil reef
#

@low path
...additionally I'd recommend reading a book regarding behavior trees because (me personally) find it very hard to understand such a complex topic when just watching stuff and replicating it. You could try "Blueprints Visual Scripting for Unreal Engine - Second Edition". I heard just positve stuff about it (I think because of Marcos Romero who seems to be a great teacher regarding blueprints etc.).
I just finished "Hands-On Artificial Intelligence with Unreal Engine". Its a good introduction to behavior trees but you should know blueprints (or C++) at least a little.
Hope that helps 😉

low path
#

Could you link me?

pine steeple
#

BT's are easy once you understand the basics

#

the flows are also easy once you get that core knowledge down

#

i can do complex BT's and understand the flow quite easily

south lynx
#

hey guys, I have a question. I would like to position enemies on radius around the player, when they approach him, so each of them has clear line for shooting and won't fire at each other. Any smart ways to achieve it?
@carrpenoctem#5419 Hey, did you get a solution for this? I have the same problem but my enemies don't shoot, they punch. I will try an enemy manager at gameinstance level that tells enemies if they can attack or position, etc. Still haven't all the rules figured out.

slow bobcat
#

@opal crest
Hey! sorry for the late reply.
Yep, that's exactly what I need. Never looked into NavFilters before. Now I only have a problem: we use the async task AIMoveTo in BT's and it doesn't allow you to pass filters because... reasons (image). But that's fine, I can make a child and override that exposing the filter. Will see if that works.
Thanks a lot! will be back with results

#

Actually, I can override the default when the enemy is possessed. Easier to do

slow bobcat
#

Ok, I did this but enemies can still get into these areas.

Unfortunately I can't show any recordings due to NDA, but I will try to explain the problem with images.

what works:

  • Enemy spawns on the orange cross
  • Player is on the blue cross
    In this case, the enemy will go all the way around the pink area to engage the player

What doesn't work:
If the player crouches and stands where the red square is (imagine that's the crouching capsule) the enemy will get there and then it will get stuck, because it doesn't know how to move in the pink area.
I don't know why it's not considered an unreachable area.

We can see many problems if an enemy is pushed/dragged into those places.
One would say "well, the grey block would block the enemy through physx", but it will not, since it's a static mesh and we use NavWalking.

vagrant crescent
#

Hello hello! I'm not sure if this is common question, how do we put better optimization for our AI's? especially semi open world games with 50 or more AI actor inside? anyone can give some tips for that? Thank you!

patent hornet
#

profile, find out whats costing more then it should, fix it, repeat

vagrant crescent
#

Ok ok, Ty!

pine steeple
#

if ai are out of sight, and don't need to do anything till they are in range, simply disable stuff

#

one optimization i am looking into is, monsters that are far from any player, disables most of its stuff till its in range

#

out of sight, out of mind

tranquil reef
#

is there a fast way to be invisible to AI? I have a pawn with an AI-Controller that uses AI-Perception Component and I tried to deactivate the AI-Stimuli Component in the player character but it doesn't seem to work

pine steeple
#

deactivate does nothing

#

you need to unregister

tranquil reef
#

@pine steeple
That did it! Thank you very much :)
I always wondered what "deactivate" does since I had always issues with that

tranquil reef
#

@pine steeple
btw you said that BT's are very easy to you. Do you have any tutorial recommendations?

opal crest
#

@slow bobcat Glad you were able to make some progress. I see the remaining problem, but I'm not sure how to fix it. You could try modifying the Filter for the tall characters to not be excluded but instead insanely costly (the approach taken by Obstacles). This would allow it to move in the area, but only if it absolutely had to. That will have obvious drawbacks, though, since you could no longer create unreachable spaces. A few ideas: look at the behaviour that allowed the enemy into the space in the first place. You might also add a test in your BT to trigger a escape from out of bounds behaviour that uses MoveDirectlyTo or overrides the filter?

pine steeple
#

@tranquil reef honestly, no, i just learnt by using

#

Services are things that update Blackboard values/specific logic for the AI that must run whilst tasks are running

#

Tasks are what the AI should be doing

#

Decorators are like should we enter here or not, and if we are in here, shall we leave here if X condition happens

#

Selectors execute till something returns success

#

Sequences execute till something returns fail

#

Both composites will return when all nodes are exhausted

tranquil reef
#

@pine steeple
Alright thank you :)
I'll keep on doing then!

twin loom
#

I've got an AI that chases the player when it sees it. How would I rotate the head bone to look towards the player while the rest of the skeleton continues it's chase animation?

pine steeple
#

aim rotation

#

counter rotate the root bone

#

wait that TIP

#

just use AimOffset

#

and have the focus actor in the animbp

#

and rotate the head to the focus

#

would be done in AnimBP

twin loom
dry yacht
#

Hello guys wanted to ask questions, Nav Mesh Bounds Volume is by letting the AI to move where we wanted it to be but seems like my AI won't move after trigger box collide with my characterBP

haughty coral
#

How do you guys usually save behavior tree state in-game? Saving blackboard values may not be enough because there is also state which includes being at specific node of sequence.

misty wharf
#

I saved BB values and set up my tree with decorators and such so that it would go mostly into the expected state if it was loaded

#

Eg. if there was a sequence that was being done, after which the BB would be in a specific state, I would gate the sequence with a decorator that checks BB values

#

so this way it would just skip straight over it

lyric flint
#

Hi guys, for my game I want my AI's to have text floating above their head. This shouldn't be that hard I think - does anyone have a tutorial that might cover some of that area ?

#

Like the text in runescape

haughty coral
#

@misty wharf That makes sense for small trees but for bigger ones you would need decorators on every node to reach desired state and even after that you would need to save state of tasks like Wait

misty wharf
#

You could group your nodes using sequences so you wouldn't need to have the decorators on everything

#

But yeah it's not perfect.. not really sure if there's any other solution, it doesn't seem like you can really save the state of BT execution

fallen verge
#

@lyric flint Try parenting a Text Render Actor to your AI's and create a function that passes in a string to modify the Text Render. Could also use delays or Timelines to create the typewriter effect.

meager bobcat
#

is there a way to do a different player state class for AI controllers?

#

ive got a stealth game and i want to have like a Detection Meter that's replicated to all other players

#

and all my AIs use a player state and that seems like the place to put it

#

but I don't want it to be in the same class as the player stuff

misty wharf
#

You could probably store it in the AI controller too. Not sure if there's a way to have a different kind of player state for them

meager bobcat
#

AI controller doesn't replicate though, does it?

misty wharf
#

hm you might be right

meager bobcat
#

so it seems like I can do a different class for AIs in the AController::InitPlayerState function

#

yeet

lunar bone
#

Hey guys. I'm using a task in a behavior tree to make an enemy ai to do a simple attack. The task is basically just calling an Attack Function in the Enemy BP.
Any ideas how to let the task know that the attack is finished? The time it takes to attack can vary depending on what type of enemy is getting the task. I tried using an Event Dispatcher, but doesn't feel like a good solution to bind the event every time the task is being executed.

misty wharf
#

What you're describing with the dispatcher is how I've done it

#

I have a number of different actions that can be triggered via BT tasks, and they produce an event on the pawn which the task listens to... it seems to work just fine :)

#

The only thing to keep in mind is that you need to unbind the event after it has fired, and also unbind it from the abort event, otherwise weird stuff could happen

lunar bone
#

Oh, that might explain why I got some weird results. I'm not unbinding the events atm. Thanks @misty wharf , I'll try that right away 🙂

hard crag
#

Guys. I've asked to make a wolf pack AI prototype recently. I need some hint to be start with. The wolves must be able to circle around the player as in a pack.

graceful saffron
#

How do you guys make AI not freeze up/stop logic when the player jumps onto objects and such? Ive noticed in a lot of UE4 games you can bug out the AI by jumping onto objects. AI doesnt know what to do lol, cant reach the player so it stops

pine steeple
#

its not that easy

#

you need to keep track of there last known location

#

and move to it

#

before they got of navmesh

tranquil reef
#

@graceful saffron
I remember that there is a node called "is jumping" or "is falling" for pawn I believe. Maybe you can use these also for your logic

lyric flint
#

@fallen verge Thank you, I got it working after a bit of reasearching 🙂 funny how you need to know the name of one little thing sometimes

atomic crescent
#

How do you get a reference to a Player Character from within an EQS Generator?

class UBTT_GenerateCoverPoints : public UEnvQueryGenerator_BlueprintBase

This bit here turns up all nulls.

void UBTT_GenerateCoverPoints::GenerateItems(FEnvQueryInstance& QueryInstance) const
{
    GEngine->AddOnScreenDebugMessage(-1, 5.0, FColor::Green, FString::Printf(TEXT("this->GetWorld() = %p"), this->GetWorld()));
    GEngine->AddOnScreenDebugMessage(-1, 5.0, FColor::Green, FString::Printf(TEXT("GEngine->GetWorld() = %p"), GEngine->GetWorld()));
    GEngine->AddOnScreenDebugMessage(-1, 5.0, FColor::Green, FString::Printf(
        TEXT("GEngine->GetWorldContexts()[0].World() = %p"), 
        GEngine->GetWorldContexts()[0].World()));

    ACharacter* PlayerCharacter = UGameplayStatics::GetPlayerCharacter(
        /* WorldContextObject */ WorldContext,
        /* PlayerIndex */ 0
    );

    GEngine->AddOnScreenDebugMessage(-1, 3.0, FColor::Blue, FString::Printf(TEXT("PlayerCharacter = %p"), PlayerCharacter));
}
patent hornet
#

usually by casting the querier

pine steeple
#

why did you name it BTT?

#

oh your making a custom EQS task

exotic current
#

hey guys, I cannot get my AI pawn to rotate with control rotation. Add Control Yaw/Pitch Input does nothing, neither does the rotation settings in CharacterMovementComponent

#

I've tried executing these functions using timelines, tick, and just one-offs, and nothing works. I'm not sure what I'm doing wrong as I'm pretty sure I've done it before?

#

Add Movement Input works, Controller Input doesn't

pine steeple
#

disable all of them

#

in the CMC, tick control rotation and disable Orient to rotation

whole fern
#

Maybe a dumb question but can you use anything similar to Simple Move to Location but without AI Controller?

patent hornet
#

you can

#

don't expect too much from it though

whole fern
#

how?

#

I don't want to just interp from point a to b. I want to make use of Nav mesh to avoid obstacles but without AI Controller.

pine steeple
#

do a pathfind query

#

grab the points

#

and interpolate to every point

#

easy mode

whole fern
#

do a pathfind query
@pine steeple Thank you. May I know how to use this in C++?

pine steeple
#
    UNavigationSystemV1* NavSys = Cast<UNavigationSystemV1>(GetWorld()->GetNavigationSystem());
    ANavigationData* NavData = NavSys->GetDefaultNavDataInstance(FNavigationSystem::DontCreate);
        FPathFindingQuery Query;
    Query.NavData = NavData;
    Query.StartLocation = StartLoc;
    Query.EndLocation = EndLoc;
    Query.SetAllowPartialPaths(false);
    const FPathFindingResult PathResult = NavSys->FindPathSync(Query, EPathFindingMode::Regular);

    TArray<FNavPathPoint> Points = PathResult.Path->GetPathPoints();
    for (const FNavPathPoint& Point : Points)
    {
        //Do whatever
        Point.Location;
    }```
#

@whole fern

whole fern
#

Thank you so much @pine steeple! I will make use of this function. I can finally remove AIController class 🙂

pine steeple
#

why you getting rid of AIController

#

it doesn't really cost much tbh

whole fern
#

For my RTS game each civilization can have upto 200 units so I don't want to have 200 pawns + 200 AIControllers

pine steeple
#

i have 130-140 monsters

#

all with AI Controllers and Behaviour trees 😄