Assets/silahsistem.cs(56,6): error CS1624: The body of silahsistem.efekt()' cannot be an iterator block because void’ is not an iterator interface type
Assets/silahsistem.cs(62,6): error CS1624: The body of silahsistem.mermisayisi()' cannot be an iterator block because void’ is not an iterator interface type
i tried make my scripts js to c# i dont know why gave error like this.
void efekt (){
muzzleflash.transform.Rotate(Vector3(90,0,0));
yield return new WaitForSeconds(0.1f);
muzzleflash.gameObject.SetActive(false);
}
Note that you need to call efekt() in another function, or set the IEnumerator as your Update(), FixedUpdate(), or LateUpdate() function. So, using the following code will call your IEumerator once every frame. This wil cause your muzzleflash to spin rapidly and turn off.
void Update()
{
StartCoroutine(efekt());
}
Alternately, for the same effect, you could do this:
This will do the exact same thing, once a second, without using coroutines. Also, I should note that in the code you provide, you won’t turn the muzzleflash, you’ll add 90 to it’s rotation along the x axis.