Development Update 3: Character Implementation and Animations

9
The model I was going to make, before realising how long it would take me to build.

 

Before putting a character into unity, there needs to be a character model. Though it would be possible to build one in Blender from scratch, the process would be very time consuming. So instead I’ve opted to download a pre-rigged character model to save time. I may come back and change the model at a later date, but in the meantime a pre-made character model will do.

10

This is the character model I’ve decided to use in the meantime. It is a useful model as it is already rigged and has a walking animation, running animation and an idle animation.

Because of this it will be very easy to implement into the game, it could also be used as a reference or base for when I create my own model.

 

11After changing some values, like size and position, the model has the scripts from the player object applied to it and is put in place of the player prefab. The model is now in place of the red square. After changing some collision settings and stuff to fit this new model, it works. However, the model has no animation, so is rather motionless. To fix this we need to create an animator controller. Because This model has a walking and running animation I want to create a run button and a variable that changes the animation depending on the speed of the player. After some changes to the script, it’s time to incorporate the animations.

13
The blend tree with 3 animations

A new input to the game is added and the animation window is opened. I create a blend tree, which is essentially how Unity transitions from one animation to another, to make gameplay appear fluid. Because there are 3 animations that need transitions between them (idle, walk and run), there needs to be 3 motion fields.

14

After some more debugging and changes to the player physics and controller, we can see that the player animations now depend on the variable, that is the speed of the player. When the player isn’t moving (speed=0) the player is in the idle position. As the player picks up speed (speed=8) the walking animation begins. When shift is held (Speed=12) the run animation begins. Because of the blend tree, this all looks nice and fluid.

Development Update 2: Player Spawn and Camera Tracking

56

 

 

 

 

 

 

 

 

7
On the left we see what the game looks like. On the right, we see the mechanics and how the objects interact. This includes the camera which is following the player.

I’ve created 2 scripts. One determines the player spawn in relation to the camera and the other is the movement of the camera.The new settings means that the player object has been turned into a prefabricated object that’s part of the game manager script. Instead of being apparent from when the game is loaded, the player will now spawn into the central camera position and be followed by the camera.

In the camera’s script there is a void, which is the camera’s target. This void is filled with the prefabricated game object, which is the player. This means the camera now follows the player… Or at least that’s how I explain it to myself in my head.

 

 

8As indicated earlier, we can now see that there is not initially any sign of the player until the play button is pressed and the script starts. Once started, the player spawns and can be controlled.