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

相关推荐
敢敢のwings8 小时前
世界模型与FlashWorld:从“在梦中学习“到秒级3D场景生成
android·学习·3d
tanghonghanhaoli11 小时前
【图书翻译】有意义的游戏设计:桌面游戏的方法论与心理学(第4章)
游戏
Behaviour12 小时前
Unity游戏之Jenkins的安装部署应用
游戏·unity·jenkins
tanghonghanhaoli13 小时前
【图书翻译】有意义的游戏设计:桌面游戏的方法论与心理学(第3章)
游戏
雾沉川1 天前
d3dx9_43.dll 丢失报错原因分析及三种标准修复方法
microsoft·3d
alansoulKing1 天前
CS1.5 新手入门与联机部署全攻略
游戏·电脑·娱乐
tanghonghanhaoli1 天前
【图书翻译】有意义的游戏设计:桌面游戏的方法论与心理学(第1、2章)
前端·游戏·ui
我是苏苏1 天前
Steam游戏:如何回退到旧版本下载(技术帖)
游戏
蓝速科技1 天前
蓝速科技圆柱形 3D 全息舱全天候值守实战指南
科技·3d