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

相关推荐
谙弆悕博士17 小时前
【附C++源码】从零开始实现 2048 游戏
java·c++·游戏·源码·项目实战·2048
沃普天科技17 小时前
TYPE C全功能10G数据放大延长PS8353 PS8780 PS8778 8K60HZ
驱动开发·游戏·计算机外设·电脑·ar·硬件工程·vr
AI前沿资讯18 小时前
2026 AI 3D工具推荐:V2Fun如何重新定义“一站式角色创作”
人工智能·3d
ZPC821020 小时前
双目相机 + RGB-D + 点云:生成物体 3D 包围盒 + 计算抓取姿态
数码相机·3d
阿斯加德D1 天前
我的世界生活大冒险整合包下载高版本2026最新分享
测试工具·游戏·游戏程序·生活·材质
CG_MAGIC1 天前
3D 建模比例把控技巧
3d·效果图·建模教程·渲云渲染
胖胖熊℡1 天前
C语言打字母游戏,多版本(117-118)
游戏
两水先木示1 天前
【Unity】使用AI辅助开发Unity游戏流程
游戏
墨绿色的摆渡人1 天前
论文笔记(一百一十五)Physically Embodied Gaussian Splatting: ... 3D Representation for Robotics (一)
论文阅读·3d
点PY1 天前
Anywhere3D-Bench论文精读
3d