18 lines
509 B
C#
18 lines
509 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Rotation : MonoBehaviour {
|
|
[SerializeField] float angle;
|
|
[SerializeField] float speed;
|
|
[SerializeField] float amp;
|
|
|
|
Vector3 startPos;
|
|
|
|
void Start() => startPos = transform.position;
|
|
|
|
void Update() {
|
|
transform.rotation *= Quaternion.AngleAxis(angle, Vector3.forward);
|
|
transform.position = startPos + Vector3.up * amp * Mathf.Sin(Time.time * speed) + Vector3.right * amp * Mathf.Cos(Time.time * speed);
|
|
}
|
|
} |