PlayerController

[SerializeField] GameObject[] guns; AudioSource audioSource; [SerializeField] AudioClip thrustingSound; [SerializeField] AudioClip bulletsSound; //bool thrusting = true; private void Start() { audioSource = GetComponent<AudioSource>(); } void Update () { if (isControlEnabled) { ProcessTranslation(); ProcessRotation(); ProcessFiring(); if (!audioSource.isPlaying) { audioSource.PlayOneShot(thrustingSound, 0.7f); } } } private void ProcessFiring() { if (CrossPlatformInputManager.GetButton("Fire")) { SetGunsActive(true); } else { SetGunsActive(false); } } void SetGunsActive(bool isActive) { foreach (GameObject gun in guns) { var emmitParticles = gun.GetComponent<ParticleSystem>().emission; emmitParticles.enabled = isActive; } } void PlayerDied() // string based method { isControlEnabled = false; audioSource.Stop(); }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.