I have this GUI texture that changes depending on how many times the jump button i pressed during midair, but when I respawn the function does not work again. It it does not reset, and it stays on the last GUItexture image from the previous jump.
This is my GUI script:
var trick6 : Texture2D;
var trick5 : Texture2D;
var trick4 : Texture2D;
var trick3 : Texture2D;
var trick2 : Texture2D;
var trick1 : Texture2D;
static var SPLASH = 6;
function Update ()
{
switch(SPLASH)
{
case 0:
guiTexture.texture = trick1;
break;
case 1:
guiTexture.texture = trick2;
break;
case 2:
guiTexture.texture = trick3;
break;
case 3:
guiTexture.texture = trick4;
break;
case 4:
guiTexture.texture = trick5;
break;
case 5:
guiTexture.texture = trick6;
break;
}
}
I trigger it though my character controller script in the jump function here (post onlye the jumping part of the script):
//Jumping
var jumpSpeed = 15.0;
var gravity = 20.0;
var speedSmoothing = 5.0;
var maxFallSpeed = 50.0;
private var moveDirection = Vector3.zero;
private var grounded : boolean = false;
private var jumpCount:int;
private var onGround:boolean;
function FixedUpdate() {
if (grounded) {
// We are grounded, so recalculate movedirection directly from axes
moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, 0);
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
jumpCount = 0;
}
if (Input.GetButtonDown ("Jump") && jumpCount < 20)
{
moveDirection.y = jumpSpeed;
jumpCount++;
SplashScript.SPLASH -= 1;
}
The third last line "SplashScript.SPLASH -= 1:" is where i trigger it through my character controller script.