【问题标题】:Need help to implement mobile inputs in Unity 3D需要帮助在 Unity 3D 中实现移动输入
【发布时间】:2021-11-04 00:56:27
【问题描述】:

我使用 Unity 2D 游戏套件设计了一款 2D 游戏。我的唯一目的是在 Android 设备上发布它们。但不幸的是,它的输入不适用于触摸屏。我想使用虚拟操纵杆移动玩家。有人可以帮我编辑这个 C# 脚本吗?

public InputButton Pause = new InputButton(KeyCode.Escape, XboxControllerButtons.Menu);
    public InputButton Interact = new InputButton(KeyCode.E, XboxControllerButtons.Y);
    public InputButton MeleeAttack = new InputButton(KeyCode.K, XboxControllerButtons.X);
    public InputButton RangedAttack = new InputButton(KeyCode.O, XboxControllerButtons.B);
    public InputButton Jump = new InputButton(KeyCode.Space, XboxControllerButtons.A);
    public InputAxis Horizontal = new InputAxis(KeyCode.D, KeyCode.A, XboxControllerAxes.LeftstickHorizontal);
    public InputAxis Vertical = new InputAxis(KeyCode.W, KeyCode.S, XboxControllerAxes.LeftstickVertical);
    [HideInInspector]
    public DataSettings dataSettings;

【问题讨论】:

  • this 对您的问题有帮助吗?
  • 没有。我试过了..

标签: c# unity3d 2d-games touchscreen


【解决方案1】:

您可以从资源商店下载资源来进行触摸控制。

您也可以自己编程。您可以从Input.Touches 获取有关用户如何触摸屏幕的所有信息 要制作虚拟操纵杆,您需要将触摸的当前位置与其在其 Phase 为 TouchPhase.Began 的帧上的位置进行比较

【讨论】:

    猜你喜欢
    • 2016-10-16
    • 1970-01-01
    • 2020-03-11
    • 2013-02-08
    • 1970-01-01
    • 1970-01-01
    • 2017-01-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多