X Tutup

Tut #2 - Character, Rigging, Animation


For this tutorial I created a simple third-person character scene in Unity and implemented both character movement and animation control using C# and Unity’s Animator system.

Scene Setup

I began by importing a basic low-poly character model from Blender. The character included several animations such as 

Idle, Run and Wave.

To create a test environment I added a large cube platform with a Box Collider so the character would have a solid surface to stand on.

I then added the following components to the character object:

Animator, Character Controller, Custom movement script.

The Character Controller allowed the player to move smoothish. 

Character Movement Script

I created a script called: 

MyThirdPersonContraoller

The script also rotates the character based on horizontal input.

Example movement logic:

var v = moveInput.y;
var h = moveInput.x;
transform.Rotate(0, h * turnSpeed * Time.deltaTime, 0);
cc.SimpleMove(transform.forward * v * speed);

This allows the player to move forward and rotate using keyboard input.

Animation System

To animate the character, I set up an Animator Controller with three animation states:

Idle, Run and Wave.

I created transitions between Idle and Run using a float parameter called Speed.

Animator transitions:

Idle → Run
Condition: Speed > 0.1

Run → Idle
Condition: Speed < 0.1 

Controlling Animations with Code

The movement script updates the Animator parameter each frame so the correct animation plays depending on the player's movement. When the player moves forward the Speed value increases, triggering the Run animation. When the player stops moving the Speed returns to zero and the Idle animation plays again.

Problems Encountered

During development I encountered several issues:

Animator not triggering: At first the animation transitions were not working because has exit time was enabled. Disabling this allowed the animations to transition immediately based on the Speed parameter.

Animation jitter: The run animation initially appeared glitchy I wasn't able to fix this one yet. 

Sliding character: Before connecting the Animator parameter to movement input, the character appeared to slide across the ground without walking. Updating the Speed parameter inside the movement script solved this.

Result

The final result is a controllable third-person character that:

moves across the platform using keyboard input

rotates based on player direction

transitions smoothly between Idle and Run animations

I still need to figure out how to fix the glitchy run. 

Get UTAS KIT207 Portfolio

X Tutup