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


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

相关推荐
NIKITAshao15 小时前
Unity URP Volume组件详解(笔记)
unity·游戏引擎
lingxiao1688818 小时前
WebApi详解+Unity注入--下篇:Unity注入
unity·c#·wpf
世洋Blog18 小时前
面经-CPU、内存、GPU的性能优化
unity·性能优化
lingxiao1688820 小时前
WebApi详解+Unity注入--中篇:.net core的WebAPI
unity·c#·.netcore
weixin_423995001 天前
unity 处理图片:截图,下载,保存
java·unity·游戏引擎
呆呆敲代码的小Y1 天前
【Unity实战篇】| 游戏轮播图效果,多种实现思路及完整教程
游戏·unity·游戏引擎·实战·游戏开发·轮播图·u3d
小南家的青蛙1 天前
O3DE社区发布2510.1版本
游戏引擎·图形引擎
示申○言舌1 天前
Unity高性能参数差异化URP Shader圆角圆环UI进度条
ui·unity·游戏引擎·圆环进度条·参数差异化·材质参数独立·圆角圆环
一只一只2 天前
Unity之协程
unity·游戏引擎·协程·coroutine·startcoroutine
NIKITAshao2 天前
Unity 跨项目稳定迁移资源
unity·游戏引擎