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

相关推荐
远程软件小助理12 小时前
ToDesk节点繁忙、向日葵免费试用受限,还有什么免费好用的远程软件推荐?
经验分享·游戏·远程工作
程序员极光12 小时前
第六篇,如何用高德地图获取定位!
3d·高德
德迅--文琪13 小时前
游戏盾筑牢网络游戏防攻击安全防线
安全·游戏
Rauser Mack15 小时前
不懂编程,但是vibe coding一个扫雷游戏
人工智能·python·游戏·html·prompt
Thomas_YXQ16 小时前
Unity3D Addressable 深度优化热更性能消耗
开发语言·3d·unity·微信
七77.16 小时前
【3D 场景生成】NuiScene: Exploring Efficient Generation of Unbounded Outdoor Scenes
3d·世界模型
threelab17 小时前
Three.js 几何图形变换 | 三维可视化 / AI 提示词
开发语言·前端·javascript·人工智能·3d·着色器
xian_wwq17 小时前
【学习笔记】倾斜摄影、高斯泼溅(3DGS)、点云与数字孪生“族谱”全盘点
笔记·学习·3d
AI视觉网奇18 小时前
stl转glb glb缩放
开发语言·3d
七77.18 小时前
【3D 场景生成】WorldGen: From Text to Traversable and Interactive 3D Worlds
3d·世界模型