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

相关推荐
大势智慧21 分钟前
DasViewer 4.0 重磅发布,全面增强3DGS处理能力
3d·渲染·应用·效率·实景三维·高斯·成果
世洋Blog26 分钟前
Unity性能优化-2d游戏的DrawCall
游戏·unity·面试·性能优化·游戏引擎
YAY_tyy28 分钟前
基于矩形区域的相机自动定位与飞行控制实现
前端·javascript·3d·cesium
呆呆敲代码的小Y33 分钟前
【Unity 实用工具篇】 | Unity中的软遮罩组件 SoftMaskForUGUI 快速上手使用
游戏·unity·游戏引擎·免费游戏·遮罩·软遮罩·softmask
思茂信息2 小时前
CST软件对Customer Success OPPO手机电源适配器EMC仿真
开发语言·嵌入式硬件·matlab·3d·智能手机·cst
Ayanami_Reii12 小时前
进阶数学算法-取石子游戏(ZJOI2009)
数学·算法·游戏·动态规划·区间dp·博弈论
caron415 小时前
C++ 推箱子游戏
开发语言·c++·游戏
顾安r15 小时前
11.29 脚本游戏 单页面格斗游戏模板
前端·javascript·css·游戏·virtualenv
reddingtons16 小时前
Illustrator 3D Mockup:零建模,矢量包装一键“上架”实拍
人工智能·ui·3d·aigc·illustrator·设计师·平面设计
远瞻。21 小时前
【环境配置】【bug调试】pytorch3d 安装
人工智能·pytorch·3d·调试