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

相关推荐
AI浩6 小时前
基于运动对齐RGB与事件视觉线索的无标签长时序3D无人机轨迹预测
3d·无人机
运筹vivo@8 小时前
leetcode每日一题: 跳跃游戏 IV
leetcode·游戏·宽度优先
小宇的天下11 小时前
TSMC 3DXF 文件解析
3d
sheeta199811 小时前
LeetCode 每日一题笔记 日期:2026.05.18 题目:1345. 跳跃游戏 IV
笔记·leetcode·游戏
德迅云安全-小潘11 小时前
游戏行业面临的网络安全挑战
安全·web安全·游戏
游乐码13 小时前
Unity基础(一)游戏中的数学Mathf函数
游戏·unity·游戏引擎
2401_8638014613 小时前
逆向网格stl,fbx,obj格式等转换实体曲面stp,igs格式插件文件小,速度快工具
3d·stp
threelab14 小时前
潮玩DIY设计平台技术解析:基于Babylon.js的3D定制化实践
开发语言·javascript·3d
blackorbird1 天前
M4 MacBook Air外接RTX 5090实现3A游戏与AI加速
人工智能·游戏
Android出海1 天前
5月合规风暴眼:Google Play权限大限与欧盟游戏监管新棋局
人工智能·游戏·google play·谷歌开发者·android开发者·google开发者·google play开发者