81 lines
2.0 KiB
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Kann sein das das nur für statische Objekte funktioniert
public class DimShift : MonoBehaviour
{
// 0 = inactive in Dimension 1
// 1 = active in Dimension 1
2023-06-18 17:38:50 +02:00
[SerializeField] private bool inFirstDim;
[SerializeField] private bool ShiftingEnabled;
2023-06-17 13:48:59 +02:00
AudioSource Audio1;
AudioReverbFilter Rev1;
AudioLowPassFilter lpf;
GameObject Dim1;
GameObject Dim2;
2023-06-18 13:37:19 +02:00
//remove if unwanted
private Animator animator;
void Start()
{
Dim1 = GameObject.Find("Dim1");
Dim2 = GameObject.Find("Dim2");
2023-06-17 13:48:59 +02:00
Audio1 = GameObject.Find("AudioController").GetComponent<AudioSource>();
Rev1 = GameObject.Find("AudioController").GetComponent<AudioReverbFilter>();
lpf = GameObject.Find("AudioController").GetComponent<AudioLowPassFilter>();
2023-06-18 13:37:19 +02:00
//remove if unwanted
animator = GetComponent<Animator>();
if (inFirstDim)
{
Dim1.SetActive(true);
Dim2.SetActive(false);
2023-06-17 13:48:59 +02:00
MusicDim1();
} else
{
2023-06-17 13:48:59 +02:00
Dim1.SetActive(false);
Dim2.SetActive(true);
2023-06-17 13:48:59 +02:00
MusicDim2();
}
}
void Update()
{
2023-06-18 17:38:50 +02:00
if (Input.GetKeyDown(KeyCode.LeftShift)&&inFirstDim&&ShiftingEnabled)
{
Dim2.SetActive(true);
Dim1.SetActive(false);
2023-06-17 13:48:59 +02:00
MusicDim2();
inFirstDim = !inFirstDim;
2023-06-18 13:37:19 +02:00
//remove if unwanted
animator.SetTrigger("ShiftsDim");
} else
{
2023-06-18 17:38:50 +02:00
if (Input.GetKeyDown(KeyCode.LeftShift)&&!inFirstDim&&ShiftingEnabled)
{
Dim1.SetActive(true);
Dim2.SetActive(false);
2023-06-17 13:48:59 +02:00
MusicDim1();
inFirstDim = !inFirstDim;
2023-06-18 13:37:19 +02:00
//remove if unwanted
animator.SetTrigger("ShiftsDim");
}
}
}
2023-06-17 13:48:59 +02:00
void MusicDim1()
{
Rev1.enabled = false;
lpf.enabled = false;
}
void MusicDim2()
{
Rev1.enabled = true;
lpf.enabled = true;
}
}