From 29043302374fef86de8f6083aa7298fb63016c4d Mon Sep 17 00:00:00 2001 From: seozzi Date: Tue, 3 Dec 2024 13:11:46 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9D=B4=EC=83=81=ED=98=84=EC=83=81=2015=20?= =?UTF-8?q?=EA=B1=B0=EB=AF=B8=20=EC=82=AC=EC=9A=B4=EB=93=9C=20continuous?= =?UTF-8?q?=ED=95=98=EA=B2=8C=203d=20=EC=9D=8C=ED=96=A5=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Anomaly15Manager.cs | 9 ++--- .../Anomaly15_spider.cs | 38 ++++--------------- 2 files changed, 11 insertions(+), 36 deletions(-) diff --git a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly15Manager.cs b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly15Manager.cs index f9b1744..4adc442 100644 --- a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly15Manager.cs +++ b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly15Manager.cs @@ -18,11 +18,11 @@ public class Anomaly15Manager : MonoBehaviour private void Start() { - // Create and set up the interactive cube + // 상호작용할 수 있는 투명한 큐브 interactionCube = CreateInteractionCube(); StartCoroutine(SetTransparency(interactionCube)); - // Start spawning spiders + // 거미 생성 StartCoroutine(SpawnSpiderRoutine()); } @@ -100,22 +100,19 @@ private GameObject CreateInteractionCube() return cube; } - // Coroutine to set the transparency of the cube + // 투명하게 fadeout private IEnumerator SetTransparency(GameObject cube) { yield return null; // Wait for one frame to ensure setup is complete Renderer cubeRenderer = cube.GetComponent(); - // Ensure it's using a unique material instance cubeRenderer.material = new Material(Shader.Find("Standard")); - // Set the rendering mode to Transparent cubeRenderer.material.SetFloat("_Mode", 3); // 3 = Transparent cubeRenderer.material.color = new Color(0f, 0f, 0f, 0f); // Black albedo with 0 alpha cubeRenderer.material.renderQueue = 3000; // Force render in transparent queue - // Additional settings to enforce transparency cubeRenderer.material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha); cubeRenderer.material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); cubeRenderer.material.SetInt("_ZWrite", 0); diff --git a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly15_spider.cs b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly15_spider.cs index efaeda3..cb7172e 100644 --- a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly15_spider.cs +++ b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly15_spider.cs @@ -6,50 +6,29 @@ public class Anomaly15_spider : InteractableObject, IInteractable [Header("Interaction Settings")] private bool hasInteracted = false; - private Anomaly15Manager anomalyManager; // Reference to Anomaly15Manager + private Anomaly15Manager anomalyManager; [Header("Audio Settings")] public AudioClip spiderSoundClip; - private Transform cameraTransform; // Reference to the Main Camera's transform - - private AudioSource audioSource; // Reference to the AudioSource component + private Transform cameraTransform; + private AudioSource audioSource; private void Start() { - // Find the Anomaly15Manager in the scene anomalyManager = FindObjectOfType(); - if (anomalyManager == null) - { - Debug.LogError("Anomaly15Manager not found in the scene!"); - } - GameObject mainCamera = GameObject.FindWithTag("MainCamera"); - if (mainCamera != null) - { - cameraTransform = mainCamera.transform; - } + audioSource = gameObject.AddComponent(); audioSource.clip = spiderSoundClip; audioSource.loop = true; + audioSource.spatialBlend = 2f; // 3D 음향으로 설정 + audioSource.Play(); } private void Update() { - // Check the distance to the camera and play sound if within 5f - float distanceToCamera = Vector3.Distance(transform.position, cameraTransform.position); - Debug.Log(distanceToCamera); - if (distanceToCamera <= 10f && !hasInteracted) - { - if (!audioSource.isPlaying) // Start playing if not already playing - { - audioSource.Play(); - } - } - else + if (hasInteracted && audioSource.isPlaying) { - if (audioSource.isPlaying) // Stop playing if out of range - { - audioSource.Stop(); - } + audioSource.Stop(); } } @@ -75,7 +54,6 @@ public void OnInteract() if (anomalyManager != null) { anomalyManager.StopSpawning(); - audioSource.Stop(); } // Start coroutine to wait 2 seconds before destroying