Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

CS1023 An embedded statement may not be a declaration or labeled statement help

$
0
0
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(); } 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().AddRelativeForce (new Vector3(0,0,throwSpeed)); if (Input.GetButtonDown("Fire2")) GameObject shootCar = Instantiate (vehicularToThrow, transform.position, transform.rotation) as GameObject; shootCar.GetComponent().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.

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>