Hello, today I just made a script which looks ok but when I go to test it I get an error saying: Assets/Scripts/PlayerShoot.js(39,1): Unexpected token: .
I go back into the script but to find that where ever I place my cursor to type when leaving the file, that is where the error is happening.
Here’s the script:
var shootForce: float;
var bulletPrefab: Transform;
var myMuzzle: Transform;
var shootingEnabled : boolean = true;
var ammoCurrent : int = 20;
var ammoMax : int = 20;
var score : int = 0;
function Update ()
{
if(Input.GetButtonDown("Fire1")){
Shoot();
}
if(ammoCurrent == 0){
shootingEnabled = false;
}
}
function OnGUI ()
{
GUI.TextField (Rect (10, 10, 100, 20), "Ammo: " + ammoCurrent + "/" + ammoMax);
}
function Shoot ()
{
if(shootingEnabled == true){
var bullet = Instantiate(bulletPrefab,myMuzzle.transform.position,myMuzzle.transform.rotation);
bullet.rigidbody.AddForce(transform.forward * shootForce * Time.deltaTime);
ammoCurrent -= 1;
}
}
function OnCollisionEnter (collision : Collision)
{
if(Collision.tag == "Ammo"){
ammoCurrent = ammoMax;
}
{
Is this a bug? Or is something wrong with my script? Thanks.