Sunday, 28 October 2018

Animation - Walk / Run

Following the tutorial on character animations, I was able to learn about how to set-up the animation for the Walk/Run transition.


Firstly, I have created an Animation Blueprint file using the Mixamo character Adam as the skeletal mesh option.


I have attached a State Machine node to the Final Animation Pose. This will enable us to set-up several animations and play one depending on the state it is currently in.

By double-clicking on the state machine, we can go inside and set-up the animations.


By setting up Entry > Idle > Walk_Run
                                   Idle < Walk_Run
This means we can go from Entry to Idle animation to the Walk_Run. If we do not set up a link from Walk_Run back to Idle, it means we will be stuck on the running animation, unable to switch back to the previous state.

By double-clicking on the Idle and Walk_Run, we can go inside the file and assign the correct animation to play.


Simply by dragging and dropping in the animation and linking it up to the Final Animation Pose, this assigns the animation to that state.


The next step I took was to create a Blendspace, selecting Mixamo Adam's skeletal mesh for this as well. 

Inside the Blendspace is a window to assign animations on a graph. On the left panel, I have set-up the Axis settings. The horizontal is the Direction, and the vertical is the Speed.

Horizontal - Minimum axis = -180.
                  - Maximum axis = 180.

Vertical - Minimum Speed = 100.
Vertical - Maximum Speed = 600.

The reason the horizontal axis values are that is so we can rotate a full 360 degrees.
For the vertical, the minimum 100 is the default, and the maximum walk speed I set-up in the stamina/sprinting section within the First Person Character blueprint file was 600. 



By adding the interpolation time to 1, this means our animations will not instantly switch from one to another. It switches between the animations over a one second period, resulting in a smooth and realistic effect. In play mode and interpolation time set to 0, you notice the unnatural change between animations and can identify the animation switches. 


By simply dragging and dropping the animations from the browser onto the graph, we can set up the animations for the correct direction and speed. By selecting the top-left middle button, it allows us to see the names of the animations which makes it easier to ensure you have selected the correct animations.

Where you drag the green diamond is where the preview will view. Holding Shift and dragging the mouse around will result in the green diamond being dragged where ever the mouse is, meaning we can see the preview update as we move it around for testing purposes.


In the Blueprint file, I have selected the Walk_Run state rather than the Idle. Inside I have linked up the Blendspace file that was just created. The node has links for Direction and Speed, rather than inputting a value manually, I have created and linked variables named Direction and Speed to the Walk_RunBS node. 


By doing this we are calculating the speed and direction of the character. In the tutorial, he has used VectorLengthSquared, whereas I have used VectorLength. The reason being that I found this was an error, and this will end up with a far larger speed by squaring it. Instead, we get the accurate values using VectorLength.


The final step is to instruct when to call the animations. By clicking on these icons, we can determine when the corresponding animation should be activated. 



This part is very simple for the Walk_Run animation. All we are doing is checking whether the speed is more than or less than 10. By checking the value of our speed variable, we can determine whether our player is moving or not. The Blendspace we set-up previous handles the rest of the animations based on speed/direction.

Overall, I think setting up the animations is a simple concept - especially with using the Blendspace. I think there could be some situations where you are dealing with a large number of animations it could get very cluttered, especially in the blueprints and be quite difficult to keep track of your work.

After learning a range of aspects of animation from the tutorial, I feel confident to go ahead and create basic animations for my character, which I intend to do with the time after the foundations of my game are complete. I would like to complete jump, death, hit reaction, and potentially crouch/prone animations. 

Friday, 26 October 2018

Animation Retargeting

Using the default FPS pack in Unreal provides you with a set of animated robotic arms. If you look down, or around it is not possible to see any legs or body, and the robotic arms do not fit in with my theme.


I downloaded the Animation Starter Pack by Epic Games on the Unreal Marketplace. I found the term "Animation Retarget" which will allow me to use these animations on another character.

After doing some searching, I came across Mixamo, by Adobe. They offer 3D animated characters you can customize and download. After a while, I discovered they have a free asset pack on the Unreal marketplace.


I found a written tutorial on the Unreal Engine website. Following this, I began by opening the Animation Starter Pack skeleton mesh and using the "Set Up Rig" for both skeletal meshes.


By doing this I am matching up the bone structure of each character. There is an advanced tab, which will include individual fingers etc.



The auto mapping only completed a few correctly. I went through the entire list manually and assigned it the most accurately as I could.


Going into the Animation Starter Pack and right-clicking to access the Retarget Anim Assets > Duplicate Anim Assets and Retarget option will allow us to duplicate the animation from the starter pack into an animation we can use with our new character.


This confirms which skeletal mesh we want to create the new animation for. Once I had completed this, according to the tutorial it should be functioning with the possibility of slightly deformed fingers.

