Post news RSS Meet the Archer, the Immortal Redneck marksman

We already have shown you the Warrior, a melee enemy, so now it's time for-AAAGH, what the hell was that!? Oh, an arrow to the knee. So original... Stupid Archer!

Posted by on

Ouch, man, my leg... Bruno about to introduce a new type of enemy: the Archer. The name almost says it all, but as we did with the Warrior, we want to explain how we made this creature, what attack pattern we chose and how it will make you curse his eyes once you play Immortal Redneck.

How it looks like

Our archer is anthropomorphic creature with a strange helmet that hides his face and make us wonder what's behind it. Or maybe the helmet actually is his head, we don't really know. I asked one of our 2D artists about it and he just gave my this look.

Anyway, those big, red, glowing eyes are his best weapon, since he can see you from very afar and shoot arrows very precisely, anticipating your movements like some sort of magic marksman. He's also very agile and can climb platforms and flee really fast if you are close enough.

Not the kind of enemy you'll beat with your fists or a melee weapon.

As the Warrior, the Archer is taller than the Redneck. Our wacky fellow is about 1,8 meters tall, but the Archer is more than 2 meters tall. That's about 5,9 feet versus 7,8. Obviously, since the Archer attacks from a distance, it looks a little smaller than he really is.

How we made the Archer

The Archer is the second enemy we programmed in Unity, so we already had some stuff done thanks to the Warrior. The process needed some time, of course, but it needed less polish than we initially thought.

Our idea was simple: the Archer had to walk around searching for you until either he either sees you or you hit him. When one of this two things happen, he enters 'attack mode' and shoots arrows trying to anticipate your movements. If he loses eye contact, he will move until he has a clear shot again.

With that in mind, our first step was to implement the wander behavior. First, our initialization node (the one we use in all our ememies) so the enemy 'starts' and, after that, the Wander node, so he moves around.

Like this:

Now, we make him 'see' the player. We made a node so he know when someone is hitting him and then we inserted a selector between both possibilities. And since we need to constantly reevaluate this conditions until one of them 'happens', we added an until success decorator node.

Now, we join both branches so the Archer patrols until one of the said events takes place. We used a parallel selector that will keep executing the wander and detection nodes until one of them returns a 'true' value.

Let's see how this looks like.

Yeah, a this moment the Archer was in a early stage, so it just stops when he sees you. Sorry about that.

Anyway, when he enters attack mode, he starts following you and he attacks non stop. We inserted a repeater in the last node of our father sequence so he we will always stay in this logic branch of the behavior tree.

We also added another branch so he is constantly checking for the player. If he is seeing you, he shoots. If he does not, he walk towards you following the shortest path available.

At this moment, it kind of looked like a hide and seek game because we didn't have the shooting implemented yet. Quite funny.

Time to make him shoot arrows. We programmed our own attack node and the we animated the Warrior with the proper nodes.

And this is how it looked like:

Now, the finishing touches. We noticed that the Archer sometimes just peeked around a corner and started shooting even tough the wall was pretty much between him and the player. This happened because we used raycast to configure his sight. We solved the issue using SphereCast instead. This way, he has to see you entirely before shooting.

Once this was solved, we implemented some course prediction in the shooting and we tested it all again.

Piece of cake, uh? No, not at all. Damn arrows. We are still making some final changes in the animation and the arrow behavior, also in the visibility of the enemy around the final rooms, since the brown color actually merge a little with the bricks and floor patterns if the Archer is a little far away.

Let's take a look at the final Archer AI and animation.

Liked it? Hope so.

For those of you that already follow us on Twitter and Facebook, thank you so much. It makes us really happy to read you comments and your feedback. You make our days better. For those who don't, what are you waiting for? It's the best way to keep up with the silly stuff we do everyday. Come one, even if you don't like our game, we want to hear bad things too. There's not greatness without good critics pointing what it doesn't work for them!

PD: We have another favorite Archer!

PDD: Also, Happy Thanksgiving!

Saghen - - 154 comments

One thing that is worth mentioning, couldn't the play spam A and D and then archer would shoot next to him? I have noticed this in many games with this type of programming (i.e. Orcs Must Die 2).

Reply Good karma Bad karma+1 vote
Crema Author
Crema - - 11 comments

That's something we really want to avoid. As you can see in the videos, the shooting still needs some work because it's easy to make him miss the shoot. Also, we need to balance its shooting pace once we have more enemies. Anyway, thanks a lot for your question!

Reply Good karma+2 votes
Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.