Initial commit

This commit is contained in:
Savina Rizdafayi
2025-07-12 19:53:40 +07:00
commit d7120c397a
933 changed files with 246809 additions and 0 deletions

View File

@ -0,0 +1,51 @@
using UnityEngine;
public class BukaPintu1 : MonoBehaviour
{
public Transform door;
public float openAngle = 90f;
public float closeAngle = 0f;
public float smoothSpeed = 2f;
private bool open = false;
public AudioSource audioSource;
public AudioClip bukaPintuSound; // Suara pintu buka
private bool soundPlayed = false; // Agar suara tidak berulang
void Update()
{
Quaternion targetRotation = open ?
Quaternion.Euler(0, openAngle, 0) :
Quaternion.Euler(0, closeAngle, 0);
// Rotasi pintu
door.localRotation = Quaternion.Slerp(door.localRotation, targetRotation, Time.deltaTime * smoothSpeed);
}
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
open = true;
}
if (!soundPlayed && audioSource != null && bukaPintuSound != null)
{
audioSource.PlayOneShot(bukaPintuSound);
soundPlayed = true;
}
}
private void OnTriggerExit(Collider other)
{
if (other.CompareTag("Player"))
{
open = false;
}
soundPlayed = false;
}
}