The Adventures of Tokk Project Report Raphael Leon 31 may 2014 | Page 7
jumpsused++;
}
This is the final part of the script that is used to create the double jump.
This was possibly the hardest part of the script as for along time as I tried to just
reuse the “jump” input. This was never going to work as this only allows for a
jump when the character is grounded. This edited script allows me to use the
“jump” input to create the first jump and then, whilst in mid air, jump again. This
is because once I have jumped my jumpspeed counter raises by one and as its
still less than maxjumpcount the character is still able to jump one more time
before having to be grounded. The maxjumpcount variable above can be changed
to allow for any amount of jumps the game requires.
// Apply gravity
moveDirection.y -= gravity * Time.deltaTime;
This tells Unity3D to calculate gravity relative to time.
// Move the controller
controller.Move(moveDirection * Time.deltaTime);
This tells Unity3D to calculate the characters movement relative to time.
/*there are masks throughout the game to collect this is linked to a script on the mask
when the character collides with one they will be displayed in the top right hand corner*/
if (masks==1)
{
msk.mycol.a=255;
}
if (masks==2)
{
msk2.mycol.a=255;
}
This part is using information from the scripts Mskinventry and
Mskinventry2. The masks that are in the top right hand corner are always there
but their transparency is set to 0 but upon colliding with one of the in game
masks, which will set “masks” up by 1 unit, which in turn will set the first mask
in the corner to opaque and able to be seen.
// forces character to stay fixed on the z axis
transform.position.z=57.5;
}
This forces the character to remain fixed in the Z-axis, as the game is a
platform game. It needs to be fixed in place, as there are many things that could
cause the character to be forced of the map.
/* this part of the character control script is linked to a script on the enemies and states
7|Page