• Register
Post news RSS Dev Log 8 - Torch, Crouch, Sneak and AI!

Hey There! Today we show some of our AI and some new features. Come have a look! :D

Posted by on

devlog long

Hey!

Today we show you some of our AI and New Features! :D

This post will explain our process on creating AI and a new feature, the Torch!

Let's Start!

The Torch

First thing we did was creating the torch. To the torch, we add a Static Mesh Component, a Box Collider, a Particle System, a Scene Component to know where to hold and another one to attach the Particle System to.

Torch

Once created, we had to make our player interact with it. However, this was a different type of interaction, as when the player is carrying the torch, he should be holding it.

This can be easily achieved in Unreal using Animation Slots. All we did was get an Animation from Mixamo where the character was holding a torch. We the use a cached posed that contains all the movement and get the desired Animation Slot, in our case, we called it "Right_Arm". To blend the animations, we used the "Layered blend per bone" node, and set it up to use all bones under the right shoulder of the character. Finally, we used the "Blend Poses by bool" node, so this only happens if the character is carrying a torch.

torch setup

In our case, the animation made the torch block a lot of the screen, so we also forced some bone rotation changes to put it more to the side. And it looked like this.

Torch

We then had to make the character able to Pick Up and Drop the torch.

This is quite simple, just play an animation and attach the torch to the right hand. To Drop, just detach it. We also use IKs' to fix some of the animation so it looks like the character actually grabs the torch.

Torch Grab Drop

Now we had to make the player able to light the torch if it was unlit. For this we created some Fire Pits where the torch can be lit, but this can be any fire source.

Fire Source

Torch Light Up 1

Torch Light Up 2

Torch Light Up 3(This one still has an animation problem, IK wasn't enough)


Finally, we needed a place where torches could be placed, after a quick google search, we found out these things where called Sconces. So we created them and made the player able to place and remove torches from these. He can also light his torch here, or light the torch in the sconce.

Sconce


Torch Sconce(We use the same animation, when placing makes it look odd)


At this point the torch was pretty much completed, we are still discussing if the player will be able or not to throw the torch, but not at the moment.

So I started on the AI.

AI - Torch Guy

Now, I haven´t done AI for a while now and certainly not in C++, so I needed something to refresh my memory and learn how the C++ side worked. The AI would use Unreal Engines Behaviour Tree System.

So I started by making a Bot that wanders the map, looking for torches, and when he finds one, places it on a sconce. If that torch is unlit, he first lights it up.

To do this I needed to learn a few things:

  1. How to setup the AI Perception Component;
  2. How to setup the AI Stimuli Source Component;
  3. How to create a task the Behaviour Tree could use.

Luckily, I found and awesome tutorial by MrCxx where he explains all of these things. So I quickly sketched a graph for the behaviour tree and started working on the tasks.

The way I made it, this Bots' only sense was sight, and as he sensed new objects, I would add Torches, Sconces and Fire Sources to an array respectively, making sure not to add the same item twice. Then I created tasks to find the closest Torch, Sconce or Fire Source to the Bot.

If he had a torch, he would check if it was lit. If it was, he would place it in the closest sconce, if not, search for the closest fire source. If he had no torch, he would wonder around looking for one.

This was my way to learn how to make a simple C++ AI and it ended up working really well. It was a little limited as it would only light torches in the big fire sources, but it worked fine.

This was my final Behaviour Tree

Torch Bot Behaviour Tree

And this is the Bot in Action

It had some problems, but it was a great first start and learning experience.

After this, I felt much more confident in what I could do, so I started to work on something a little harder, The Guards!

The Guards are a little harder as their purpose is to limit what the player can do, they are an obstacle. This can range from not allowing the player to enter a certain area, to killing him in sight. This allows for some new mechanics such as sneaking and distracting.

Crouch

Now sneaking can be achieved by adding a new sense to the guard, hearing. If the player is Running, his footsteps will make noise, but, if he's crouching, they won't. So before I made the Guard, I made the player crouch.

For this I used the Character Movement Component, that already has the ability to crouch. All I needed where some animations and it was done.

Crouch


The built in crouch is pretty good, as it automatically changes the capsule collider size and checks for head space when standing up.

So now I started the Guard AI.

AI - Guards

The way the Guard was made is: he patrols around points that we can change in the map.

When something triggers it, be it a sound or the player running, it get as suspect. This makes him stop and look around and after a short while, go to the location where the trigger happened. If during this time, the guard finds the player, or has a direct line of sight to the player, he starts running towards the player.

The player has some time to react to a guard and he can do two things. He can either run away and try to lose the guard this way or, he can hide in bushes(an area) by crouching.

Later we will add boxes where he can hide inside.

After a while, the guard loses interest and return to his patrol.

The player can also throw stones to distract the Guard.

The Guard also has a suspicion amount, and as the player makes noise or gets close to the guard, that value rises.

It's a little complicated and hard to explain, so here is a view of the behaviour tree

Guard Behaviour Tree

and here is the Guard in action.

It still has a lot of issues, but it's almost done.

And that's it for this post, this was a little too much text, but I still have a lot to learn about AI and still have some difficulties explaining.

Next post we will hopefully have the AI a little better and start populating the map.

Thanks for reading and I'll see you next post!

Follow us on Twitter, and now Instagram!

title

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.

News
Browse
News
New
Post news
Share
Related Games
Curse of Life
Curse of Life Adventure
Related Engines
Unreal Engine 4
Unreal Engine 4 Commercial