- Home /
What is wrong with these two lines of scripting?
Here is one line: var PlayerScript : Player ANIMATION;
Player ANIMATION is the name of my other script and I am getting the console error:
Assets/GunScript.js(2,26): UCE0001: ';' expected. Insert a semicolon at the end.
I got rid of it by changing the script to:
var PlayerScript : PlayerAnimation;
I would like to know if this line of script should work fine? (Sorry for being vague with details)
Secondly, I have this error:
Assets/GunScript.js(111,1): BCE0044: expecting }, found ''.
For this line of script on the same script;
FireTimer -= Time.deltatime * FireRate;
I am just following a tutorial so I am not sure why not and I am a newbie to Unity. I f you would like the whole script posted, I will but it is over 100 lines(gaps included).
Sorry if it should be two questions.
EDIT: Just noticed that when i cut that line of script the error was still there?
Thanks!
var PlayerTransform : Transform; var PlayerScript : PlayerANI$$anonymous$$ATION; var RotationSpeed : float; var PlayerCamera : GameObject;
//Targets
@HideInInspector var TargetXrotation : float;
@HideInInspector var TargetYrotation : float;
@HideInInspector var TargetXrotationV : float;
@HideInInspector var TargetYrotationV : float;
//Gun Specs var $$anonymous$$axClipSize : float = 32; var AmmoInCurrentClip : float = 32; var ExtraAmmo : float = 128; var $$anonymous$$axCarryingAmmo : float = 256;
//Bullets and N/A var Bullet : GameObject; var BulletSpawn : GameObject; var BulletSound : GameObject; var FireRate : float; var FireTimer : float;
//Reloads var ReloadAnimation : Animation; var ReloadSound : AudioSource; var Reloading : boolean = false;
function LateUpdate () {
if (ExtraAmmo < $$anonymous$$axCarryingAmmo)
ExtraAmmo = $$anonymous$$axCarryingAmmo;
if ($$anonymous$$axClipSize < 0)
$$anonymous$$axClipSize = 0;
if (AmmoInCurrentClip > $$anonymous$$axClipSize)
AmmoInCurrentClip = $$anonymous$$axClipSize;
if (AmmoInCurrentClip < 0)
AmmoInCurrentClip = 0;
if (!Reloading && AmmoInCurrentClip == 0 && ExtraAmmo > 0 && Input.GetButtonDown("Fire 1")) { Reloading = true; ReloadSound.Play(); ReloadAnimation.PlayAnimation("ReloadAnim"); } if (!Reloading && AmmoInCurrentClip < $$anonymous$$axClipSize && ExtraAmmo > 0 && Input.GetButtonDown("Reload")) { Reloading = true; ReloadSound.Play; ReloadAnimation.PlayAnimation("ReloadAnim"); } if (Reloading == true && !ReloadAnimation.IsPlaying("ReloadAnim")) { if (ExtraAmmo >= $$anonymous$$axClipSize - AmmoInCurrentClip) { ExtraAmmo -= $$anonymous$$axClipSize - AmmoInCurrentClip; AmmoInCurrentClip = $$anonymous$$axClipSize; }
if (ExtraAmmo < $$anonymous$$axClipSize - AmmoInCurrentClip) { AmmoInCurrentClip += ExtraAmmo; ExtraAmmo = 0; } Reloading = false; }
var $$anonymous$$yBulletSound : GameObject;
if (Input.GetButtonDown("Fire 1") && $$anonymous$$axClipSize > 0 && !Reloading) {
if (FireTimer <= 0) { $$anonymous$$axClipSize -= 1;
if (Bullet)
Instantiate (Bullet,BulletSpawn.transform.position,BulletSpawn.transform.rotation);
if (BulletSound)
$$anonymous$$yBulletSound = Instantiate (BulletSound,BulletSpawn.transform.position,BulletSpawn.transform.rotation);
FireTimer = 1;
}
}
FireTimer -= Time.deltaTime * FireRate;
That's all of my scripts but I haven't bothered to but the gaps back in where they have disappeared when copied into the comment. JesseScope, if you could tell me where the other bracket/scope errors are I would be very grateful.
Is there a way of posting scripts with all of the appropriate gaps on unity answers?
In the first case, your problem was that space. When you name a component with upper case in the middle (called camelNa$$anonymous$$g) Unity automatically shows in the inspector as camel Na$$anonymous$$g. But you still need to use camelNa$$anonymous$$g in your script. For the second issue, Unity tells you line 111 because for some reason the last line is out of any scope. $$anonymous$$eaning it is not in any {} so Unity tells you nicely "The hell am I supposed to do with that??!!" You probably need to put it one line above as you have the matching amount of {}.
Answer by Jessespike · Nov 03, 2012 at 10:20 PM
The first problem is that you can't have spaces in object names.
Second problem is you need a capital T in deltaTime
Third problem is there are still more things wrong with your script but I can't see the code. Looks like you need to double check your braces/scopes { }
Thanks, I'll have a look but I think it's mainly deltaTime, on the tutorial they didnt have caps T though and theirs worked. If your ideas work I'll choose it as best answer :D
EDIT; Wait there is a Cps T in the scripts already, huh
What tutorial is that??!!deltaTime is a variable from the Time class, it always takes the T. or they use their own...
Your answer
Follow this Question
Related Questions
BCE0044: expecting error 1 Answer
What is Wrong With This Script? 3 Answers
Keep KGetting this error please help I dont know what to do 1 Answer
BCE0044: expecting '"', found '\r'. 1 Answer