Getting this error when I left click and it says it is in the lines 28 and 15 so I have no idea what to do. Any help will do.
using UnityEngine;
using System.Collections;
public class PlayerShooting : MonoBehaviour {
public float firerate = 0.5f;
float cooldown = 0;
public float damage = 25f;
// Update is called once per frame
void Update () {
cooldown -= Time.deltaTime;
if (Input.GetButton (“Fire1”)) {
fire ();
}
}
void fire(){
if (cooldown > 0) {
return;
}
Ray ray = new Ray(Camera.main.transform.position, Camera.main.transform.forward);
Transform hitTransform;
Vector3 hitPoint;
hitTransform = FindClosestHitObject (ray, out hitPoint);
if (hitTransform != null) {
Debug.Log (“Fired Gun”);
Health h = hitTransform.GetComponent();
while(h == null && hitTransform.parent){
hitTransform = hitTransform.parent;
h = hitTransform.GetComponent();
}
if(h !=null){
h.TakeDamage(damage);
}
}
cooldown = firerate;
}
Transform FindClosestHitObject(Ray ray, out Vector3 hitPoint){
RaycastHit[ ] hits = Physics.RaycastAll (ray);
Transform closestHit = null;
float distance = 0;
hitPoint = Vector3.zero;
foreach (RaycastHit hit in hits) {
if(hit.transform != this.transform && (closestHit==null || hit.distance < distance )){
closestHit = hit.transform;
distance = hit.distance;
hitPoint = hit.point;
}
}
return closestHit;
}
}