Hello I have an error in Unity, I'm a noob in javascript.
My errors: "Asset/ShootEject.js(46,1): BCE0044: expecting },found 'public'.
and: "Asset/ShootEject.js(106,1): BCE0044: expecting EOF, found }'
My scri^t (plz help me :p):
#pragma strict
///////////////////////////////////////////////////////////////////VARIABLES///////////////////////////////////////////////////////////////////////
@SerializeField
public var bulletCasing : Rigidbody;
@SerializeField
public var ejectSpeed : int = 100;
@SerializeField
public var fireRate : float = 0.5;
@SerializeField
private var nextFire : float = 0.0;
@SerializeField
private var fullAuto = false;
@SerializeField
public var clip : int = 30;
@SerializeField
public var maxclip : int = 30;
@SerializeField
public var reserve : int = 300;
@SerializeField
public var minreserve : int = 0;
@SerializeField
public var shotsound : AudioClip;
@SerializeField
public var reloadsound : AudioClip;
public var MunMax : boolean = true;
public var reloadsoundplay : boolean = false;
public var automatic : boolean = true;
@SerializeField
public var fireshot : GameObject;
///////////////////////////////////////////////////////////////////FONCTION UPDATE////////////////////////////////////////////////////////////////
function Update () {
if(Input.GetButton("Fire1") && Time.time > nextFire){
if(clip >= 1){
nextFire = Time.time + fireRate;
public var bullet : Rigidbody;
bullet = Instantiate(bulletCasing, transform.position, transform.rotation);
clip -= 1;
GetComponent.().PlayOneShot(shotsound);
bullet.velocity = transform.TransformDirection(Vector3.left * ejectSpeed);
Instantiate(fireshot, transform.position, transform.rotation);
}
}
if(automatic == true){
if(Input.GetKeyDown("v")){
fullAuto = !fullAuto;
}
}
if(Input.GetKeyDown("r")){
if(reloadsoundplay == true){
GetComponent.().PlayOneShot(reloadsound);
}
if(reserve > 30){
RemoveReserve();
clip += maxclip - clip;
}
if(reserve < 30){
clip += reserve;
RemoveReserve();
}
}
if(fullAuto == true){
fireRate = 0.10;
}else{
fireRate = 0.5;
}
if(reserve <= 0){
reserve = 0;
}
if(clip == maxclip){
reloadsoundplay = false;
}
if(clip < maxclip){
reloadsoundplay = true;
}
if(reserve == 0){
reloadsoundplay = false;
}
if(automatic == false){
fireRate = 0.7;
}
}
///////////////////////////////////////////////////////////////////FUNCTION ON GUI///////////////////////////////////////////////////////////////////////
function OnGUI(){
GUI.Box(Rect(10,10,130,25), clip+ " / " +reserve);
}
///////////////////////////////////////////////////////////////////FUNCTION REMOVE RESERVE///////////////////////////////////////////////////////////////
function RemoveReserve(){
reserve -= maxclip - clip;
}
↧