跳转一次预制不能正常工作?

问题描述 投票:0回答:1

我正试图测试一条会跳出水面的鱼。我的脚本似乎很好,除非我按下键没有任何反应。我正在按照一个简单的教程,似乎适合每个人。我做错了什么,如何在以后在没有按键的情况下在我的捕获脚本中引用它时更简单。这是因为鱼会在以后自行跳跃。

public bool onGround;
private Rigidbody rb;

// Use this for initialization
void Start () 
{
    onGround = true;
    rb = GetComponent<Rigidbody> ();
}

// Update is called once per frame
void update ()
{

    if (onGround) 
    {
        if (Input.GetKeyDown ("a"))
        {
            rb.velocity = new Vector3 (0f, 5f, 0f);
            onGround = false;
        }
    }
}

}

c# unity3d unityscript
1个回答
1
投票

实际上,更可能的是你的更新功能没有正确设置

将其更改为

void Update()
© www.soinside.com 2019 - 2024. All rights reserved.