Files
2024-09-22 21:45:37 +02:00

34 lines
910 BLFS
C#

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;
public class AnimProc : MonoBehaviour
{
[SerializeField] private bool top;
[SerializeField] private float angle = 10;
[SerializeField] private float speed = 1;
private float delay = 0;
private Transform pivot;
[SerializeField] private float randomizedAngleMax= 0.1f;
void Start()
{
delay = UnityEngine.Random.Range(0, 5);
randomizedAngleMax = 1f + randomizedAngleMax * UnityEngine.Random.Range(-1, 1);
}
// Update is called once per frame
void Update()
{
float angle = (float)Math.Sin(Time.time * speed + delay) * this.angle * randomizedAngleMax;
// Rotate the object around its local Z axis at the top or bottom
transform.localRotation = Quaternion.Euler(0, 0, angle * (top ? 1 : -1));
}
}