我目前正在尝试设置一个控制器与我的WebGL统一游戏,以使一个对象左和右移动。控制器是一个iNNEXT SNES控制器。我已经将水平D控件映射到:
Type: Joystick Axis
Axis: 4th axis (Joysticks)
Joy Num: Get Motion from all Joysticks
控件在“统一编辑器”中工作。当使用D-Pad时,玩家会左右移动.但是,一旦我为WebGL构建了游戏,longer控件就不再被识别,对象也不再向左或向右移动。我还试着为“Input.GetAxis(”水平“)”添加print语句,并且在Unity中测试时收到-1或1,但是当我为WebGL构建游戏时,它保持在0上。
void Update () {
if (Input.GetAxis("HorizontalDPAD") > 0){
MoveRight();
}else if(Input.GetAxis("HorizontalDPAD") < 0){
MoveLeft();
}
}
public void MoveLeft(){
transform.position += Vector3.left * movementSpeed * Time.deltaTime;
}
public void MoveRight(){
transform.position += Vector3.right * movementSpeed * Time.deltaTime;
}
我没有收到任何错误消息,Input.GetAxis("HorizontalDPAD")在Unity中工作。在WebGL中,just控件似乎没有被识别。如果您有解决方案,或者有什么想法需要测试,请告诉我。
发布于 2022-03-24 08:47:12
尝试删除edit -> project settings -> script execution order
中的跨平台输入
https://stackoverflow.com/questions/56554126
复制相似问题