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


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

相关推荐
小贺儿开发9 小时前
《流光绘忆》Unity 沉浸式光影互动
科技·unity·ai·程序员·工具·互动·光影
wasee00112 小时前
亲子XR大空间为什么受欢迎?研学项目的客群与运营模式分析
xr
Aman198413 小时前
Claude Code做Unity项目移植(一):从零散工具到团队式
unity·游戏开发·vibe coding·claude code·项目迁移
地狱为王15 小时前
Unity使用VoxLock实现语音隔离
unity·游戏引擎·音频处理·voxlock
Jmyd012318 小时前
博物馆数字展厅系统架构设计:实景采集到云渲染全链路
unity·系统架构·博物馆·数字展厅·博物馆数字化
解决小子18 小时前
【虚幻引擎】【GAS】模块详解
游戏引擎·虚幻·gas
一只大鸽子19 小时前
游戏开发笔记0-Godot启动
笔记·游戏引擎·godot
weixin_4242946721 小时前
对于未加入 Script Execution Order 的脚本
unity
暴走约伯1 天前
【VFX工具链源码拆解 03】告别机械劳动(下):材质字典映射批处理与智能纹理槽识别
unity·游戏引擎·材质
Wanda12141 天前
机器人与机电一体化3D数字孪生机器-Day9
人工智能·3d·unity·机器人·数字孪生