using DragonLi.Core; using Mirror; using UnityEngine; using System.Collections; using System.Collections.Generic; public class FootStepSound : MonoBehaviour { public string Step1Key; public string Step2Key; private Transform temp; private string spawnKey; private bool canPlay = true; public GameObject FootStep01Pre1; public GameObject FootStep01Pre2; public void PlayStepVoice(int id) { if (!canPlay) return; canPlay = false; CoroutineTaskManager.Instance.WaitSecondTodo(() => { canPlay = true; }, 0.125f); if (id == 1) GenerateFoot1Sound(); else GenerateFoot2Sound(); // temp = SpawnManager.Instance.SpawnWithoutAlloc(spawnKey, transform.position); // if (temp) // SpawnManager.Instance.DespawnWithoutAlloc(spawnKey, temp, 1.0f); } private void Start() { } [Server] public void GenerateFoot1Sound() { GameObject FootStep01 = Instantiate(FootStep01Pre1); NetworkServer.Spawn(FootStep01); FootStep01.transform.position = transform.position; CoroutineTaskManager.Instance.WaitSecondTodo(() => { NetworkServer.Destroy(FootStep01); }, 1.1f); } [Server] public void GenerateFoot2Sound() { GameObject FootStep02 = Instantiate(FootStep01Pre2); NetworkServer.Spawn(FootStep02); FootStep02.transform.position = transform.position; CoroutineTaskManager.Instance.WaitSecondTodo(() => { NetworkServer.Destroy(FootStep02); }, 1.1f); } }