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

相关推荐
humors22113 小时前
支付宝游戏频道《灵画师》体验
游戏·介绍·体验·攻略·灵画师·试玩
云飞云共享云桌面14 小时前
广东精密机械设备工厂8-10人共享一台SolidWorks设计服务器
运维·服务器·3d·自动化·汽车·制造
HMS Core16 小时前
基于人体骨骼点识别与跟踪,实现低时延体感游戏
游戏·华为·harmonyos
AI视觉网奇17 小时前
bambu-studio-ai 踩坑实战笔记
人工智能·3d
MagicUrban20 小时前
经纬管网MagicPipe3D V3.8.1发布,参数化自主可控三维管线建模工具
3d·gis·智慧城市·bim·地下管网
LONGZETECH21 小时前
传统实训 vs 仿真实训:从技术架构拆解新能源汽车教学的范式之变
c语言·3d·unity·架构·汽车
科技之门1 天前
AI3D从建模到贴图、绑骨和动画的完整流程怎么做?V2Fun完整工作流指南
人工智能·3d·贴图
AI分享猿1 天前
游戏原画与建筑灵感:AI图像生成如何服务前期设计
人工智能·游戏
饺子大魔王的男人2 天前
NAS还能挂机修仙?极空间部署XiuXianGame网页游戏教程
游戏
dalong102 天前
WPF:3D甜甜圈
3d·c#·wpf·甜甜圈