26 lines
520 B
C#
26 lines
520 B
C#
|
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);
|
||
|
}
|
||
|
}
|
||
|
}
|