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

相关推荐
Johnstons13 小时前
游戏网络测试怎么做?从延迟到丢包,一套完整的游戏弱网测试方案
网络·游戏·php
2023自学中18 小时前
imx6ull 开发板, mame 模拟器,运行游戏 测试
linux·游戏·嵌入式·开发板
蓝速科技18 小时前
蓝速科技 3D 全息舱 AI 数字人博物馆导览效果实录
人工智能·科技·3d
专业技术员!!!!1 天前
游戏代练平台怎么开发?Uni+PHP多端代练系统|适配三角洲+王者代练
游戏
chaoyuanl1 天前
沉浸式飞行影院进场安装前期筹备事项
大数据·科技·3d·xr·娱乐
FL16238631293 天前
Apex检测数据集Apex Legend游戏敌友方检测数据集VOC+YOLO格式5671张3类别
yolo·游戏·机器学习
金銀銅鐵7 天前
[Python] 模 n 乘法的逆元计算器
python·数学·游戏
金銀銅鐵8 天前
借助 Pygame 探索最大公约数的规律
python·数学·游戏
nujnewnehc12 天前
不会 py, 用 ai 写了个游戏辅助的感受
人工智能·游戏
jump_jump13 天前
为了重玩金庸群侠传,我研究了一下 Ruffle 怎么复活 Flash
游戏·rust·github