#Player not spawning if AI does and AI doesn't if Player is.
40 messages · Page 1 of 1 (latest)
It's an RTS game. I've got a main player prefab that controls the units. I need to spawn it twice, once with autospawn and a second time with the line of code above for it to be spawned on both the client and the host's side. The problem is that unless I'm "spawning" it twice, the client will be spawned or instantiated but his hero unit won't be spawned. And if I remove it, from the inspector, the player will be sapwned but his units won't, and the ai will. The Ai needs it not to be instantiated twice. And I got not relevant errors in the inspector. When I get home, I'll make a video and show pics of the inspector. Thank you.
I need both the enemy A.I. heroes to spawn and the main player prefab as well. I'll record a video with the build and post it here in a moment:
This is the steam demo version with two players. A host and a client. This version has the "MainPlayer" prefab as the Player Prefab and the unit spawner prefab in the network manager. Unless I assign the "MainPlayer" prefab in both fields in the inspector, the client won't be able to spawn units, bu the ai will spawn:
I'll make a second build without the "MainPlayer" prefab assigned a second time and show the game from the client's side.
Seems odd that input controls work in offline...no idea what you're controlling. The errors from steam failures may or may not be interfering. Are we to assume that whatever you put in the Unit Spawner Prefabs list is getting properly registered, or is that prefab (other than what's in Player Prefab) also in the Registered Spawnable Prefabs list below that?
Sorry for the late respone. Unity crashed and I had to reimport everything because all of my scripts broke. The game has an offline and an online mode. The "Unit Spawner Prefabs" has nothing to do with network identity. It's the main player prefab which for some reason doesn't get assigned a hero unity unless it's spawned "twice" with "OnServerAddPlayer"
With the override.
The steam failures only happen in the editor, but work as intended on the steam demo.
I'm also using dissonance. The voice chat works in both cases. The "MainPlayer" prefab spawns. The "Hero" unit isn't spawning for the "AI", if I make it spawn for the client, if that makes sense.
put the whole of your custom network manager in https://pastie.io/ so I can see what you're doing
It's a mess, I know.
how is the hero ending up in DDOL?
I added a Don't destroy game object script to the hero, but that doesn't prevent it from....hmmm.
Oh, wait.
Ye.
Ok, so the hero got instantiated for a moment, then got destroyed on the client's side. So I had to ensure it wouldn't.
that's not how you ensure it doesn't - find what's killing it instead
and don't put it in DDOL in Awake in any case
Ok, removed the DDOL from the hero.
I can't tell from the code if URTS_UNET is valid or not, so I don't know what code is running
It's a symbol. Everything under if works.
I know what it is, but can't tell if it's a valid symbol in your project 🙂
Oh, yeah, it is.
I mean, it works.
Ok, the DDOL is no longer necessary. I don't know why but the hero unit isn't being destroyed any longer.
No, for the player.
The ai is still not spawning.
I'm sorry, my bad, I should've been clearer. I'm a dummy. The Ai is still not spawning, but the player isn't being destroyed.
Hero in the Unit Spawner Prefabs list and MainPlayer in Player Prefab? add debug logs to Awake and Start and OnDestroy to figure out what's happening from stack traces. Make sure you're not suppressing any logging anywhere...enable everything including warnings.
Hero in the Unit Spawner Prefabs list and MainPlayer in Player Prefab? Yes and yes. Will do and return.
Will add debug logs.
But this isn't the issue either, the heroes spawn once I remove the mainplayer prefab from the "OnServerAddPlayer" override. But if I do that, it's back to square one, can't spawn units.
well first disable that Animator to get rid of that log spam
or enable Collapse
so you have some sanity to work with
All right. Did that. Collapsed. Hmm.
and disable the call to RTSToolkit.RTSMultiplayer:Cmd_AddNation in RTSToolkit.Diplomacy:AddNewNation until you can fix it - you can't pass prefabs through Cmd's