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

相关推荐
装杯让你飞起来啊1 天前
混合练习 —— 猜数字游戏
windows·游戏·kotlin
前端不太难1 天前
鸿蒙游戏 CI/CD:为什么你还在手动打包?
游戏·ci/cd·harmonyos
AI_Auto1 天前
【智能制造】- 工业制造中的3D视觉四大核应用场景
3d·制造
开开心心就好1 天前
自动分类存储PPT素材的实用工具
科技·游戏·智能手机·电脑·powerpoint·sublime text·phpstorm
la_vie_est_belle1 天前
Pygame Studio——用Python自制的一款可视化游戏编辑器
python·游戏·编辑器·游戏引擎·pygame·pyside6·pygame-ce
ZC跨境爬虫1 天前
跟着 MDN 学 HTML day_16:(音频与视频处理——从画布滤镜到3D沉浸音频的进阶指南)
前端·javascript·ui·3d·html·音视频
夜猫逐梦2 天前
【逆向经验】一篇文章讲透为什么CE搜不到Python游戏的内存值
开发语言·python·游戏
小熊Coding2 天前
童年游戏冒险岛(Python版本)
python·游戏·pygame
aaaffaewrerewrwer2 天前
2048Merge:在线畅玩的经典2048数字合并游戏,无需下载即点即玩
安全·游戏·个人开发
晴夏。2 天前
unlua实现原理
游戏·ue5·ue4·lua·ue·unlua