Unity Input detected multiple times in a press

前端 未结 2 798
攒了一身酷
攒了一身酷 2021-01-15 15:18

I have a source MonoBehavior script with these methods:

private void Update () {
    if (Input.GetMouseButton(0)) {
        HandleInput();
    }         


        
2条回答
  •  无人及你
    2021-01-15 16:04

    For me, I had placed the Input.GetMouseButtonDown(0) inside FixedUpdate. Because of this, Input.GetMouseButtonDown(0) returns true multiple times in a single mouse click. Replace FixedUpdate with Update, and it will work.

提交回复
热议问题