The Adventures of Tokk Project Report Raphael Leon 31 may 2014 | 页面 5
“Python” for “Maya” or writing code in “3DSMax” to numerous game engines. My
game will hopefully show future employees just how well I have understood the
fundamentals of coding and what an asset I could be to their company.
The character control script is probably the most complicated script that
has been used in the game. This script also calls upon other scripts that are put
onto other game objects that interact with the character. This script will be
broken into small chunks so that they can be best explained to a layman.
Variables are always placed at the beginning, as later parts of the scripts
will use the values that you have set up here.
//calling variables for speed, jumpspeed and gravity
var speed : float = 14.0;
var jumpSpeed : float = 25.0;
var gravity : float = 40.0;
private var moveDirection : Vector3 = Vector3.zero;
These are the variables that the character controller uses for movement.
They are all floats, which mean that they are able to become fractions, and are
not restricted to being integers. It took along time to get these numbers correct
and working harmoniously with each other. Originally the speed was set to 12,
the jumpspeed 10 and the gravity 20. This caused the character’s movements to
be very sluggish with a very limited jump. After adjusting these values fluid
character movement was achieved. Vector3 is used throughout Unity to pass 3D
positions and directions around. It also contains functions for doing common
vector operations. As the game is set in 3D space Vector3 is used instead Vector2.
// variables used to for the jump and the double jump
var jumpsused :int=0;
var maxjumpcount:int=2;
These variables are used to set up the double jump and were essential to
make the double jump work. The script uses these variables later. Jumpspeed
shows how many jumps the character has used and maxjumpcount is the
maximum amount that the character can do.
/* calling upon another script (destroy mask script) this states
that no masks should be displayed at the beginning of the game*/
public var msk:Mskinventry;
msk= GetComponent(Mskinventry);
public var msk2:Mskinventry2;
msk2 = GetComponent(Mskinventry2);
public static var masks:int=0;
function Start()
{
masks=0;
5|Page