Files
VRProject/Assets/HIVEMIND/CyberpunkCity/HDRP(Default)/Scripts/LanternSwing.cs
oogushiyuuga d42ac5beeb Mapの追加
2026-05-18 16:13:38 +09:00

29 lines
894 B
C#

using UnityEngine;
public class LanternSwing : MonoBehaviour
{
[Header("Swing Settings")]
public float swingAngle = 15f; // Sallanma açýsý
public float swingSpeed = 2f; // Sallanma hýzý
public float randomOffsetRange = Mathf.PI * 2f; // Rastgele ofset aralýðý
private Quaternion initialRotation;
private float randomOffset;
void Start()
{
// Baþlangýç rotasyonunu kaydedin
initialRotation = transform.rotation;
// Her bir lantern için rastgele bir offset oluþturun
randomOffset = Random.Range(0f, randomOffsetRange);
}
void Update()
{
// Sallanma hareketi (sinüs dalgasý) - rastgele offset ile
float swingOffset = Mathf.Sin(Time.time * swingSpeed + randomOffset) * swingAngle;
transform.rotation = initialRotation * Quaternion.Euler(0, 0, swingOffset);
}
}