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

相关推荐
摸鱼的春哥3 小时前
10年3次大失败,他从“罪人”输成了中年人的“白月光”
游戏
工业3D_大熊16 小时前
3D Web轻量引擎HOOPS赋能BIM/工程施工:实现超大模型的轻量化加载与高效浏览!
3d·3d web轻量化·3d模型可视化·3d渲染引擎·工业3d开发引擎·bim模型可视化
研梦非凡16 小时前
ICCV 2025|从粗到细:用于高效3D高斯溅射的可学习离散小波变换
人工智能·深度学习·学习·3d
1uther17 小时前
Unity核心概念⑨:Screen
开发语言·游戏·unity·c#·游戏引擎
2501_9181269118 小时前
用html5写一个flappybird游戏
css·游戏·html5
fanged1 天前
Cesium4--地形(OSGB到3DTiles)
3d·gis·web
桃花键神1 天前
从传统到智能:3D 建模流程的演进与 AI 趋势 —— 以 Blender 为例
人工智能·3d·blender
惊鸿.Jh1 天前
3227. 字符串元音游戏
游戏
东风西巷1 天前
全能的3D创作平台,Blender(免费开源3D建模工具)
学习·3d·开源·blender·软件需求
查里王2 天前
AI 3D 生成工具知识库:当前产品格局与测评总结
人工智能·3d