为什么我的TouchPhase。开始不像这样?

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

我想知道这是否是我的触摸控制器的工作方式。

   private void Update () {
        Vector2 vel = rb.velocity;
        float ang = Mathf.Atan2 (vel.y, x : 10) * Mathf.Rad2Deg;

        if (Input.GetKey (KeyCode.Space)) {
            rb.AddForce (Vector2.up * gravity * Time.deltaTime * 2000f);
        }
        if (Input.GetTouch (TouchPhase.Began)) {
            rb.AddForce (Vector2.up * gravity * Time.deltaTime * 2000f);
        }
    }
unity3d touch game-engine
1个回答
0
投票

[Input.GetTouch期望索引..您正在传递枚举值。

Input.GetTouch实际上有几个在Unity中使用触摸的示例。

在您的情况下,您只想检查在API状态下是否有首次触摸,因此您可以使用例如

Began

unity3dtouch

© www.soinside.com 2019 - 2024. All rights reserved.