您当前的位置: 首页 >  vr

每日出拳老爷子

暂无认证

  • 4浏览

    0关注

    135博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Unity VR:通过New Input System设置控制函数详解

每日出拳老爷子 发布时间:2022-03-14 01:28:01 ,浏览量:4

  1. 引入XR相关包和新Input系统包:using UnityEngine.InputSystem; using UnityEngine.XR.Interaction.Toolkit;
  2. 声明相应的actionmap:public List other_ref = null; public List grip_ref = null;
  3. 声明相应的需要操作的对象,我这里是挂在VR Controller下的手部模型动画:public Animator left_anime_controller; public Animator right_anime_controller;
  4. Awake触发功能函数:
    private void Awake()
    {
        foreach(var ele in other_ref)
        {
            ele.action.performed += toggle_panel;
        }

        foreach (var ele in grip_ref)
        {
            ele.action.performed += set_grip;
        }
    }
  1. 写具体函数动作:private void set_grip(InputAction.CallbackContext context) { float cur_grip_value = context.action.ReadValue(); left_anime_controller.SetFloat("grib", cur_grip_value); }
关注
打赏
1657016083
查看更多评论
立即登录/注册

微信扫码登录

0.0369s