Unity_XR控制手部动画

文章目录


手部模型下载链接

效果展示

一、添加左右手部模型

1.添加XR Origin

2.添加模型

二、添加控制手部动画脚本

1.查看手部动画



2.编写脚本

csharp 复制代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class AnimateHandController : MonoBehaviour
{
    public InputActionProperty pinchActionProperty_Select_value;
    
    public InputActionProperty gripActionProperty_ActivateValue;

    private InputAction pinchAction;
    private InputAction gripAction;
    private Animator animator;

    // Start is called before the first frame update
    void Start()
    {
        pinchAction = pinchActionProperty_Select_value.action;
        gripAction = gripActionProperty_ActivateValue.action;
        animator = GetComponent<Animator>();
    }

    // Update is called once per frame
    void Update()
    {
        float triggerValue = pinchAction.ReadValue<float>();
        animator.SetFloat("Trigger", triggerValue);

        float gripValue = gripAction.ReadValue<float>();
        animator.SetFloat("Grip",gripValue);
    }
}

3.添加脚本到有动画的模型上

4.设置脚本中的变量


注意找到对应左右 的值拖进去

相关推荐
星星火柴9367 小时前
AscendantPath | 实现视觉小说的人物对话系统(二)
游戏·unity·游戏程序·版本为2022.3.57·配合github下载地址使用
死也不注释8 小时前
【在Unity游戏开发中Dictionary、List介绍】
数据结构·游戏·unity·游戏引擎·list·游戏程序
★YUI★1 天前
学习游戏制作记录(冻结敌人时间与黑洞技能)7.30
学习·游戏·unity·c#
惊鸿醉1 天前
⭐ Unity 异步加载PPT页面 并 首帧无卡顿显示
unity·游戏引擎·powerpoint
还债大湿兄2 天前
3D游戏引擎的“眼睛“:相机系统深度揭秘与技术实现
数码相机·3d·游戏引擎
死也不注释2 天前
【第四章自定义编辑器窗口_扩展默认的编辑器窗口_扩展Hierarchy窗口(8/11)】
unity·编辑器
BuHuaX2 天前
Unity_UI_NGUI_缓动
ui·unity·c#·游戏引擎·游戏策划
DaLiangChen3 天前
Unity 实时 CPU 使用率监控
unity·游戏引擎
cyr___3 天前
Unity教程(二十四)技能系统 投剑技能(中)技能变种实现
学习·游戏·unity·游戏引擎