当前位置: 首页 > news >正文

Unity动画系统(2)

6.1 动画系统基础2-3_哔哩哔哩_bilibili

p316

模型添加Animator组件

动画控制器

AnimatorController

AnimatorController

可以通过代码控制动画速度

建立动画间的联系

bool值的设定

trigger

p318

trigger点击的时候触发,如喊叫,开枪及换子弹等,执行完成后自动回复原状态

通过代码调整动画播放速度

动画播放速度与某一个参数关联到一起

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EthanController : MonoBehaviour
{
    private Animator ani;
    private void Awake()
    {
        ani = GetComponent<Animator>();
    }

    private void Update()
    {
        动画参数名称可以转换为一个ID【int】
        //int id = Animator.StringToHash("CanMove");
        //Debug.Log("ID"+id);
        设置后读取动画参数
        //ani.SetBool("CanMove",true);
        [使用HashID进行参数的设置或读取,效率更高]
        //ani.SetBool(id, true);

        //ani.SetFloat
        //ani.GetFloat
        //ani.SetInteger
        //ani.GetInteger
        //ani.SetTrigger
        //ani.SetTrigger [触发参数]

        ani.SetFloat("ShoutPlaySpeed", 2);
        ani.SetFloat("ShoutPlaySpeed",2,0.5f,Time.deltaTime);

        //按下方向键左键
        if (Input.GetKeyDown(KeyCode.LeftArrow)) {
            ani.SetBool("CanMove", true);
        }

        if (Input.GetKeyDown(KeyCode.RightArrow)) {
            ani.SetBool("CanMove", false);
        }

        if (Input.GetKeyDown(KeyCode.Space)) {
            ani.SetTrigger("Shout");
        }
        if (Input.GetKey(KeyCode.S)) {
            //设置喊叫动画的播放速度,有0.5s过渡时间
            ani.SetFloat("ShoutPlaySpeed",2,0.5f,Time.deltaTime);
        }
    }
}
 

http://www.lryc.cn/news/394156.html

相关文章:

  • 深度网络现代实践 - 深度前馈网络之反向传播和其他的微分算法篇
  • 自动化设备上位机设计 四
  • [leetcode hot 150]第二十三题,合并K个升序链表
  • MybatisPlus实现插入/修改数据自动设置时间
  • Java语言程序设计篇一
  • Calicoctl工具学习 —— 筑梦之路
  • Wormhole Filters: Caching Your Hash on Persistent Memory——泛读笔记
  • PyTorch学习之torch.transpose函数
  • Git仓库介绍
  • 人工智能笔记分享
  • 秋招提前批面试经验分享(上)
  • [AIGC] ClickHouse的表引擎介绍
  • 关于新装Centos7无法使用yum下载的解决办法
  • OpenEarthMap:全球高分辨率土地覆盖制图的基准数据集(开源来下载!!!)
  • 工作助手VB开发笔记(1)
  • WAWA鱼曲折的大学四年回忆录
  • Go 依赖注入设计模式
  • 使用React复刻ThreeJS官网示例——keyframes动画
  • 嵌入式linux面试1
  • 智能交通(3)——Learning Phase Competition for Traffic Signal Control
  • 【扩散模型】LCM LoRA:一个通用的Stable Diffusion加速模块
  • 【PYG】pytorch中size和shape有什么不同
  • 备份服务器出错怎么办?
  • 数据库(表)
  • Feign-未完成
  • # [0705] Task06 DDPG 算法、PPO 算法、SAC 算法【理论 only】
  • Open3D 点云CPD算法配准(粗配准)
  • 04-ArcGIS For JavaScript的可视域分析功能
  • Nestjs基础
  • DDL:针对于数据库、数据表、数据字段的操作