I need help with this error I can’t figure out what it’s telling me to fix, I see where it want me to fix but not how to fix it. Anyone got any suggestive actions? ( The problem is on line 19)
using UnityEngine;
using System.Collections;
public class Shooting : MonoBehaviour
{
public GameObject bullet_pefab;
float bulletImpulse = 20f;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
if (Input.GetButtonDown ("Fire1"))
Camera camera = Camera.main;
GameObject thebullet = (GameObject)Instantiate(bullet_pefab, camera.transform.position, camera.transform.forward, camera.transform.rotation);
thebullet.rigidbody.AddForce( camera.transform.forward * bulletImpulse, ForceMode.Impulse);
}
}
Because your if statement doesn’t have braces it looks at the next line and sees a declaration which is not allowed. The error is explained here Error CS1023
Your update should be:
void Update() {
if (Input.GetButtonDown("Fire1")) {
Camera camera = Camera.main;
GameObject thebullet = (GameObject)Instantiate(bullet_pefab, camera.transform.position, camera.transform.forward, camera.transform.rotation);
thebullet.rigidbody.AddForce( camera.transform.forward * bulletImpulse, ForceMode.Impulse);
}
}
You are assigning Camera only when you’ve clicked the button(“Fire1”)
but the rest of code will still be executed. (READ AS: You’ve missed brackets)
Change this:
void Update ()
{
if (Input.GetButtonDown ("Fire1"))
Camera camera = Camera.main;
GameObject thebullet = (GameObject)Instantiate(bullet_pefab, camera.transform.position, camera.transform.forward, camera.transform.rotation);
thebullet.rigidbody.AddForce( camera.transform.forward * bulletImpulse, ForceMode.Impulse);
}
to this:
void Update ()
{
if (Input.GetButtonDown ("Fire1"))
{
Camera camera = Camera.main;
GameObject thebullet = (GameObject)Instantiate(bullet_pefab, camera.transform.position, camera.transform.rotation);
thebullet.rigidbody.AddForce( camera.transform.forward * bulletImpulse, ForceMode.Impulse);
}
}
That change should solve the problem 
You must enclose the code after the if with brackets:
void Update ()
{
if (Input.GetButtonDown ("Fire1")){
Camera camera = Camera.main;
GameObject thebullet = (GameObject)Instantiate(bullet_pefab, camera.transform.position, camera.transform.forward, camera.transform.rotation);
thebullet.rigidbody.AddForce( camera.transform.forward * bulletImpulse, ForceMode.Impulse);
}
}
The error CS1023 means that you’re declaring a variable in some “forbidden” place. Temporary variables in C# only exist inside the block where they are declared, what without brackets would be the single instruction after the if.