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


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

相关推荐
★YUI★3 小时前
学习游戏制作记录(制作系统与物品掉落系统)8.16
学习·游戏·ui·unity·c#
SmalBox11 小时前
【渲染流水线】[逐片元阶段]-[透明度测试]以UnityURP为例
unity·渲染
三只坚果1 天前
blender制作动画导入unity两种方式
unity·游戏引擎·blender
benben0441 天前
《Unity Shader入门精要》学习笔记二
unity·unity shader
YF云飞1 天前
Unity音频管理:打造沉浸式游戏音效
游戏·unity·游戏引擎·游戏程序·个人开发
SmalBox1 天前
【渲染流水线】[逐片元阶段]-[裁剪测试]以UnityURP为例
unity·渲染
与火星的孩子对话1 天前
Unity高级开发:反射原理深入解析与实践指南 C#
java·unity·c#·游戏引擎·lucene·反射
scoone2 天前
开源游戏引擎Bevy 和 Godot
游戏引擎·godot
阿赵3D2 天前
Unity2022打包安卓报错的奇葩问题
android·unity·安卓
霸王•吕布2 天前
游戏引擎中的粒子系统
游戏引擎·粒子系统·粒子发射盒·粒子物理参数·粒子实例·粒子生命周期·粒子参数