- Home /
Spawn Objects Inside IEnumerator In Serverside (Unity Networking)
In my code, Bullets are spawn inside BulletSpawn Countie function looks like this
IEnumerator BulletSpawn()
{
isFireCompleate = false;
var bullteIns = Instantiate(Bullet, BulletSpawnPosition.transform.position, transform.localRotation);
Destroy(bullteIns, 5f);
yield return new WaitForSeconds(FireRate);
isFireCompleate = true;
}
And I am trying to add networking
I think for bullets: i want to spawn bullets inside the server side. and Using NetworkServer.Spawn(bullteIns)
, Sync bullet spawn to all the clients & Synchronize Damage (variable) using [SyncVar]
I'm following This presentation (Unite 2014 - New Unity Networking in 5.x).
[Command]
IEnumerator CmdBulletSpawn()
But with my countie function. i am not able to do that.
Error: Command function [PlayerInputController:CmdBulletSpawn] cannot be a coroutine
My Question is, How can i spawn bullets in the server side in this case. Is there any method beside using Command. or do i need to change my code.
Answer by Titanium_Fist · May 01, 2017 at 01:07 PM
make the spawner command anormal void function and invoke it from our coroutine function ,make the spawner command an normal void function and invoke it from our coroutine function
Your answer
Follow this Question
Related Questions
SyncListString not changing in a Command 0 Answers
How To Send [Command] From Mouse Input Of The Local Player 1 Answer
Trying to send command for object without authority - on a networkidenity with local authority 2 Answers
Transform.parent not set on clients UNET 0 Answers
Cmd is called on Server ERROR!?!! 0 Answers