当前位置:网站首页>Untiy中控制Animation的播放速度
Untiy中控制Animation的播放速度
2022-07-28 11:16:00 【漫步云巅】
Unity组件里面的Animation是可以控制播放速度的,通过调整AnimationState的speed属性即可更改某个动画的速度。
在实际需求中,可以通过改变动画速度来更快地打开一个奖励或者过场等等,这样可以让用户减少等待时间,提升体验感。
官方也给出了相关的控制接口
https://docs.unity3d.com/ScriptReference/Animation.html
speed=1为缺省速度,大于1为加速,可以按照实际来改变速度。
anim = GetComponent<Animation>();
foreach (AnimationState state in anim)
{
state.speed = 0.5F;
}或者控制某个单独的
public void SetAnimationSpeed(Animation ani, string name, float speed)
{
if (null == ani) return;
AnimationState state = ani[name];
if (!state) state.speed = speed;
}修改Animator的播放速度会影响整个状态机的速度
public void SetAnimatorSpeed(Animator animator, float speed)
{
if (null == animator) return;
animator.speed = speed;
}一般不要这样改,直接改clip的速度,或者改状态机中state的速度

在lua中写这样的接口:
注意到,获取AnimationState的属性

提供了一个get属性的this字段,利用这个字段可以改变速度:
function SetAnimationSpeed(animation, name, speed)
if animation == nil then return end
local state = animation.this:get(name)
if state then state.speed = speed end
end
边栏推荐
- 一些多参数函数的具体作用
- What is the process of switching c read / write files from user mode to kernel mode?
- 哪位大神帮看下 oracle number类型解析 怎么搞 Struct{scale=15,val
- Solutions to slow start of MATLAB
- DNS series (III): how to avoid DNS spoofing
- R language uses oneway The test function performs one-way ANOVA
- Object to object mapping -automapper
- [collection] Advanced Mathematics: Capriccio of stars
- Update dev (development version) of the latest win11
- LabVIEW AI视觉工具包(非NI Vision)下载与安装教程
猜你喜欢

Redis安装

Leecode8 string conversion integer (ATOI)

15. User web layer services (III)

LabVIEW AI visual Toolkit (non Ni vision) download and installation tutorial

108. Introduction to the usage of SAP ui5 image display control Avatar

14. User web layer services (II)

Ripro9.0 revised and upgraded version +wp two beautification packages + rare plug-ins

The fifth generation verification code of "cloud centered, insensitive and extremely fast" is coming heavily

Zotero document manager and its use posture (updated from time to time)

直接插入排序与希尔排序
随机推荐
R language ggplot2 visualization: use the ggboxplot function of ggpubr package to visualize the box diagram and customize the fill parameter to configure the filling color of the box
AlexNet—论文分析及复现
Solutions to slow start of MATLAB
The reflect mechanism obtains the attribute and method information of class
LabVIEW AI visual Toolkit (non Ni vision) download and installation tutorial
[geek challenge 2019] babysql-1 | SQL injection
Understand how to prevent tampering and hijacking of device fingerprints
Blackboard cleaning effect shows H5 source code + very romantic / BGM attached
AlexNet—论文分析及复现
简单选择排序与堆排序
Flash point list of cross platform efficiency software
Unity鼠标带动物体运动的三种方法
MySQL离线同步到odps的时候 可以配置动态分区吗
Know the optical fiber interface and supporting optical fiber cable of can optical fiber converter in fire alarm networking
Embrace open source guidelines
Develop your own NPM package from 0
Design a system that supports millions of users
R language - some metrics for unbalanced data sets
How async await implements concurrency
Start from scratch blazor server (2) -- consolidate databases