Hi I have a simple script that plays different audio clips on various button or mouse clicks, now I have the code setup to play an audio clip that is assigned in a public variable on left mouse click, but I need it to do that and also play the audio that is assigned to the audio source when I click the up and down arrow keys, I thought I had it figured out, but it keeps giving me the error/errors below. Also Please give me the code in C# thanks.
Error:
Assets/AudioTrigger.cs(21,17): error CS0029: Cannot implicitly convert type float' to
bool’
Here’s the code I’m using:
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(AudioSource))]
public class AudioTrigger : MonoBehaviour
{
public AudioClip swing;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
if(Input.GetButtonDown("Fire1"))
audio.PlayOneShot(swing);
if(Input.GetAxis("Vertical"))
audio.Play();
}
}