Tijs
1
In my 2D vertical platformgame i want to give my player a temporary jump boost.
im thinking something like.
if(hit.gameObject.tag == "Boost")
{
**var jumpheight =*2.0;**
yield.WaitForSeconds(5.0) destroy()
But im not sure how to put this in code.
Piflik
2
Something like this should work:
public var jumpHeight : float = 5.0;
public var jumpTimer : float = 2.5;
function OnControllerColliderHit(hit : ControllerColliderHit) {
if(hit. gameObject.tag == "Boost") {
jumpHeight *= 2.0;
Invoke("ResetJump", jumpTimer);
}
}
function ResetJump() {
jumpHeight *= 0.5;
}