private void Awake() { if (_impactSound == null) { _impactSound = GetComponent <SoundPlayOneshot>(); } }
//------------------------------------------------- private void SpawnParticles(GameObject particlePrefab, SoundPlayOneshot sound) { // Don't do this twice if (bParticlesSpawned) { return; } bParticlesSpawned = true; if (particlePrefab != null) { GameObject particleObject = Instantiate(particlePrefab, transform.position, transform.rotation) as GameObject; particleObject.GetComponent <ParticleSystem>().Play(); Destroy(particleObject, 2f); } if (sound != null) { float lastSoundDiff = Time.time - s_flLastDeathSound; if (lastSoundDiff < 0.1f) { sound.volMax *= 0.25f; sound.volMin *= 0.25f; } sound.Play(); s_flLastDeathSound = Time.time; } }
public static void StartForLevel(int levelIndex) { Instance._StartForLevel(levelIndex); ScoreDisplay = GameObject.Find("ScoreText").GetComponent <Text>(); ComboDisplay = GameObject.Find("ComboText").GetComponent <Text>(); ComboSound = GameObject.Find("ComboSounds").GetComponent <SoundPlayOneshot>(); }
private void OnCollisionEnter(Collision collision) { print("on collision enter: " + collision.transform.tag); if (collision.transform.tag == "Ax") { SoundPlayOneshot soundPlayOneshot = collision.transform.GetComponent <SoundPlayOneshot>(); if (soundPlayOneshot != null) { soundPlayOneshot.Play(); } else { Debug.LogError("SoundPlayOneshot component not found on axe."); } GameObject woodchipInstance = Instantiate(woodChipPrefab); woodchipInstance.transform.position = collision.contacts[0].point; chopCount++; if (chopCount > 2) { // Spawn logs and delete this. for (int i = 0; i < 3; i++) { GameObject logInstance = Instantiate(logPrefab); logInstance.transform.position = transform.position + new Vector3(Random.Range(-1f, 1f), Random.Range(0f, 0.5f), Random.Range(-1f, 1f)); } GameObject smokeInstance = Instantiate(smokePrefab); smokeInstance.transform.position = transform.position; Destroy(gameObject); } } }
protected void Awake() { ThrowSound = GetComponent <SoundPlayOneshot>(); VelocityEstimator = GetComponent <VelocityEstimator>(); }
private void Awake() { _interactable = GetComponentInParent <Interactable>(); _impactSound = GetComponent <SoundPlayOneshot>(); }