[csharp] df
Viewer
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class pooplol : MonoBehaviour
- {
- public Animator Toilet;
- public AudioSource kmms;
- public GameObject inttext;
- private bool isInteractable = false;
- void Start()
- {
- // Try to fetch the Animator component
- Toilet = GetComponent<Animator>();
- if (Toilet == null)
- {
- Debug.LogError("Animator component not found on the GameObject to which this script is attached.");
- }
- }
- void Update()
- {
- if (isInteractable && Input.GetKeyDown(KeyCode.E))
- {
- Debug.Log("E key pressed and interactable is true.");
- Toilet.ResetTrigger("press");
- Toilet.SetTrigger("press");
- }
- }
- void OnTriggerStay(Collider other)
- {
- if (other.CompareTag("MainCamera"))
- {
- inttext.SetActive(true);
- isInteractable = true;
- Debug.Log("MainCamera is within trigger area.");
- }
- }
- void OnTriggerExit(Collider other)
- {
- if (other.CompareTag("MainCamera"))
- {
- inttext.SetActive(false);
- isInteractable = false;
- Debug.Log("MainCamera has exited the trigger area.");
- }
- }
- }
Editor
You can edit this paste and save as new: