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

相关推荐
tokenKe12 小时前
Epic Games 发布下一代版本控制系统 Lore:被 HN 干到 1000+ 分的“游戏版 Git“
git·游戏
苏州邦恩精密16 小时前
蔡司3D扫描仪采购要点及厂家服务能力分析
人工智能·科技·3d·自动化·汽车
small-pudding18 小时前
3D 麻将贴图开启 Mipmaps 后远处边缘发黑,关闭后又发白,为什么?
3d·贴图
云空18 小时前
《Three.js 完整版3D魔方:带贴纸+中心固定+自动求解复原》
前端·javascript·3d·three.js
中国搜索直付通18 小时前
避开直付通选型暗礁:二级商户的合规生存与背景甄别
java·大数据·开发语言·人工智能·游戏
云空19 小时前
《Three.js 可操控3D魔方(键盘转动+打乱+复原)》
javascript·学习·游戏·3d·three.js
方向研究19 小时前
金融游戏的训练价值
人工智能·游戏·金融
facaixxx202419 小时前
雨云游戏服务器MCSM面板指南:低延迟BGP线路(一键开服)
运维·服务器·游戏
快乐星空Maker1 天前
C++【生存游戏】开发:荒岛往事 第二期
游戏
LJHclasstore_luo1 天前
【GoC游戏】等(wait)1.0.0版本
游戏·goc编程