Hi everyone, I’ve been searching for hours in the forum and watched a bunch of tutorials, but I don’t find how to do what I want.
(I’m not fluent in english, please excuse any mistake !;-).
I’ve a very simple game for 2 players that works really nice in « solo » mode (versus an AI computer). Now, I’m trying to make this same game work with 2 players (2 humans versus). So I started to work with the network solution built in Unity. I use the free LobbyManager asset. Works fine to match game instances.
But, every time I see a tuto or an documentation, the player example is always defending himself. That’s frustrating ! My problem is :
- How to tell the « spawned players » which object, already existing in the scene, they have to protect. (« Host gamer you are at position A and must protect existing Weakpoint A », “Client gamer you are at position B and must protect existing Weakpoint B” ) ?
This is in order to make the weakpoint X be able to tell the player X « hey boss, I’m hurt, take Damage ! ». It already works fine in the non-network version (myProtector.TakeDamage(int x)). But, in the network mode, I can not figure a way to associate a pre-existing WeakPoint gameObject to a spawned player (and vice-versa).
I’ve tried so much ways ! The last fail : make a parent containing the weakpoint & the player (so the Weakpoint (child(0)) can know that it’s protector is transform.parent.getChild(1)), but when the Network Manager automatically spawns the entire group, the player SyncVar does not work anymore, neither the Sync Transform (I think because the player is then a child object in this case).
Any little help, even on a small parts, would be a big step for me. (I’m working with C# freshly learned). And if I’m misunderstanding a concept, please tell me :).
Thank you.
Cédric.