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


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

相关推荐
qq_428639618 小时前
虚幻基础:安装插件
游戏引擎·虚幻
qq 1808095110 小时前
从零构建一个多目标多传感器融合跟踪器
unity
平行云11 小时前
实时云渲染支持在网页上运行UE5开发的3A大作Lyra项目
unity·云原生·ue5·webgl·虚拟现实·实时云渲染·像素流送
AA陈超11 小时前
虚幻引擎5 GAS开发俯视角RPG游戏 P07-18.生成火球术
c++·游戏·ue5·游戏引擎·虚幻
鹏飞于天11 小时前
Shader compiler initialization error: Failed to read D3DCompiler DLL file
unity
wonder1357913 小时前
UGUI重建流程和优化
unity·游戏开发·ugui
Doc.S16 小时前
多无人机任务自定义(基于ZJU-FAST-Lab / EGO-Planner-v2)
游戏引擎·无人机·cocos2d
那个村的李富贵17 小时前
Unity打包Webgl后 本地运行测试
unity·webgl
nnsix18 小时前
Unity OpenXR开发HTC Vive Cosmos
unity·游戏引擎
nnsix18 小时前
Unity OpenXR,扳机键交互UI时,必须按下扳机才触发
unity·游戏引擎