현재 적용은 했는데

인게임에서 소리 들으니까 중복돼서 들리네..프레임 단위로 호출돼서 그런거 같은데..

애니메이터에서 이벤트 처리로 소리 찍으니까 한번만 깔끔하게 들리긴 하는데 애니메이션 쓸 일 없는 오브젝트는 처리하기 애매해가지고..

코드 풀로 올릴게



using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class ST1HintRoomEnter : OBJManager

{

public Transform PositionEnterRoom; // 들어가는 위치

public Transform PositionOutRoom; // 나가는 위치

bool b_Entercheck; // 들어갈때

bool b_Outcheck; // 나갈때

bool b_nowInside = false; //안 체크

protected override void Start()

{

base.Start();

SecIcon.SetActive(false);

S1DoorInside.SetActive(false);

}

void FixedUpdate()

{

if(b_Entercheck)

{

if (Input.GetKey(KeyCode.F) && b_nowInside == false)

{

StartCoroutine("InsideSec");

}

else b_checktest = false;

if(Input.GetKey(KeyCode.F) && b_nowInside == true)

{

StartCoroutine("OutsideSec");

}

}

}

private void OnTriggerEnter2D(Collider2D collision)

{

if (collision.gameObject.CompareTag("Player"))

{

b_Entercheck = true;

SecIcon.SetActive(true);

}

if(collision.gameObject.CompareTag("Player") && b_nowInside == true)

{

S1DoorInside.SetActive(true);

}

}

private void OnTriggerExit2D(Collider2D collision)

{

b_Entercheck = false;

SecIcon.SetActive(false);

S1DoorInside.SetActive(false);

}

IEnumerator InsideSec()

{

FindObjectOfType<AudioManager>().OnePlay("ST1SecroomDoor", 0.2f);

yield return new WaitForSeconds(0.35f);

Player1.transform.position = new Vector2(PositionEnterRoom.position.x, PositionEnterRoom.position.y);

b_nowInside = true;

}

IEnumerator OutsideSec()

{

FindObjectOfType<AudioManager>().OnePlay("ST1SecroomDoor", 0.2f);

yield return new WaitForSeconds(0.35f);

Player1.transform.position = new Vector2(PositionOutRoom.position.x, PositionOutRoom.position.y);

b_nowInside = false;

}

}


코루틴이 돌면 소리가 작동하도록 했는데

업데이트에서 불러서 그런지 소리가 겹쳐 들리는 문제가 있어가지고..

fixedupdate에서도 마찬가지인데 소리 딱 깔끔하게 한번 들리게 하려면 뭘 건드는게 맞을까