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

相关推荐
上海云盾第一敬业销售15 分钟前
深入了解游戏盾:安全架构解析
安全·游戏·安全架构
da_vinci_x1 小时前
PS 3D Viewer + AI 生成:灰盒(Greybox)一键变“3A”概念图
人工智能·游戏·数学建模·3d·prompt·aigc·游戏美术
国服第二切图仔1 小时前
Electron for 鸿蒙PC项目实战案例之记忆卡片游戏
游戏·electron·harmonyos·鸿蒙pc
技术小甜甜1 小时前
[Godot游戏开发] 安卓平台游戏如何设置窗口与分辨率:Viewport、Window Override与自适应窗口解析
android·游戏·godot
苏州知芯传感14 小时前
环境智能的触角:MEMS微振镜赋能分布式光纤传感网络
网络·分布式·3d·mems·激光·微振镜
PA_17 小时前
unity Component-Based Architecture游戏框架
游戏·unity·游戏引擎
Stark-C19 小时前
『真·扩容』将游戏和软件安装到NAS,极空间iSCSI功能初体验
游戏
Minecraft红客19 小时前
复原大唐3d更新版本
c++·游戏·3d·娱乐
YAY_tyy19 小时前
详解 3D Tiles 核心入口文件:tileset.json 结构与实战解析
3d·json·3dtiles
weixin_505154461 天前
在浏览器实现3D效果,有最优雅的解决方案吗?
人工智能·3d·数字孪生·3d产品配置器·3d交互展示·3d数字资产