简体   繁体   English

如何使用Lerp缓慢旋转球形?

[英]How to slowly rotate spherical shapes using Lerp?

I need to slowly rotate spherical shapes which are placed on waypoints. 我需要缓慢旋转放置在航点上的球形。 It needs to rotate slowly. 它需要缓慢旋转。 How can I achieve this with Lerp? 如何使用Lerp做到这一点?

The code I currently have: 我目前拥有的代码:

if(!isWayPoint5)
{
    //here i"m using turn by using rotate but i needed rotate 
    //slowly is same as turns train in track.
    transform.Rotate(0,0,25);
    isWayPoint5 = true;
}

Check out how to use Quaternion.Lerp on the wiki-site. 在Wiki网站上查看如何使用Quaternion.Lerp

Using that example: 使用该示例:

public Transform from = this.transform;
public Transform to = this.transform.Rotate(0,0,25);
public float speed = 0.1F; //You can change how fast it goes here
void Update() {
    transform.rotation = Quaternion.Lerp(from.rotation, to.rotation, Time.time * speed);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM