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

相关推荐
小二·2 小时前
从零手写《超级玛丽》——前端 Canvas 游戏开发与物理引擎
前端·游戏
da_vinci_x2 小时前
【2D场景】16:9秒变21:9?PS “液态缩放” + AI 补全,零成本适配全面屏
前端·人工智能·游戏·aigc·设计师·贴图·游戏美术
zl_vslam5 小时前
SLAM中的非线性优-3D图优化之相对位姿Between Factor位姿图优化(十三)
人工智能·算法·计算机视觉·3d
军军君017 小时前
Three.js基础功能学习五:雾与渲染目标
开发语言·前端·javascript·学习·3d·前端框架·three
资讯雷达7 小时前
工业扫描选型指南:蓝光 3D 扫描仪哪个品牌更靠谱?
3d
向宇it10 小时前
【unity游戏开发——网络】unity+PurrNet联机实战,实现一个多人对战类《CS/CSGO》《CF/穿越火线》《PUBG/吃鸡》的FPS射击游戏
游戏·unity·游戏引擎·交互·联机
2401_8414956412 小时前
【游戏开发】坦克大战
python·游戏·socket·pygame·tkinter·pyinstaller·坦克大战
顾安r12 小时前
1.1 脚本网页 战推棋
java·前端·游戏·html·virtualenv
lxysbly21 小时前
安卓玩MRP冒泡游戏:模拟器下载与使用方法
android·游戏
YAY_tyy1 天前
Turfjs+Three.js:地理数据的三维建模应用
前端·javascript·3d·arcgis·turfjs