You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
847 B
C#

using UnityEngine;
namespace Class03
{
// 별의 자식 비주얼만 움직여 수집 영역은 일정하게 유지합니다.
public sealed class StarMotion : MonoBehaviour
{
[SerializeField] private float degreesPerSecond = 65f;
[SerializeField] private float amplitude = 0.16f;
[SerializeField] private float cyclesPerSecond = 0.45f;
[SerializeField] private float phase;
private Vector3 initialPosition;
private void Awake() => initialPosition = transform.localPosition;
private void Update()
{
transform.localPosition = initialPosition + Vector3.up *
(Mathf.Sin(Time.time * cyclesPerSecond * Mathf.PI * 2f + phase) * amplitude);
transform.Rotate(Vector3.up, degreesPerSecond * Time.deltaTime, Space.Self);
}
}
}