【问题标题】:on screen joystick in unity 5unity 5 中的屏幕操纵杆
【发布时间】:2016-08-05 08:31:56
【问题描述】:

当我向下滑动操纵杆时,操纵杆无法正常工作,火车向上移动,反之亦然,当我向上推时,火车向下移动。

我想把它改过来。

这里是代码

using UnityEngine;
using System.Collections;
using UnityStandardAssets.CrossPlatformInput;

public class joystick : MonoBehaviour {
    public float TrainSpeed = 50;
    public float TrainRotateSpeed = 50;
    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () {
            transform.Translate(0f, 0f, TrainSpeed *           CrossPlatformInputManager.GetAxis("Vertical") * Time.deltaTime);
        transform.Rotate(0f, TrainRotateSpeed * CrossPlatformInputManager.GetAxis("Horizontal") * Time.deltaTime, 0f);

}

}

【问题讨论】:

    标签: unity5 touchscreen


    【解决方案1】:

    在 TrainSpeed 前加一个减号:

     transform.Translate(0f, 0f, -TrainSpeed * CrossPlatformInputManager.GetAxis("Vertical") * Time.deltaTime);
    

    【讨论】:

    • 谢谢你,我会试试的,我知道 - 必须去某个地方
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多