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

相关推荐
逻辑羊驼16 小时前
Hunyuan3D本地部署
3d
2501_9151063219 小时前
游戏上架 App Store 的技术流程解析 从构建到审核的全流程指南
游戏·macos·ios·小程序·uni-app·cocoa·iphone
LinkTime_Cloud1 天前
微软将《魔域》开源:47年经典游戏的重生与教育使命
游戏
福尔摩斯张1 天前
Axios源码深度解析:前端请求库设计精髓
c语言·开发语言·前端·数据结构·游戏·排序算法
2501_940094022 天前
山寨掌机 开源掌机游戏整合包 Emuelec整合包128G 一键导入整合游戏包
游戏·安卓·开源软件·软件
众趣科技2 天前
众趣科技:以空间数字孪生技术重构VR内容制作新生态
3d·vr·空间计算
LBuffer2 天前
DOS游戏水浒传
游戏·修改·解包
墨绿色的摆渡人2 天前
零碎的知识点(二十):3D 高斯为什么是椭球
决策树·机器学习·3d
catchadmin2 天前
使用 PHP 和 Raylib 也可以开发贪吃蛇游戏
开发语言·游戏·php