簡単なアニメーションはスクリプトで済ませてしまいたい!そのために XYZ軸それぞれを指定の範囲でSinの滑らかさで変化させるスクリプト。 Inspectorからパラメータを調整可能。 木の枝の揺れなどに使う予定です。
var enableX:boolean = false; var enableY:boolean = false; var enableZ:boolean = false; //theta var thetaXmin:float = 0; var thetaXmax:float = 0; var XchangeSpeed:float = 1; var thetaYmin:float = 0; var thetaYmax:float = 0; var YchangeSpeed:float = 1; var thetaZmin:float = 0; var thetaZmax:float = 0; var ZchangeSpeed:float = 1; function Update () { var thetaXmean:float = (thetaXmax + thetaXmin) / 2; var thetaXRadius:float = thetaXmax - thetaXmean; var thetaX:float; var thetaYmean:float = (thetaYmax + thetaYmin) / 2; var thetaYRadius:float = thetaYmax - thetaYmean; var thetaY:float; var thetaZmean:float = (thetaZmax + thetaZmin) / 2; var thetaZRadius:float = thetaZmax - thetaZmean; var thetaZ:float; var rotX = transform.eulerAngles.x; var rotY = transform.eulerAngles.y; var rotZ = transform.eulerAngles.z; if(enableX){rotX = thetaXmean + thetaXRadius * Mathf.Sin( Time.time * XchangeSpeed );} if(enableY){rotY = thetaYmean + thetaYRadius * Mathf.Sin( Time.time * YchangeSpeed );} if(enableZ){rotZ = thetaZmean + thetaZRadius * Mathf.Sin( Time.time * ZchangeSpeed );} transform.rotation = Quaternion.Euler(rotX, rotY, rotZ); }