My character was not animated at all, so I opened the Blueprint file for my First Person Character and changed the Animation to the MixamoAnimBP_Adam (Blueprint file included for my selected character in the Mixamo Character Pack).


Once I had done this, my character was animated. However, the animations were deformed and not functioning as expected.


All of the animations were behaving oddly, except for the standing idle default animation. I attempted to fix this by using the Retargeting Options:


This was advised to fix issues concerning the fingers. I attempted to use this method to fix the arms too but did not succeed.


I came across a setting in the Animation tab "Root Motion". If I selected each animation and selected the root lock option, by doing this the character was no longer beneath the ground. This did not help with the deformed body animation.

I skipped over the last step of the written tutorial, not realizing the importance of the last step at the time. Instead, I found a YouTube tutorial which stressed the importance of ensuring both skeletal meshes have the same pose in order for the animations to be compatible.


This was required on both skeletal meshes.


By matching their poses and saving this, all my animation issues were resolved. I now have a fully functioning character as I had hoped for.

The fact I have a realistic looking character that is moving is very satisfying, and I found it quite a complex task which was a little confusing the first time around. Now that I have completed it once, and understand what is happening after learning about the issue I had encountered, I feel confident to go ahead and do animation retargeting for further characters. However, there is still more work to do before I can say my character is complete.

If I play my game currently, my character has changed and he does move. But he is not holding a gun correctly, and he is not changing animations from walk to sprint etc and I must set these animation switches up next.

Thursday, 25 October 2018

Stamina & Sprinting

Currently, the movement speed is quite slow without an option to sprint like most First-Person Shooters. I found an online tutorial on YouTube that demonstrates how to implement the Stamina and Sprinting element.


The first step was to create an input binding. I assigned the Left Shift key to the Sprint, which is commonly used in online games.


I remembered about creating a health and armour bar previously, using the same principle I created a bar for stamina. Undecided whether I will keep this in the final product, but I have added it in for the time being for the sole purpose of ensuring that the stamina system is functioning as expected.


I had to create another Binding for the stamina bar. Following exactly the same set-up as the Health and Armour bars except for one step.


By including the Division Integer we can divide our value by 100. The reason for this is because it is easier for us to operate on a 0-100 scale, but the Progress Bar actually operates on a scale of 0-1. By dividing it by 100 ensures that the value is correct on both ends.

In the FirstPerson Character Blueprint file, I created two more variables: Stamina (integer) and IsSprinting (Boolean). I set the default value of Stamina to 100 - meaning we will spawn with a full stamina bar.

  • Firstly we check to see if the Sprint key has been pressed (Left Shift).
  • If the Sprint key is pressed, we check whether the Stamina is greater than or equal to 1.
  • If True, set the IsSprinting boolean to true, and set the Max Walk Speed to 850.
  • If False, do nothing.
  • If the Sprint key is released, set the IsSprinting boolean to false.
  • Then set the Max Walk Speed to 600.
This is basic functionality for sprinting. However, to add a sense of realism to the game I would like to have a limit on how much the player can sprint - a regeneration system.


From the tutorial, I was able to learn that we use the Event Tick - which is an event called on every frame of gameplay. We use the delays to adjust how frequently they are called. If we didn't use the delay on the regeneration as an example, the stamina bar would refill instantly the moment the player releases the sprint key - which would practically defeat the purpose of the stamina system.

  • We check to see if the player is currently sprinting
  • If True, check to see if the Stamina is less than or equal to 0
  • If True, set IsSprinting to false and set Max Walk Speed to 600 (Walking speed)
  • If False, set Stamina to (Stamina value - 1).
  • If IsSprinting is False we set the stamina to (Stamina value + 1)
This provides the functionality that is required. However, there are two problems with this that are not covered in the tutorial. 

  • The Stamina does not have a minimum and maximum value. It will continue to recharge past 100, or drop below 0.
  • The Stamina reduces if the player holds down the Left Shift key, even while they are not moving.


Previously, I came across a Clamp node. Using this was a very simple way to ensure the Stamina stays within the boundaries of 0-100.

After a while of searching for how to prevent a player's Stamina reducing while not moving, I came across the question being asked before: how-to-detect-player-movement


This lead to me being able to create a method of checking whether a player is moving, before executing the Sprinting. By performing this, we are checking whether they are moving on the X or Y axis, and if they are we can reduce the Stamina. If they are not moving, we begin regenerating.

Now that I have managed to fix the two issues, I feel like the stamina system is perfected. The only questionable aspect is the UI. In a lot of games, the stamina system exists, but there is no indication bar to tell you - rather they indicate it by audio (breathing SFX). The UI currently is very basic and ugly, I intend to change this later on but question whether the stamina is necessary.

Landscape #3: Foliage



On Unreal's marketplace, I managed to come across Soul: Cave pack for free by Epic Games. I noticed a selection of dead trees and various rocks which is specifically what I wanted for my terrain.

