mirror of
https://github.com/Project-Redacted/project-hampter.git
synced 2025-06-07 19:23:13 +00:00
Update :3
This commit is contained in:
parent
1f50b3f262
commit
6bbd56a5cf
759 changed files with 269694 additions and 37600 deletions
29
Assets/Scripts/Flashlight.cs
Normal file
29
Assets/Scripts/Flashlight.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class Flashlight : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Light flashlight; // Reference to the flashlight Light component
|
||||
public KeyCode toggleKey = KeyCode.E; // Key to toggle the flashlight on/off
|
||||
private bool isOn = false; // Flag to keep track of whether the flashlight is on or off
|
||||
public AudioSource audioSource;
|
||||
private void Start()
|
||||
{
|
||||
audioSource = GetComponent<AudioSource>();
|
||||
flashlight = GetComponentInChildren<Light>();
|
||||
flashlight.enabled = false;
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
// Check if the toggle key is pressed
|
||||
if (Input.GetKeyDown(toggleKey))
|
||||
{
|
||||
// Toggle the flashlight on/off
|
||||
isOn = !isOn;
|
||||
flashlight.enabled = isOn;
|
||||
audioSource.Play();
|
||||
|
||||
//audioClip = GetComponent<AudioClip>();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue