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

相关推荐
金銀銅鐵4 小时前
[Python] 用 turtle 来绘制国际象棋棋盘(不含棋子)
python·游戏
Python私教7 小时前
Godot怎么下载和安装?零基础完成第一次启动
人工智能·游戏·godot
3D小将7 小时前
3D格式转换之Rhino(Rhinoceros)转 CATIA 标准化转换技术
3d·solidworks模型·ug模型·rhino模型·catia模型
FairGuard手游加固20 小时前
2026年7月份国产游戏审批信息
游戏
星空露珠1 天前
28种颜色对应名称,
开发语言·数据库·算法·游戏·lua
中国搜索直付通1 天前
棋牌游戏支付与防沉迷:二级商户如何构建“免疫系统”
游戏
2601_962924761 天前
遗忘之海手游战术家怎么玩 遗忘之海手游战术家玩法攻略
游戏
雅客李1 天前
2026年第三季度云手机实测 游戏多开挂机托管三维度数据公开
游戏·智能手机
爱吃程序猿的喵1 天前
LingBot-Map 复现与原理剖析:基于 Geometric Context Transformer 的流式 3D 重建
人工智能·python·深度学习·计算机视觉·3d·transformer