Unity 3D试图禁用操纵杆控制,以便角色可以在瞄准时移动
我正在尝试禁用操纵杆控件,因此当我缩小角色(并且他的瞄准)时,如果玩家在瞄准模式时遇到了操纵杆,他就不会开始移动。
我正在使用启动器资产的 - 新输入系统(动作类型/PassThrough&passhrough& control type/vector2) - 我使用的是运动混合树(2D自由形式的方向作为混合类型)
(两个)下面的行是我要禁用的)
playerControls.PlayerMovement.Movement.performed += i => movementInput = i.ReadValue<Vector2>();
playerControls.PlayerMovement.Camera.performed += i => cameraInput = i.ReadValue<Vector2>();
private void OnEnable()
{
if (playerControls == null)
{
playerControls = new PlayerControls();
playerControls.PlayerMovement.Movement.performed += i => movementInput = i.ReadValue<Vector2>();
playerControls.PlayerMovement.Camera.performed += i => cameraInput = i.ReadValue<Vector2>();
playerControls.PlayerMovement.Run.performed += i => runInput = true; /// Hold
playerControls.PlayerMovement.Run.canceled += i => runInput = false; /// Let Go
playerControls.PlayerMovement.QuickTurn.performed += i => QuickTurnInput = true;
playerControls.PlayerActions.Aim.performed += i => aimingInput= true;
playerControls.PlayerActions.Aim.canceled += i => aimingInput = false;
playerControls.PlayerActions.Shoot.performed += i => shootInput = true;
playerControls.PlayerActions.Shoot.canceled += i => shootInput = false;
}
playerControls.Enable();
}
I'm trying to disable the joystick controls so when I zoom in on my character(and he is aiming), he won't start to move if the player accidently hits the joystick while he is in aim mode.
I'm using the --new input system from the starter assets (action type/passthrough & control type/Vector2)-- and I'm using a locomotion blend tree (2D free form Directional as the blend type)
(The two lines below are what I want to disable)
playerControls.PlayerMovement.Movement.performed += i => movementInput = i.ReadValue<Vector2>();
playerControls.PlayerMovement.Camera.performed += i => cameraInput = i.ReadValue<Vector2>();
private void OnEnable()
{
if (playerControls == null)
{
playerControls = new PlayerControls();
playerControls.PlayerMovement.Movement.performed += i => movementInput = i.ReadValue<Vector2>();
playerControls.PlayerMovement.Camera.performed += i => cameraInput = i.ReadValue<Vector2>();
playerControls.PlayerMovement.Run.performed += i => runInput = true; /// Hold
playerControls.PlayerMovement.Run.canceled += i => runInput = false; /// Let Go
playerControls.PlayerMovement.QuickTurn.performed += i => QuickTurnInput = true;
playerControls.PlayerActions.Aim.performed += i => aimingInput= true;
playerControls.PlayerActions.Aim.canceled += i => aimingInput = false;
playerControls.PlayerActions.Shoot.performed += i => shootInput = true;
playerControls.PlayerActions.Shoot.canceled += i => shootInput = false;
}
playerControls.Enable();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我最好的选择是让您在AIM进行这样的操作时禁用运动:
您可以尝试一下,但将此摘要移到目标下方。
My best bet is for you to disable movement while aim was performed like this:
You can try it, but move this snippet below your Aim.performed snippet
我在大多数情况下都想出了它。 不幸的是,这是我使用的
布尔值,我忘了禁用,这就是给我大部分问题的原因。
I figured it out for the most part. here is what I used
unfortunately I had a boolean that I forgot to disable so that is what gave me most of my problems.