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

相关推荐
Hello123网站1 天前
h5游戏免费下载:一起蛙蛙跳
游戏
鼓掌MVP1 天前
图生3D技术解析:从二维平面到立体世界的智能飞跃
平面·3d
@sinner1 天前
《扫雷:病毒蔓延》- 颠覆传统的动态扫雷游戏
python·游戏·pygame
2501_929382651 天前
王国保卫战全集下载 1~5部全系列MOD DLC修版 安卓+ios+PC电脑版
游戏·ios·智能手机·iphone·玩游戏·单机游戏·安卓游戏
Hello123网站1 天前
h5游戏免费下载:街头篮球
游戏
Pu_Nine_92 天前
教程: 在网页中利用原生CSS实现3D旋转动画
css·3d·css3
wanhengidc2 天前
什么是站群服务器
运维·服务器·网络·游戏·智能手机
ZTLJQ2 天前
植物大战僵尸HTML5游戏完整实现教程
前端·游戏·html5
特立独行的猫a2 天前
HarmonyOS鸿蒙中的NES游戏模拟器的完整实现
游戏·华为·harmonyos·fc·nes