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


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

相关推荐
RReality3 小时前
【Unity Shader URP】序列帧动画(Sprite Sheet)实战教程
unity·游戏引擎
mxwin4 小时前
Unity URP 多线程渲染:理解 Shader 变体对加载时间的影响
unity·游戏引擎·shader
呆呆敲代码的小Y5 小时前
【Unity工具篇】| 游戏完整资源热更新流程,YooAsset官方示例项目
人工智能·游戏·unity·游戏引擎·热更新·yooasset·免费游戏
nainaire6 小时前
自学虚幻引擎记录1
游戏引擎·虚幻
想你依然心痛9 小时前
HarmonyOS 5.0游戏开发实战:构建高性能2D休闲游戏引擎与 monetization 系统
华为·游戏引擎·harmonyos
黄思搏1 天前
基于标注平台数据的 Unity UI 自动化构建工作流设计与工程实践
ui·unity·蓝湖·vectoui
羊羊20352 天前
开发手札:Unity6000与Android交互
android·unity·android-studio
Zarek枫煜2 天前
C3 编程语言 - 现代 C 的进化之选
c语言·开发语言·青少年编程·rust·游戏引擎
Sator12 天前
Unity AStarPath的踩坑点
unity
榮華2 天前
DOTA全图透视辅助下载DOTA全图科技辅助下载DOTA外挂下载魔兽争霸WAR3全图下载
数据库·科技·游戏·游戏引擎·游戏程序·ai编程·腾讯云ai代码助手