话不多说,看——代码
bool Isjump = false;//默认false
float timer=0;
float move = 250;//跳跃的高度
public float time =2;//相当于跳跃的次数
private Rigidbody box;
void Start()
{
box = GetComponent<Rigidbody>();//这里获取组件
}
void Update()
{
//time += Time.deltaTime;
if (time >= timer)//大于等于0都会执行
{
//条件成功时候,为true
Isjump = true;
if (Input.GetMouseButtonDown(0))//鼠标的点击事件(0是左键)
{
//这里是往上跳,*后面是跳跃的高度
box.AddForce(Vector3.up * move);
//点击一次time减去1
time -= 1;
Debug.Log(time);
}
}
}