Proper way to implement Throwing/Catching/Blocking AI.

I’m working to what is, basically, a frisbee, game where there are two opponents standing on platforms throwing discs at each other.

There can be more discs at once flying around and the platforms may lack tiles here and there.

Right now I’m focusing on the Catching/Blocking mechanics but I’m not sure if I’m tackling the problem properly.

The discs are perceived and stored into an array in the character then in the BT there’s a sequence containing a MOVE TO Task and two Services: the first one filters only the discs flying towards the character, stores them in an array, checks for each one the distance to the character and then sets the nearest one as a blackboard value.
The second Service gets the destination of the pawn by intersecting the direction vector of the disc with the location of the pawn and assigns the location to the blackboard variable for the MOVE TO Task.

It works. But I’m in the need of a more refined behavior: I need not only to filter the incoming discs and find the nearest but, if they are bouncing elsewhere, how long every and each one of them is going to take to make it to the character, then based on it’s speed, check if the character can make it to that location in time to catch them or block them, disregard the ones that are too fast or close and finally set as blackboard variable the nearest, incoming, possible to catch Disc.

This is my BT:


All the additional logic is going to take place in The Service FindNearestDisc, since I’m having troubles splitting all that logic into more services because I can’t pass on to them the array containing the discs.
Is that appropriate to do it like that, is there a better/ more efficient way to do it?

After your ai character perceives the discs => puts them in an a array => why not just push this array to an actor that just contains disc info (array of discs) and access them later in the service from the blackboard?

Service


Disc array Actor

BT

AI perception

Blackboard

Thanks for the detailed suggestion.
I’m not familiar with that so a couple of things are unclear to me what exactly are:
You basically have created a Blueprint Actor containing an array of Disc Actors and named it DiscActor, right?
Then Blackboard Variable of the same type so it can be used to store the Discs Array in order to perform calculations by the various Services in the BT?

Oh, WOW!
While I was typing you went even further and made literally the Character’s logic, I have no words, really, so kind.

Yeah, I have a similar implementation, mine is less elegant, basically a Timed Custom Event updated every 0.1s that gets all perceived actors in an array and then clears it. I was thinking about using the AI nodes but the On Target Perception Forgotten totally flew over my head.
Man thanks again.

Oh another thing, I’m still a newbie with BTs: Your use of a Selector means that BTT_Move and Wait are executed alternatively and exclusively? I mean after it moves then it can do it again only after the Wait note is executed as well?
Maybe I should do the same: use a selector containing all the services that executes a move to OR the Catching/Blocking logic?

I wouldn’t pay too much attention to the bt graph itself. I just repurposed an old ai project and wanted to see that the needed elements are accessible in the service :wink:

It took me a while but in the end I did it, I wasn’t able to try until the past week and then I had to redesign my logic because I hit two walls basically: first one was tied to the nature of my project: Hotseat Multiplayer is a feature, I implemented a second player spawned by and referenced in the first one so that I only one Player Controller is used for two identical pawns.
It took me a while to figure out that I was getting one and setting another different instance of the same actor…

The second one: It didn’t actually fly over my head the On Target Perception Forgotten node: it doesn’t exist on 4.26, nothing unrecoverable but I had to redesign some logic between the Projectile and the Character.

I have noticed that while the AI Character is moving to the destination the other services are stopped, is there a way to keep them executing instead?

Maybe you can call them in parallel?

I tried with a Simple Parallel but had no success, maybe I have missed something, going to try again tomorrow.

I can’t make it to work: simple parallel executes only the task and disregards the leftmost part, tried even with a selector like in the video but the outcome doesn’t change.
I have no clue.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.