untiy3D为游戏物体制作简单的动画

1.创建一个物体挂载动画组件Animator

2.创建一个动画控制器

3.动画控制器挂载到Animator组件

4.创建动画窗口>动画

入口默认执行left

执行效果

20250212_151707

脚本控制动画

鼠标点击是切换到动画t

csharp 复制代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class test : MonoBehaviour
{


    private Animator animator;

    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {

        // 获取动画器组件
        animator = GetComponent<Animator>();
    }

    // Update is called once per frame
    void Update()
    {

        if (Input.GetMouseButtonDown(0)) {

            animator.Play("left");

        
        }


        
    }
}

效果

20250212_152204

相关推荐
高升说19 小时前
手眼 3D 相机选型:先定工作距离,再谈精度,最后定安装
人工智能·数码相机·3d
码流怪侠20 小时前
Sunshine 深度拆解:当 NVIDIA GameStream 闭源后,如何用 4 万颗 Star 重建自托管云游戏
游戏·github·nvidia
RoboWizard21 小时前
游戏电脑不装固态硬盘会怎么样?
游戏·电脑
利刃大大1 天前
我用 GPT-6 给江南大学建了个 3D 沙盘
gpt·3d·ai·blender·江南大学
驱动小百科1 天前
英伟达GeForce Game Ready 616.92驱动发布:支持《007 First Light》等游戏
人工智能·游戏·英伟达616.92驱动·geforce game·nvidia显卡驱动
职场的momo1 天前
用户讨论:算法开发Offer决赛:大疆纯后端Agent与网易游戏测试,对内AI跳槽难?
人工智能·游戏·跳槽
不要生病了1 天前
从脑电到彩色三维点云:Neuro-3D 精读与证据边界
3d
时空节拍AI数字人1 天前
AI 数字人为什么需要“3D”?2D 不够用吗
人工智能·网络协议·tcp/ip·3d·信息可视化
Zldaisy3d2 天前
以光束整形3D打印,探索陶瓷-铜功能件的一体化制造
3d·制造
LeapMay2 天前
中国科学院深圳先进技术研究院-深圳职业技术大学联合培养博士后招聘(具身智能/多模态感知/视觉检测方向)
人工智能·计算机视觉·3d·机器人