Hi.I want to make a CharacterController jump script which jump speed depends on how long you press jump button.
(Like every other Platform Game.)
This is the function that decides jump speed.
function SetJumpSpeed():float{
var timeKeeper:float;
var pressedTime:float=0.2;//0.2second
timeKeeper=Time.time;//save Time.time when the jump button was pushed.
if((Time.time-timeKeeper)>pressedTime&&Input.GetButton(“Jump”))
//if 0.2second has been passed since I pressed Jump Button and I am still pressing Jump Button.
jumpSpeed=8.0;//I can jump higher.
else jumpSpeed=4.0;
Debug.Log(“”+jumpSpeed);
return jumpSpeed;
}
jumpSpeed will be always 8.0.I guess this will happen because the line
timeKeeper=Time.time;
doesn’t work property in Update function.
Will you show me how I can save time when I pressed the button.
Thanks in advance,and sorry for my poor grammar.