当前位置:网站首页>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
边栏推荐
- Anonymous implementation class object of interface
- 在生产环境中每天Oracle监控到的无效对象一般怎么去处理?
- boost官网搜索引擎项目详解
- Byte side: how to realize reliable transmission with UDP?
- Service Workers让网站动态加载Webp图片
- 14、用户web层服务(二)
- 业务可视化-让你的流程图'Run'起来(4.实际业务场景测试)
- MySQL离线同步到odps的时候 可以配置动态分区吗
- Understand how to prevent tampering and hijacking of device fingerprints
- 「以云为核,无感极速」第五代验证码重磅来袭
猜你喜欢
![[applet] how to notify users of wechat applet version update?](/img/04/848a3d2932e0dc73adb6683c4dca7a.png)
[applet] how to notify users of wechat applet version update?

Redis installation

Redis安装

Cvpr2020 best paper: unsupervised learning of symmetric deformable 3D objects

中国业务型CDP白皮书 | 爱分析报告

Router firmware decryption idea

15、用户web层服务(三)

A new mode of one-stop fixed asset management

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

LabVIEW AI visual Toolkit (non Ni vision) download and installation tutorial
随机推荐
一些多参数函数的具体作用
Shell (I)
Consumer installation and configuration
301. Delete invalid brackets
Flash point list of cross platform efficiency software
Today's sleep quality record 74 points
Business visualization - make your flowchart'run'(4. Actual business scenario test)
How to deal with invalid objects monitored by Oracle every day in the production environment?
Summary of common RSA related problems in CTF: basic RSA encryption and decryption
在生产环境中每天Oracle监控到的无效对象一般怎么去处理?
js代码如何被浏览器引擎编译执行的?
Good use explosion! The idea version of postman has been released, and its functions are really powerful
可视化大型时间序列的技巧。
Article summary of MinGW installation and use
Static proxy instance
Detailed explanation of boost official website search engine project
async await如何实现并发
Excel shortcut keys (letters + numbers) Encyclopedia
Open source huizhichuang future | 2022 open atom global open source summit openatom openeuler sub forum was successfully held
Full version of H5 social chat platform source code [complete database + complete document tutorial]