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

相关推荐
Lanren的编程日记18 分钟前
Flutter 鸿蒙应用游戏化元素实战:积分等级+成就解锁+排行榜,全方位提升用户粘性
flutter·游戏·华为·harmonyos
love530love2 小时前
FaceLift 单图 3D 人脸重建项目 Windows 11 完整部署指南
人工智能·windows·python·3d·facelift
IT观测15 小时前
创想三维携AI教育全矩阵亮相第87届教装展,构建3D打印教育新范式
人工智能·3d·矩阵
njsgcs19 小时前
让ai执行多轮行动可以把任务变成限定长度的操作,让ai填空,比如我3d模型可以参数化全部给ai,ai返回修改后完全的模型
人工智能·3d
superior tigre19 小时前
45 跳跃游戏2
算法·leetcode·游戏
CyL_Cly20 小时前
杀戮尖塔2mod:二次元猎宝
windows·游戏
cxr8281 天前
从细胞到蜂群:基于康威生命游戏原理的多智能体编排
游戏
小辉同志1 天前
45. 跳跃游戏 II
c++·leetcode·游戏·贪心算法
开开心心就好1 天前
避免借电脑尴尬的故障模拟工具
科技·游戏·visualstudio·edge·pdf·电脑·powerpoint
深念Y1 天前
王者荣耀与英雄联盟数值设计对比:穿透、乘算与加算、增伤乘算更厉害,减伤加算更厉害
数学·算法·游戏·建模·游戏策划·moba·数值