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

相关推荐
小贺儿开发14 小时前
DeepSeek + Codex + MCP:Unity 游戏开发实测
科技·游戏·unity·ai·程序员·编程·deepseek
派森诺生物14 小时前
Cell首篇棉花研究:3D基因组破解纤维品质密码
3d·cell·派森诺·棉花育种
慧都CAD开发笔记15 小时前
客户只改了一个位置,报价团队为什么要把整个模型重新看一遍?SpinFire Insight CAD模型对比
3d·制造
慧都CAD开发笔记1 天前
3D InterOp读取STEP模型:能显示,为什么一划分网格就失败?
3d
xcLeigh1 天前
Unity基础:Instantiate实例化——在运行时动态创建游戏物体
游戏·unity·游戏引擎·教程·instantiate
Shirley~~1 天前
three.js的调试面板工具
前端·3d
棉猴1 天前
玩游戏学Python2-IDLE与pgzero入门
开发语言·python·游戏·玩游戏·pgzero·pgzrun
河南花仙子科技1 天前
加油站小游戏营销拓客新方案
游戏·拓客
云飞云共享云桌面2 天前
智能装备数字化转型:云飞云云桌面助力苏州工厂共享 SolidWorks 算力
运维·服务器·3d·自动化·制造
Zldaisy3d2 天前
哈工大黄永江课题组 l 多元素原位合金化调控增材制造TC4多尺度组织
3d·制造