I downloaded the pack and added the realistic looking rock texture for my mountains. Then I started using the foliage tool to create a more realistic terrain by adding in a range of trees.


Dragging and dropping the foliage into the left-hand panel immediately brings up the details panel below. With these settings, I could alter the density of the foliage and their sizes, distance apart and many more.

I chose to put them on various settings so certain pieces would occur more than others and had all of them selected at once so I could paint all of them at once. At first, I found that the density was far too much, and it would be costing vast amounts computationally. After playing around with the settings for a while, I have managed to find a good balance between being realistic and over-the-top, whilst keeping the costs on the lower side.

Using the Culling Distance setting means you can keep foliage inactive until the player is within a certain radius of it, keeping the computation cost down a huge amount. I have a small map size and the player will not be exploring the terrain, so it is not a concern. However, in a different game, this may be crucial.


It is also possible to drag and drop the Static Mesh files straight into the Viewport. This creates one individual instance of it, meaning it is not an efficient method of creating a large terrain containing a huge range of objects. In this situation, I only intend to use one instance of the water.

When using this approach, the object comes in at the standard size. The water piece was extremely large and where it was naturally positioned made it invisible on my terrain. Soon I realized that I could use the rescaling tools to adjust the size and it's positioning.


By simply creating it large enough to put over my map area, then using the translate tool I could reposition the Z axis to make the water appear shallow or deep. The water is filling in the grooves I created in the landscape using the sculpting tool previously.

After adding these extra features from the Soul: Cave package, my terrain has started to come to life and I am very pleased with it. The only issue is the texture on the mountains have the same lines running down them. On the small map that I have, with few mountains, I think I can get away with this. However, if I had a larger size and the player was free to explore the terrain oppose to restricted to what is visible from the windows, this would be more of an issue as it would take away from the realism and be clear there is a repeated texture.

Wednesday, 24 October 2018

Landscape #2: Handling Textures


In the KiteDemo folder that is included in the Open World Demo Collection by Epic Games, I found extra materials that seemed far more ideal for what I wanted. So I decided to add extra layers and remove the grass.


Grey squares were appearing after painting several layers and were not disappearing over time. or after building and running play. I figured it may have been to do with adding too many layers and started to search for solutions.




On this thread, an unknown user posted explaining select the layers and set the Sampler Source to Shared: Wrap. 

By using this, the grey blocks disappear and the materials are working much better. It seems we should be using shared mode once we are reaching 16+ textures, and there is no loss of quality.


I tried to search for an explanation for what Shared: Wrap setting actually does. I could not actually find a clear response that made great sense, other than we should use this setting once we are using 16+ textures. 

Using a combination of textures blended together, I am beginning to see a darker and more realistic effect on the terrain. Overall, it is a huge improvement in comparison to the previous version of the terrain. It is currently still very bare and the grey areas have diagonal stripes through them and a use of different texture may be required for a realistic effect. 

Landscape #1: Sculpting and Materials

By following this tutorial I was able to learn about creating landscapes in Unreal and many of the tools.

Firstly by going to the Landscape mode, I selected my size. Considering the playable size of the map will be restricted to the building, and the terrain is only what they will see through the windows, I don't need a particularly large landscape, which will use up more processing power.


Using the Sculpting Tool I was able to create some hills and mountains. The higher ones appeared particularly stretched and unnatural, so I used the Smooth Tool to run over them all to create a realistic shape.

The Hydro Erosion tool was used to create small grooves at the bottom of the mountains to give a realistic erosion effect that would be apparent over years in reality.

The other tool I used was the Retopologize to prevent stretching of materials once applied.


I created a new material, using the naming convention M_ (to denote material). Inside the file, I created nodes to connect three materials (defining the amount on the left panel). 

The reason for this is to create several layers that I will be able to paint with continuously. The main ones being Grass, Rock, and Gravel from the StarterContent folder.

Two types of files are included, _D for Base Layer and _N for Normal.


Using the LandscapeCoords node and linking it to all the textures, followed by adjusting the Mapping Scale adds a greater level of detail to the overall landscape to give it a much more realistic appearance.

Before:


After:



With a combination of tools, primarily the Sculp, Smooth, and Retropologize I was able to create the heightmap. Furthermore, with the use of blueprints, I was able to implement three materials which can be 'painted' on the terrain to achieve my first version of a terrain.

There is more work required to accomplish the level of detail I am hoping for. However, I can see the terrain formation coming along and with the exploration of materials, I hope to achieve rocky mountains, gravel ground filled with rocks and dead trees to enhance the dark, isolated atmosphere of the game.

Unreal: Project Evaluation

Unreal is visually enticing and appears to be extremely user-friendly. In the beginning stages, I found it really nice to use and I was exc...