简体   繁体   中英

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?

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.

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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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