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

相关推荐
学术小李18 小时前
3D Gaussian Splatting中梯度反传求偏导的推导
3d
蓝鲨硬科技19 小时前
任利锋的“造物”野心,让AI 3D进入“可制造”时代
人工智能·3d·制造
noipp2 天前
推荐题目:洛谷 P5843 [SCOI2012] Blinker 的噩梦
c语言·数据结构·c++·算法·游戏·洛谷·luogu
日月云棠2 天前
UE5 Lyra Messages 模块深度解析——从一条击杀消息看游戏事件系统的设计哲学
游戏·ue5
Ivan CloudBay2 天前
SDK 游戏盾如何隐藏游戏服务器的真实 IP?
服务器·tcp/ip·游戏
魔术师Dix2 天前
StartGame:Unity TDD 外部工程指南
学习·游戏·unity·c#·测试驱动开发
cxoptics2 天前
3D电影用的偏振眼镜原理是什么?
3d
我才是银古2 天前
OpenCSG.NET:一个 .NET CSG 几何建模库的技术剖析
3d·dwg·csg
我要见SA姐12 天前
AI提示词遇见精密算法:TimeGuessr如何用数学魔法打造文化游戏新体验
人工智能·算法·游戏