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

相关推荐
AA陈超4 小时前
虚幻引擎5 GAS开发俯视角RPG游戏 P07-19.发送鼠标光标数据
c++·笔记·学习·游戏·ue5·虚幻引擎
毕设源码-钟学长9 小时前
【开题答辩全过程】以 基于Vue NodeJs的在线游戏平台的设计与实现为例,包含答辩的问题和答案
游戏
"YOUDIG"9 小时前
从算法到3D美学——一站式生成个性化手办风格照片
算法·3d
sbjdhjd1 天前
开源分享 | 超浪漫 3D 圣诞树立体动画(附零基础使用教程)
3d·青少年编程·开源·html·节日
lrh30251 天前
Custom SRP - 16 Render Scale
3d·unity·srp·render pipeline·render scale
wanhengidc1 天前
巨椰 云手机 云游戏稳定运行
运维·服务器·arm开发·游戏·云计算
毕安格 - BimAngle1 天前
Revit 模型一键输出 3D Tiles (for Cesium) 和 glTF/glb
3d·cesium·gltf·glb·3d tiles
_大学牲1 天前
Flutter 勇闯2D像素游戏之路(四):与哥布林战斗的滑步魔法师
flutter·游戏·游戏开发
map_vis_3d1 天前
JSAPIThree 加载 3D Tiles 学习笔记:大规模三维场景渲染
笔记·学习·3d
da_vinci_x1 天前
Substance 3D Painter 进阶:手绘“掉漆”太累?用 Anchor Point 让材质“活”过来
游戏·3d·aigc·材质·设计师·技术美术·游戏美术