I’m getting CS1023 using this code;
using UnityEngine;
using System.Collections;
public class ThrowObject : MonoBehaviour {
public GameObject bullet;
public AudioClip shootSound;
public GameObject vehicularToThrow;
private float throwSpeed = 2200f;
private AudioSource source;
private float volLowRange = .5f;
private float volHighRange = 1.0f;
void Awake () {
source = GetComponent<AudioSource>();
}
void Update () {
if (Input.GetButtonDown("Fire1"))
{
float vol = Random.Range (volLowRange, volHighRange);
source.PlayOneShot(shootSound,vol);
GameObject throwThis = Instantiate (bullet, transform.position, transform.rotation) as GameObject;
throwThis.GetComponent<Rigidbody>().AddRelativeForce (new Vector3(0,0,throwSpeed));
if (Input.GetButtonDown("Fire2"))
GameObject shootCar = Instantiate (vehicularToThrow, transform.position, transform.rotation) as GameObject;
shootCar.GetComponent<Rigidbody>().AddRelativeForce (new Vector3(0,0,throwSpeed));
}
}
}
Why? I tried moving the declaration outside of the if statement and nothing changed, same error. Help!
It’s at 26, 131, by the way.