I really do not understand what is wrong with my script, I have an error saying expecting ( , found Shoot. But I dont have a clue what I have done wrong can anyone help me?
Here you go, I think your error was that you had your curly brackets for closing your `Update()` function after the `Shoot()` function, plus I think you had an extra one there in the end as well!!!!!! There were also a couple of errors with the raycast, so I updated that too!!!! I fixed up your code for you and it should work now!!!!! I also indented it, so it is a bit easier to read!
var shootSound : AudioClip;
var bloodPrefab : Transform;
var sparksPrefab : Transform;
var range = 500;
var hit : RaycastHit;
function Update (){
if(Input.GetButtonDown("Fire1")){
Shoot();
}
}
function Shoot(){
var fwd = transform.TransformDirection (Vector3.forward);
if(Physics.Raycast(transform.position, fwd, hit, range)){
var rot = Quaternion.FromToRotation(Vector3.up, hit.normal);
if(hit.collider.tag == "Enemy"){
if(bloodPrefab){
Instantiate(bloodPrefab, hit.point, rot);
}
hit.collider.gameObject.SendMessage("ApplyDamage", 25, SendMessageOptions.DontRequireReceiver);
}
else{
if(sparksPrefab){
Instantiate(sparksPrefab, hit.point, rot);
}
}
}
}
It should work now, but if not, then just post back