C# 有两个跟随光标的输入设备';s旋转与统一';中国的新输入系统

C# 有两个跟随光标的输入设备';s旋转与统一';中国的新输入系统,c#,unity3d,game-engine,C#,Unity3d,Game Engine,所以我正在创建一个自上而下的射击游戏,并且刚刚开始使用unity的新输入系统。我现在已经将它设置为可以使用鼠标或控制器的右杆旋转玩家的枪的位置。右棒可以工作,但它会导致您无法再使用鼠标旋转。即使控制器已从PC上拔出,它也会执行此操作,但如果我完全删除脚本的控制器部分,鼠标旋转将再次开始工作。这是我剧本的一张照片 Vector2 mouseScreenPosition = playerControls.Player.MousePosition.ReadValue<Vector2>()

所以我正在创建一个自上而下的射击游戏,并且刚刚开始使用unity的新输入系统。我现在已经将它设置为可以使用鼠标或控制器的右杆旋转玩家的枪的位置。右棒可以工作,但它会导致您无法再使用鼠标旋转。即使控制器已从PC上拔出,它也会执行此操作,但如果我完全删除脚本的控制器部分,鼠标旋转将再次开始工作。这是我剧本的一张照片

 Vector2 mouseScreenPosition = playerControls.Player.MousePosition.ReadValue<Vector2>();//Allows the mouse to follow the cursors rotation
    Vector3 mouseWorldPosition = Camera.main.ScreenToWorldPoint(mouseScreenPosition);
    Vector3 targetDirection = mouseWorldPosition - transform.position;
    float angle = Mathf.Atan2(targetDirection.y, targetDirection.x) * Mathf.Rad2Deg;
    transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, angle));

    Vector2 p = playerControls.Player.Rotate.ReadValue<Vector2>();//Allows the right stick of a gamepad to follow the mouse cursor
    playerControls.Player.Rotate.canceled += ctx => p = Vector2.zero;
    Vector3 gamePadCam = Camera.main.ScreenToWorldPoint(p);
    Vector3 gamePadDirection = gamePadCam - transform.position;
    float gamePadangle = Mathf.Atan2(p.y, p.x) * Mathf.Rad2Deg;
    transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, gamePadangle));
Vector2 mouseScreenPosition=playerControls.Player.MousePosition.ReadValue()//允许鼠标跟随光标旋转
Vector3 mouseWorldPosition=Camera.main.ScreenToWorldPoint(mouseScreenPosition);
Vector3 targetDirection=鼠标旋转位置-transform.position;
浮动角度=数学Atan2(targetDirection.y,targetDirection.x)*数学Rad2Deg;
transform.rotation=Quaternion.Euler(新矢量3(0f,0f,角度));
Vector2p=playerControl.Player.Rotate.ReadValue()//允许游戏板的右键跟随鼠标光标
playerControls.Player.Rotate.cancelled+=ctx=>p=Vector2.0;
Vector3 gamePadCam=Camera.main.ScreenToWorldPoint(p);
Vector3 gamePadDirection=gamePadCam-transform.position;
浮点数padAngle=Mathf.Atan2(p.y,p.x)*Mathf.Rad2Deg;
transform.rotation=Quaternion.Euler(新矢量3(0f,0f,gamePadangle));

@fattie很抱歉我不知道。我对使用stack Overflow还比较陌生绝对没问题,@nino!!!如果愿意,只需“编辑”,然后粘贴到代码中。。请注意,有一个方便的“代码”按钮,可以为您设置格式。这是一个非常有趣的问题,顺便说一句,希望有人知道answer@fattie对不起,我不知道。我对使用stack Overflow还比较陌生绝对没问题,@nino!!!如果愿意,只需“编辑”,然后粘贴到代码中。。请注意,有一个方便的“代码”按钮,可以为您设置格式。这是一个非常有趣的问题,顺便说一句,希望有人知道答案