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

相关推荐
TAICHIFEI2 小时前
光片显微镜海量3D图像重建/拼接软件全分类
3d·分类·数据挖掘
_张一凡7 小时前
【论文解读】一篇读懂LAWM-3D:从 DreamDojo 的 2D 潜动作到 3D 感知,关键不是加多视角而是三道防泄漏设计
3d·具身智能·世界模型
河南花仙子科技18 小时前
花仙子科技干货分享|游戏制作技术演进历程与未来展望
科技·游戏
ownkss1 天前
游戏公会联运怎么做:步骤、指标与复盘重点
游戏·游戏发行·游戏运营·游戏分发
xcLeigh1 天前
Unity基础:C#脚本的创建与挂载——让你的游戏物体活起来
游戏·unity·c#·教程
达子6661 天前
第30章_综合案例:HarmonyOs开发图解之 俄罗斯方块游戏
游戏·华为·harmonyos
huangns1 天前
汽车座椅、脚垫3D扫描数字化打版怎么做,需要哪些设备?
3d
云飞云共享云桌面1 天前
非标装备厂降本方案|8‑10 人三维研发共用一台主机,兼容SolidWorks等多款 3D 绘图软件
运维·服务器·3d·自动化·负载均衡·制造
nujnewnehc1 天前
游戏辅助后续之yolo
游戏·游戏开发