So here's the part of the script I can't seem to fix.
The errors are:
Assets/Scripts/Shoot2.js(75,10): BCE0044: expecting (, found 'Reload'.
Assets/Scripts/Shoot2.js(75,19): UCE0001: ';' expected. Insert a semicolon at the end.
Assets/Scripts/Shoot2.js(76,20): BCE0044: expecting :, found '='.
This is a script for a gun that I am using in Unity for my end of school year assignment. I've got everything else sorted out perfectly, no errors at all. Just that little part which I can't seem to figure out and I can't just delete it since it's the reload script and that's a fundamental of a shooter. So if you could give any help in debugging this, please share!
Complete Script:
Sorry if this is the wrong section! Wasn't really sure where I should post this.
Code:
function Reload () {
isReloaded = true;
if(reloadSound){
audio.PlayOneShot(reloadSound);
if(currentClip > 0){
currentAmmo = ammoPerClip;
currentClip -= 1;
}
isReloaded = false;
}
The errors are:
Assets/Scripts/Shoot2.js(75,10): BCE0044: expecting (, found 'Reload'.
Assets/Scripts/Shoot2.js(75,19): UCE0001: ';' expected. Insert a semicolon at the end.
Assets/Scripts/Shoot2.js(76,20): BCE0044: expecting :, found '='.
This is a script for a gun that I am using in Unity for my end of school year assignment. I've got everything else sorted out perfectly, no errors at all. Just that little part which I can't seem to figure out and I can't just delete it since it's the reload script and that's a fundamental of a shooter. So if you could give any help in debugging this, please share!
Complete Script:
Code:
#pragma strict
var weaponModel : GameObject;
var shootFrom : Transform;
var playerModel : Transform;
var bulletHole : GameObject;
var shootTimer : float = 0.0f;
var shootCooler : float = 0.0f;
var bulletForce : int = 0;
var bulletDamage : int = 0;
var distanceFired : int = 0;
var timeToReload : flat = 0.0f;
var currentAmmo : int = 0;
var CurrentClip : int = 6;
var ammoPerClip : int = 30;
var isReloaded : boolean = false;
var canShoot : boolean = true;
var reloadSound : AudioClip;
var shootSound : AudioClip;
function Start () {
currentAmmo = ammPerClip;
}
function Update () {
if(Input.GetMouseButton(0)){
if(currentAmmo < 1 && isReloaded == false){
Reload();
}
if(currentAmmo > 0 && shootTimer < 0 && canShoot == true){
Fire();
}
}
shootTime -= Time.deltaTime;
}
function Fire () {
if(currentAmmo > 0){
var hit : RaycastHit;
var direction : Vector3 = transform.TransformDirection(Vector3.forward);
Debug.DrawRay(shootFrom.position, direction * distanceFired, Color.cyan);
if(Physics.Raycast(shootFrom.postion, direction, hit, distanceFired)){
var hitRotation = Quaternion.FromToRotation(Vector3.up, hit.normal);
if(hit.transform.tag == "Prop"){
Instantiate(bulletHole, hit.point, hitRoation);
if(hit.rigidbody){
if(hit.transform.tag == "Enemy"){
print("BulletHitEnemy");
}
hit.rigidbody.AddForceAtPosition(direction * bulletForce, hit.point);
}
}
currentAmmo --;
shootTimer = shootCooler;
if(shootSound){
audio.PlayOneShot(shootSound);
}
}
}
function Reload () {
isReloaded = true;
if(reloadSound){
audio.PlayOneShot(reloadSound);
if(currentClip > 0){
currentAmmo = ammoPerClip;
currentClip -= 1;
}
isReloaded = false;
}
Sorry if this is the wrong section! Wasn't really sure where I should post this.