test commit

This commit is contained in:
niko
2026-10-11 20:26:48 +02:00
parent 4dbd3c0ab3
commit 6fee00e7ff
2187 changed files with 760371 additions and 2 deletions
+39
View File
@@ -0,0 +1,39 @@
using UnityEngine;
using UnityEngine.InputSystem;
public class HeldInteractions : MonoBehaviour
{
[Header("Flashlight")]
public GameObject Flashlight;
public AudioSource FlashlightToggleSfx;
public InputActionProperty FlashlightAction;
[Header("Misc")]
public GameObject Map;
public InputActionProperty MapAction;
public bool OffHandFree => !Map.activeSelf;
bool justToggledLight;
private void Update()
{
var toggledMap = MapAction.action.WasPressedThisFrame();
if (toggledMap) {
Map.SetActive(!Map.activeSelf);
}
var lightThreshold = 0.9f;
var toggledLight = FlashlightAction.action.ReadValue<float>();
if (toggledLight > lightThreshold && !justToggledLight) {
justToggledLight = true;
Flashlight.SetActive(!Flashlight.activeSelf);
FlashlightToggleSfx.Stop();
FlashlightToggleSfx.pitch = Random.Range(0.9f, 1.1f);
FlashlightToggleSfx.Play();
}
if (toggledLight < lightThreshold)
justToggledLight = false;
}
}