Wowie! It’s been 2 weeks since I posted something here, and let me tell you… So. Much. Have. Been. Done.
So let’s dive right into it!
Updates, and how to cope with them.
As many of you may know, Unreal Engine recently had an update to 4.18.2. Is this a bad thing? In this case, it was not… Except for the fact that some changes had to be done with the AI. I lost the ability to control how many checkpoints it makes towards its destination, which is bad. As you may remember, the AI is using a ‘CharacterMovement’ component both when it flies and when it walks. But by using such a component for precise flying movement often results in the AI circulating its checkpoint, forever trying to get back into its track.
So changes had to be made. Now, the AI uses a ‘FloatingPawnMovement’ component when it is doing its flying shenanigans. And yes, it’s flying movement is now a little…
Robot-like. But you do the best with what you have.
Fuel me up!
The AI does now finally have a real jetpack system!
It’s a rather simple system, so don’t let all the trissle-trassle scare you. I’ll walk through it with you!
It starts with having a full tank, so it switches over to ‘FloatingPawnMovement’ and flying mode the moment it comes to life. As flying mode is activated, an event is activated that drains the fuel. See this like a stamina bar in any other game. As long as one action is taken, the ‘stamina’ is drained.
Just as before, the AI have a retreat behavior once the fuel gets empty. But this time it has a little twist into it. Every time a jetpack check is done, the AI gets a new set of random number between 40 and 60. This means that each AI may retreat at different times, even when they are simultaneously activated. This is to achieve the illusion that some of the AI are more of a risk taker while some are playing it more safe. They also have sound cues, but we’ll get to that soon.
Once the fuel is 100% drained, the AI switches back to ‘CharacterMovement’ and turns off the flying mode. Once this is done, the fuel will start to regenerate. How fast and how much that will be regenerated is customizable. And once the fuel goes back to its full size, the flying mode goes back online.
But those whom are experienced with ‘FloatingPawnMovement’ knows that rotation is not included. So I had to tell the AI to update its flying rotation, so that it is facing the direction it’s going. You can see the blueprints I made for it here:
What was that?!
Remember that each bullet that is shot also is linked to the shooter? We are taking advantage of this opportunity and give the AI a bullet reaction! You know in, almost every shooter ever, you have a small ‘blood compass’ that points to the direction where the bullet came from, and thus gives you a direction to focus on? We’re giving that ability to the AI!
Here’s the blueprint:
If the AI in that moment don’t see any player and get shot, it traces the owner of the bullet and turns to the general direction it got attacked. After a few seconds of not seeing its attacker, it turns back to it’s current direction.
CALCULATED!
Yes, this is exactly what you’re thinking it is! The AI is now the master sharpshooter thanks to the wonderful world of MATH!
If you recall from basic math class, that I slept through, The predicted location = Target Location + (target velocity * time). That’s it. Here’s the blueprints to show how it looks:
Naturally, I added a chance for the AI to miss it shot. We don´t want the Ai to become totally OP.
“But why? Why giving it a prediction formula to begin with?!”I hear you all scream in chorus. It’s because it is a part of my focus in this project. To create an AI that “learns” from the players’ behavior. And as far as I’m concerned, seeing your target moving and reacting accordingly based on its velocity, is a kind of learning.
I KNOW YOU ARE HERE SOMEWHERE!!!
Since we’re speaking of learning, I might as well get into this new feature!
Whenever the AI is not seeing any player at all, it starts to count up to 40! Once it reached said number, it changes its patrol points! Since they could not find any player on its natural patrol, it will know when it’s time to start looking elsewhere! Here’s a picture of the blueprint to show how the counting is made.
And here’s a picture on how the whole behavior tree looks so far. (They grow so fast! :´ ) )
WHY ARE WE YELLING?!
One last thing I want to mention; I’ve implemented some voice cues to the AI. Since the criteria in my focus was also to make the AI indicate its choices to the player, I decided to do some voice acting for the sake of it.
Oh? You want to hear it? I guess you have to wait until the project is done. Evil laughter
So what can we expect from yours truly next week?
My next Dev vlog will be the groups last, I’m afraid. We had a specific set of time to pull it off, and it’s reaching to its end. So I will spend the majority of my time to clean up the blueprints, fine tuning and tweaking some numbers and so on. But, IF I get time over, I promise I will do a last push and make something funny. Only time will tell.
Have an awesome weekend my lovelies, and I’ll see you next week!
0 comments