I’m getting the following errors in the code:
(14,25): error CS1502: best overloaded method match for ‘UnityEngine.MonoBehaviour.StartCoroutine(System.Collections.IEnumerator)’ has some invalid arguments
(14,25): error CS1503 Argument ‘#1’ cannot convert ‘void’ expression to type ‘System.Collections.IEnumerator’
Here is the code:
using UnityEngine;
using System.Collections;
public class MyWeapon : MonoBehaviour {
public float Damage = 100f;
public float MaxDistance = 100f;
private float Distance;
bool isFiring = false;
public void Update() {
// ...
if (Input.GetButton("Fire1") && !isFiring) {
StartCoroutine(Shoot());
}
// ...
}
public void Shoot() {
RaycastHit hit;
Ray ray = Camera.main.ViewportPointToRay(new Vector3(0.5f,0.5f,0f));
if (Physics.Raycast (ray, out hit, 100f)) {
{ Distance = hit.distance;
if (Distance < MaxDistance)
hit.transform.SendMessage("ApplyDamage",Damage,SendMessageOptions.DontRequireReceiver);
}
}
}
IEnumerator COFire() {
isFiring = true;
yield return 0;
yield return new WaitForSeconds(5f);
isFiring = false;
}
}
I know its probably a really simple answer but I havent been able to find a match, especially in C#
I’m complete beginner noob level