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

相关推荐
coder攻城狮26 分钟前
VTK系列1:在屏幕绘制多边形
c++·3d
一起养小猫1 小时前
Flutter for OpenHarmony 实战:记忆棋游戏完整开发指南
flutter·游戏·harmonyos
程序猿阿伟1 小时前
《游戏AI训练模拟环境:高保真可加速构建实战指南》
人工智能·游戏
PHOSKEY3 小时前
3D工业相机如何“读透”每一个字符?快速识别、高精度3D测量
数码相机·3d
XX風6 小时前
7.2 harris 3d
3d
多恩Stone6 小时前
【3D-AICG 系列-3】Trellis 2 的O-voxel (下) Material: Volumetric Surface Attributes
人工智能·3d·aigc
多恩Stone6 小时前
【3D-AICG 系列-1】Trellis v1 和 Trellis v2 的区别和改进
人工智能·pytorch·python·算法·3d·aigc
三年模拟五年烧烤6 小时前
easy-threesdk快速一键搭建threejs3d可视化场景
3d·threejs
前端不太难6 小时前
HarmonyOS 游戏中,被“允许”的异常
游戏·状态模式·harmonyos
top_designer6 小时前
Materialize:手绘地表太假?“PBR 纹理炼金术” 5分钟生成次世代材质
游戏·3d·aigc·材质·设计师·游戏美术·pbr