47 lines
1.1 KiB
C#
47 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class ObjPressurePlateMod: MonoBehaviour
|
|
{
|
|
public GameObject door;
|
|
public SpriteRenderer spriteRenderer;
|
|
public Sprite originalSprite;
|
|
public Sprite activatedSprite;
|
|
public AudioSource audioSource; // Reference to the AudioSource component
|
|
public AudioClip buttonClickSound; // The sound clip to be played
|
|
private bool isActive = false;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
audioSource = GetComponent<AudioSource>();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
void OnTriggerEnter2D(Collider2D other) {
|
|
if (other.CompareTag("PressurePlatable")){
|
|
door.SetActive(false);
|
|
spriteRenderer.sprite = activatedSprite;
|
|
if(!isActive){
|
|
audioSource.PlayOneShot(buttonClickSound);
|
|
isActive = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
void OnTriggerExit2D(Collider2D other) {
|
|
if (other.CompareTag("PressurePlatable")) {
|
|
door.SetActive(true);
|
|
spriteRenderer.sprite = originalSprite;
|
|
}
|
|
}
|
|
*/
|
|
}
|