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

相关推荐
njsgcs6 小时前
枪战游戏“棋盘化”价值建模 强化学习或rag
游戏
Candy 9179 小时前
内盒拼箱计算与3D可视化
3d·内盒拼箱计算与3d可视化
jiayong239 小时前
数字孪生 vs 虚拟仿真 vs 3D建模-技术选型指南
3d·数字孪生·虚拟仿真
calvinpaean10 小时前
Metric3D Towards Zero-shot Metric 3D Prediction from A Single Image 论文学习
学习·3d
前端不太难11 小时前
HarmonyOS 游戏里,主线程到底该干什么?
游戏·状态模式·harmonyos
CG_MAGIC12 小时前
Maya 关键帧动画基础:角色走路循环与姿态调整
3d·maya·效果图·建模教程·渲云渲染·渲云
远程软件小助理12 小时前
电脑玩手游哪个模拟器启动速度最快?MuMu、雷电、应用宝对比实测
游戏
云飞云共享云桌面13 小时前
SolidWorks如何实现多人共享
服务器·前端·数据库·人工智能·3d
开开心心_Every1 天前
家长控制电脑软件:定时锁屏管理使用时长
网络协议·tcp/ip·游戏·微信·pdf·excel·语音识别
云边散步1 天前
godot2D游戏教程系列二(3)
笔记·学习·游戏·游戏开发