ProjectZ/Assets/Scripts/Menu/swingLamps.cs

26 lines
520 B
C#
Raw Normal View History

2024-02-19 21:00:36 +03:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class swingLamps : MonoBehaviour
{
public List<Transform> lamps;
public float intensivity, maxAngle;
private float a, sin;
void Update()
{
a += intensivity * Time.deltaTime;
sin = Mathf.Sin(a);
for (int i = 0; i < lamps.Count; i++)
{
float side = i % 2 > 0 ? 1 : -1;
lamps[i].rotation = Quaternion.Euler(sin * maxAngle * side, 0, 0);
}
}
}