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

相关推荐
学無芷境1 小时前
vesselFM: A Foundation Model for Universal 3D Blood Vessel Segmentation
3d
上海云盾-小余2 小时前
im即时通讯被攻击使用游戏盾高防方案有效解决
网络·网络协议·web安全·游戏·金融·ddos
电报号dapp11914 小时前
钱包开发:在虚无中为数字自我筑巢
游戏·去中心化·区块链·智能合约
CG_MAGIC15 小时前
云渲染时能否关机或断网?
3d·云渲染·建模教程·渲云渲染·3d软件
zhangx1234_15 小时前
C语言 扫雷游戏
游戏
拾荒的小海螺16 小时前
开源项目:Three.js 构建 3D 世界的工具库
javascript·3d·开源
gihigo19981 天前
使用MATLAB绘制3D心形图和玫瑰花图案
开发语言·matlab·3d
呆呆敲代码的小Y1 天前
【Unity实战篇】| 游戏轮播图效果,多种实现思路及完整教程
游戏·unity·游戏引擎·实战·游戏开发·轮播图·u3d
zl_vslam1 天前
SLAM中的非线性优-3D图优化之地平面约束(十五)
人工智能·算法·计算机视觉·3d
STCNXPARM1 天前
Android14显示系统 - 开源图形库Mesa3d
3d·开源·mesa3d·android图形库·opengl-es