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 天前
【Spring Boot开发实战手册】掌握Springboot开发技巧和窍门(六)创建菜单和游戏界面(下)
java·spring boot·游戏
视觉人机器视觉1 天前
海康机器人3D 机器人引导 —— 空间基础篇一
3d·机器人
程序员林北北1 天前
【前端进阶之旅】Vue3 + Three.js 实战:从零构建交互式 3D 立方体场景
前端·javascript·vue.js·react.js·3d·typescript
月下雨(Moonlit Rain)1 天前
宇宙飞船游戏项目
python·游戏·pygame
海天一色y1 天前
使用 Python + Tkinter 打造“猫狗大战“回合制策略游戏
开发语言·python·游戏
deep_drink2 天前
【论文精读(三)】PointMLP:大道至简,无需卷积与注意力的纯MLP点云网络 (ICLR 2022)
人工智能·pytorch·python·深度学习·3d·point cloud
新缸中之脑2 天前
Tripo AI:构建游戏就绪的3D资产
人工智能·游戏·3d
小贺儿开发2 天前
Unity3D 文物互动大屏
3d·unity·实时互动·udp·socket·网络通信
henry1010103 天前
DeepSeek生成的网页小游戏 - 迷你高尔夫
前端·javascript·游戏·html
yunteng5213 天前
休闲回合制游戏架构相关技术实现
游戏·架构·dau·技术实现·休闲回合