Unity 在特定秒数内将对象移动到一个点(变换) [英] Unity move an object to a point(transform) within a certain number of seconds

查看:57
本文介绍了Unity 在特定秒数内将对象移动到一个点(变换)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让对象在几秒钟内改变它的位置.例如,它将到达"5 秒内的一个点.

I want to make the object change its position in a few seconds. For example, it will "reach" a point within 5 seconds.

选择一个位置并在固定的时间内到达.有可能的?有功能吗?

Choose a position and reach it within a fixed number of time. It is possible? Does it have a function?

后例.我的对象在 (10f, 10f, 0) 我希望他在 2 秒内到达 (20f, 10f, 0).

Lat example. My object is in (10f, 10f, 0) I want him to reach (20f, 10f, 0) in 2 seconds.

有可能吗?

更新:从头开始,例如它称为glide 10, 78. secs to 3";- 在 3 秒内移动到 10X、78Y

Update: in scratch, for example it called "glide 10, 78. secs to 3" - moving to 10X, 78Y in 3 seconds

推荐答案

除非您已经 90 岁,否则只需使用 tweeng.

Unless you're 90 years old, just use a tweeng.

就是这么简单

StartCoroutine(5f.Tweeng( (p)=>transform.position=p,
  startHere,
  endHere) );

它在 5 秒内从 startHereendHere.

it goes from startHere to endHere in 5 seconds.

仅此而已.

tweeng 扩展只有几行代码,例如:https://stackoverflow.com/a/372​​28628/294884

A tweeng extension is only a few lines of code, example: https://stackoverflow.com/a/37228628/294884

您可以使用补间、淡化音量、扭曲对象、设置文字大小动画、淡化图像等任何.

You can do anything with a tweeng, fade volume, twist objects, animate the size of type, fade images, whatever.

您将参与的每个大型项目都已经使用了 tweeng.再简单不过了.

Every single large project you'll ever work on, they already use tweeng. It couldn't be simpler.

这篇关于Unity 在特定秒数内将对象移动到一个点(变换)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