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.设置脚本中的变量


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

相关推荐
北京阿法龙科技有限公司17 小时前
AR 巡检与普通巡检有哪些区别,有哪些优势|阿法龙XR云平台
ar·xr
SmalBox19 小时前
【URP】Shader绘制棋盘格对比内置管线
unity·渲染
郝学胜-神的一滴2 天前
基于OpenGL封装摄像机类:视图矩阵与透视矩阵的实现
c++·qt·线性代数·矩阵·游戏引擎·图形渲染
恒点虚拟仿真2 天前
XR数字融合工作站赋能新能源汽车专业建设的创新路径
人工智能·汽车·xr·虚拟现实·虚拟仿真·新能源汽车·ai+虚拟仿真
EQ-雪梨蛋花汤2 天前
【Unity笔记】Unity 编辑器扩展:打造一个可切换 Config.assets 的顶部菜单插件
unity·编辑器·游戏引擎
SmalBox2 天前
【URP】UnityHLSL顶点片元语义详解
unity·渲染
在路上看风景2 天前
9. Mono项目与Unity的关系
unity
在路上看风景2 天前
1.12 Memory Profiler Package - Summary
unity
SmalBox3 天前
【URP】Unity Shader Tags
unity·渲染
极客柒3 天前
Unity 塔防自用可视化路点寻路编辑器
unity·编辑器·游戏引擎