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

相关推荐
渔民小镇17 小时前
4 行代码接入 Spring —— ionet 的生态融合之道
java·服务器·分布式·游戏
上海云盾-小余20 小时前
游戏业务接口防护:防爬虫、防刷量、防恶意请求一体化方案
爬虫·游戏
小三金21 小时前
免费的国外模型资源网站整理
3d
装杯让你飞起来啊2 天前
混合练习 —— 猜数字游戏
windows·游戏·kotlin
前端不太难2 天前
鸿蒙游戏 CI/CD:为什么你还在手动打包?
游戏·ci/cd·harmonyos
AI_Auto2 天前
【智能制造】- 工业制造中的3D视觉四大核应用场景
3d·制造
开开心心就好2 天前
自动分类存储PPT素材的实用工具
科技·游戏·智能手机·电脑·powerpoint·sublime text·phpstorm
la_vie_est_belle2 天前
Pygame Studio——用Python自制的一款可视化游戏编辑器
python·游戏·编辑器·游戏引擎·pygame·pyside6·pygame-ce
ZC跨境爬虫2 天前
跟着 MDN 学 HTML day_16:(音频与视频处理——从画布滤镜到3D沉浸音频的进阶指南)
前端·javascript·ui·3d·html·音视频
夜猫逐梦2 天前
【逆向经验】一篇文章讲透为什么CE搜不到Python游戏的内存值
开发语言·python·游戏