Very simple: How do I call a IEnumerator function?
I would need it for my Players footstep generation. I would need to call a infinit loop which checks whether the player is running or not and if so he will spawn one and delay the next by .3 seconds. For that i need a “yield return new Waitforseconds()” and for that i need a coroutine. Now, as soon as i try to declair my Coroutine as a ServerRpc I get
Error: “(0,0): error - RPC method must return void!” as an error.
Code:
void Start(){
StartCoroutine( FootstepGenServerRpc());
}
[ServerRpc]
private IEnumerator FootstepGenServerRpc(){
begin:
for( ;steping; ){
GameObject step = Instantiate(Footsteps,new Vector3(transform.position.x, transform.position.y, 121f), transform.rotation);
step.GetComponent<NetworkObject>().Spawn();
yield return new WaitForSeconds(.3f);
if(!steping) break;
step = Instantiate(Footsteps2, new Vector3(transform.position.x, transform.position.y, 121f), transform.rotation);
step.GetComponent<NetworkObject>().Spawn();
yield return new WaitForSeconds(.3f);
}
if(!steping){
yield return new WaitForSeconds(.3f);
goto begin;
}
}