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

相关推荐
视觉人机器视觉18 小时前
3D机器视觉中,3D 点云是什么,为什么点云有洞洞?原因分成 5 大类
3d
Martina_032118 小时前
AI生成3D场景导入 Unity/Unreal 后,NPC 总串层?用6步检查导航高度与跨层连接
人工智能·游戏·数学建模·3d·unity·自然语言处理·aigc
HwJack2018 小时前
【共创稿事节】HarmonyOS 7文旅展陈展厅大空间 3DGS 重建的分块策略与拼接踩坑
3d·华为·harmonyos
Nil20818 小时前
leetcode 55跳跃游戏
算法·leetcode·游戏
西红柿炖牛腩35420 小时前
GLB 转 OBJ/PLY 后体积没变?3D 模型不减面变小靠什么
前端·javascript·3d
特视界说20 小时前
没有完整 3D 模型,能做产品三维动画吗?
3d·微信·音视频·新浪微博
Nil20821 小时前
leetcode 45跳跃游戏Ⅱ
算法·leetcode·游戏
外收内放2 天前
Python基础语法练习题(拓展1)
python·游戏
Martina_03212 天前
AI生成的过山车轨道导入后频繁脱轨?用5步检查样条、轨距与碰撞
图像处理·人工智能·游戏·3d·材质·游戏策划·关卡设计
Martina_03212 天前
AI生成的模块场景一烘焙就有黑边?用6步检查Lightmap UV、纹素密度与Padding
人工智能·游戏·3d·aigc·uv·游戏策划·关卡设计