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

相关推荐
逸模13 小时前
逸模智造・BIM 效能专栏一|极速土建翻模,2D 一键跨越 3D
笔记·3d·bim·土建·翻模
陈天伟教授1 天前
eDrawings 2026 x64 Edition-免费 3D 模型和 2D 工程图查看器
3d
Rauser Mack2 天前
Vibe coding游戏实战:零代码编程五子棋小游戏
人工智能·python·游戏·html·prompt
想做后端的前端2 天前
游戏里的水面是怎么做的
游戏
leoZ2312 天前
Claude 全面解析:从基础原理到实战应用指南
人工智能·游戏
2501_943782352 天前
【共创季稿事节】猜数字游戏:二分法思维与交互式反馈
前端·游戏·microsoft·harmonyos·鸿蒙·鸿蒙系统
Tian_Hang2 天前
eclipse ditto 学习笔记
运维·服务器·开发语言·javascript·3d
星空露珠2 天前
迷你世界UGc3.0脚本Wiki[剧情动画模块管理接口 Timeline]
开发语言·数据结构·算法·游戏·lua
AI视觉网奇2 天前
BambuStudio 编译实战 2026
3d
AI前沿资讯2 天前
AI3D角色生产如何减少返工?用 V2Fun 前移建模与动画流程
人工智能·3d