using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Use this for initialization
void Start ()
{
onGround = true;
jumpPressure = 0f;
minJump = 2f;
maxJumpPressure = 10f;
rbody = getComponent();
}
// Update is called once per frame
void Update ()
{
if(onGround)
{
//holding jump button//
{
if(jumpPressure < maxJumpPressure)
{
jumpPressure += Time.deltaTime*10f;
}
else
{
jumpPressure = maxJumpPressure;
}
}
//not holding jump button//
else
{
//jump//
if(jumpPressure > 0f)
}
jumpPressure = jumpPressure + minjump;
rbody.velocity = new Vector3(jumpPressure/10f,jumpPressure,0f);
jumpPressure = 0f;
onGround = false;
anim.SetFloat("jumpPressure",0f);
anim.SetBool("onGround",false;);
}
}
}
}
void OnCollisionEnter(Collision other)
{
if(other.gameObject.CompareTag("ground"))
{
onGround = true;
anim.SetBool("onGround",false;);
}
}
}
↧