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_428639613 小时前
虚幻基础:角色攻击
游戏引擎·虚幻
EQ-雪梨蛋花汤6 小时前
【Unity笔记】Unity XR 模式下 Point Light 不生效的原因与解决方法
笔记·unity·xr
希望PZM7 小时前
Unity实现UV的中心缩放
unity·游戏引擎·uv
小林up1 天前
《Unity Shader入门精要》学习1:Phong 模型中法向量归一化的正确位置
学习·unity·游戏引擎
SmalBox1 天前
【光照】[PBR][几何遮蔽]实现方法对比
unity·渲染
玉龙20252 天前
使用虚幻引擎时间轴制作一个弹跳小球
游戏引擎·虚幻·虚幻引擎基础入门
玉龙20252 天前
虚幻引擎|UE5制作DeepSeek插件并打包发布
ue5·游戏引擎·虚幻·虚幻引擎基础入门·=学习·虚幻引擎插件
Hody912 天前
【XR行业应用】XR + 医疗:重构未来医疗服务的技术革命与实践探索
重构·xr
万兴丶2 天前
Google Play合规指南:您的应用所使用的原生库不支持 16 KB 内存页面大小.快速解决
unity·google
北京阿法龙科技有限公司2 天前
AR眼镜在安防领域人脸识别技术方案|阿法龙XR云平台
ar·xr