Hi all,
Im having problems with my C# Script, I want it so when a Key is held down, a sound and Gameobject are enabled. When the key is let go they both stop - Getting error “Unexpected Symbol ‘Else’” (Sorry for the script going messy at the end)
using UnityEngine;
using System.Collections;
public class Hose : MonoBehaviour {
public GameObject SprayParticles;
public AudioSource HoseSound;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update() {
if( Input.GetKeyDown( KeyCode.Z) ) {
SprayParticles.SetActive(true);
HoseSound.Play();
}
{
else if ( Input.GetKeyDown( KeyCode.Z) )
{
SprayParticles.SetActive(false);
HoseSound.Stop();
}
}
}