seems that a bracket is missing from your code using System.Collections; using…
- User
seems that a bracket is missing from your code using System.Collections; using System.Collections.Generic; using UnityEngine;
public class door : MonoBehaviour { bool toggle; public Animator anim;
codepublic void openClose() { toggle = !toggle; if(toggle == false) { anim.ResetTrigger("open"); anim.SetTrigger("close"); } if (toggle == true) { anim.ResetTrigger("close"); anim.SetTrigger("open"); } [SerializedField] private AudioClip _yourAudioClip; // Add your audio clip on Editor private AudioSource _audioSource; private void Awake() { _audioSource == GetComponent<AudioSource>(); } private void Foo() { _audioSource.PlayOneShot(_yourAudioClip); } } - Assistant
It looks like you've pasted the code into your
openClosemethod, and it appears you might be mixing method-level code with class-level declarations. Let's correct it and ensure all methods and blocks are properly defined. Additionally, there are some syntax errors in assignment and method definitions that need fixing.Here is your corrected code:
csharp