- Home /
Bullets Only Spawning on Host Client... (a uNet problem),Multiplayer Connected Client Not Spawning Bullets, But Host the is...
Right now I'm at that phase of converting my single player 2D game to a multiplayer 2D game (wow)...
Anyways, I'm having a bit of trouble on firing weapons, like in the title, when I fire my weapons on the host client, the projectiles are drawn on both clients. But as soon as I move over to the connected client and fire my weapons, nothing is visible and a console message pops up saying:
SpawnObject for BulletPrefab(Clone) (UnityEngine.GameObject), NetworkServer is not active. Cannot spawn objects without an active server
I've looked through answers (a little) for some answers, but I was wondering if the way I set up my game had something to do with it, because so far I am using this system to fire weapons: [simplified]
class BaseWeapon: ScriptableObject { [Command] %|-896139254_1|% spawnObjects(...); } [Command] public virtual void CmdspawnObjects(...) { %|852133546_5|% //bullet.rotation = parameterDefinedRotation; //bullet.Direction = parameterDefinedDirection; //etc... //NetworkServer.Spawn(bulletGameObject); %|1320322482_9|% } class AssaultRifle: BaseWeapon { ... override CmdFire() { //Nothing Changed, Just Makes it Fully Auto or Something if (AutomaticFire...) { superclass.Fire } } ... } class PlayerInventory: NetworkBehavior { public Weapon primaryGun; void Start() { primaryGun = ScriptableObject.CreateInstance(AssaultRifle); } } class PlayerFire: NetworkBehavior { void CheckButtons() { if (fireButtonisPressed) { PlayerInventory.primaryGun.Fire(PlayerDirection, InitialPos); } } void Update() { CheckButtons(); } }
(Note: I mostly followed the uNet tutorial and stopped at multiplayer shooting, as it's the part that I'm stuck on right now),Right now I'm at that phase of converting my single player 2D game to a multiplayer 2D game (wow)...
Anyways, I'm having a bit of trouble on firing weapons, like in the title, when I fire my weapons on the host client, the projectiles are drawn on both clients. But as soon as I move over to the connected client and fire my weapons, nothing is visible and a console message pops up saying:
SpawnObject for BulletPrefab(Clone) (UnityEngine.GameObject), NetworkServer is not active. Cannot spawn objects without an active server
I've looked through answers (a little) for some answers, but I was wondering if the way I set up my game had something to do with it, because so far I am using this system to fire weapons: [simplified]
class BaseWeapon: ScriptableObject { [Command] %|792706246_12|% %|-634990858_13|% %|-1407531162_14|% [Command] %|30968305_15|% //Instantiate Bullets //bullet.rotation = parameterDefinedRotation; %|820811585_17|% %|916912317_18|% //NetworkServer.Spawn(bulletGameObject); %|-188920145_19|% } class AssaultRifle: BaseWeapon { %|1925514617_20|% override CmdFire() { //Nothing Changed, Just Makes it Fully Auto or Something if (AutomaticFire...) { superclass.Fire } } %|782288284_21|% } class PlayerInventory: NetworkBehavior { public Weapon primaryGun; void Start() { primaryGun = ScriptableObject.CreateInstance(AssaultRifle); } } class PlayerFire: NetworkBehavior { void CheckButtons() { if (fireButtonisPressed) { PlayerInventory.primaryGun.Fire(PlayerDirection, InitialPos); } } void Update() { CheckButtons(); } }
Please Help...