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

相关推荐
陈天伟教授3 小时前
图解人工智能(60)人工智能应用-AI游戏
人工智能·游戏
魔士于安3 小时前
Shader forge技术美术专用
游戏·unity·游戏引擎·贴图·技术美术·模型
Y学院5 小时前
C#游戏脚本开发全流程(Unity通用完整版)
游戏·unity·c#
私人珍藏库6 小时前
[Android] 三维山水全景地图-3D地形全景观测地图
android·3d·app·工具·软件·多功能
yyuuuzz7 小时前
游戏云服务器推荐的技术选择思路
大数据·运维·服务器·游戏·云计算·aws
xinhuanjieyi1 天前
html修复游戏种太阳错误
前端·游戏·html
魔士于安1 天前
unity 音乐会场景 unity2022
游戏·unity·游戏引擎·贴图·模型
码来的小朋友1 天前
[python] 我开发了一个有20个关卡随机地图的迷宫游戏
python·游戏·pygame
不羁的木木1 天前
《HarmonyOS 6.1 新能力实战之智感握姿》第四篇:进阶应用——横屏游戏手柄模式
游戏·华为·harmonyos
Swift社区1 天前
鸿蒙游戏Runtime解析:Store如何驱动整个游戏世界?
游戏·华为·harmonyos