(スクリプト)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Rotate90 : MonoBehaviour
{
private int num;
private int count;
private Quaternion targetRot;
void Update()
{
count += 1;
if(count % 500 == 0)
{
// 数字が1>2>3>0>1>2・・・とループする。
num = (num + 1) % 4;
}
var step = Time.deltaTime * 30f;
// Y座標を軸として、ゆっくり90度ずつ角度を変える。
// 90にnumを掛けることで、90>180>270>0>90>180・・・と角度がループする(ポイント)
targetRot = Quaternion.AngleAxis(90 * num, Vector3.up);
transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRot, step);
}
}
(実行結果)



