GGJ2022/Assets/Scripts/BGRotation.cs

31 lines
747 B
C#
Raw Permalink Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BGRotation : MonoBehaviour
{
2022-01-30 10:32:44 +00:00
private Vector3 rotation;
2022-01-30 11:12:24 +00:00
private ProceduralGeneration bgParrentScript;
2022-01-30 10:32:44 +00:00
private void Start()
{
2022-01-30 10:34:49 +00:00
rotation = new Vector3(Random.Range(0, 360), Random.Range(0, 360), Random.Range(0, 360)) * 0.009f;
2022-01-30 11:12:24 +00:00
bgParrentScript = GameObject.Find("Level").GetComponent<ProceduralGeneration>();
2022-01-30 10:32:44 +00:00
}
void FixedUpdate()
{
2022-01-30 10:32:44 +00:00
transform.Rotate(rotation);
}
private void OnTriggerEnter(Collider other)
{
if (other.tag == "platform")
{
2022-01-30 11:12:24 +00:00
this.bgParrentScript.backgroundLevelBlocks.Remove(this.gameObject);
Destroy(this.gameObject);
}
2022-01-30 11:12:24 +00:00
}
}