- Home /
create variable trouble
I get this error, "Assets/scripts/scripts/Shoot.cs(6,17): error CS0825: The contextual keyword `var' may only appear within a local variable declaration"
using UnityEngine;
using System.Collections;
public class Shoot : MonoBehaviour
{
private var ShootActive = false;
void OnMouseDown ()
{
}
void Update ()
{
}
}
This is the script i am writing so far, i am trying to crate a variable that when active an object spawns on the empty that this script is attached to. I want an if statement in the OnMouseDown area that says "when ShootActive = true spawn object and when ShootActive = false do nothing" but i don't know how to write this Thanks for any help i get, please don't just say i can't do this with an if statement and i need to use something else. I need an example script or a script written to fit this one. Thanks
Answer by MithosAnnar · Sep 22, 2012 at 06:01 PM
Hi lildevil345,
That is a c# script you are using. I'm afraid we don't use var in c#, instead try:
Private bool shootActive = false;
Remember, In c# you have to declare the kind of variable.
Cheers!
Mithos
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Errors with script using Javascript. 2 Answers
Getting Unknown Identifier Error 1 Answer
Scroll text works, but load level is to fast! 2 Answers
Scripting error! 1 Answer