
First error line: The first if function statement
Second error line: The Debug.DrawRay
public class Gun : MonoBehaviour {
public enum GunType {Semi,Burst,Auto};
public GunType gunType;
public Transform spawn;
public void Shoot () {
Ray2D ray = new Ray2D (spawn.position, spawn.forward);
RaycastHit2D hit;
float shotDistance = 20;
if(Physics2D.Raycast(ray,out hit, shotDistance)) {
shotDistance = hit.distance;
}
Debug.DrawRay (ray.origin, ray.direction = shotDistance, Color.red, 1);
}
public void ShootContinuous () {
if (gunType == GunType.Auto) {
Shoot ();
}
}
}