Hello there,
for my next game I plan to add a multiplayer mode and a coop mode to my existing single player setup.
I am currently unsure whether TNet or Photon would be the better choice to do this. Given that TNet is much cheaper than Photon, I decided to give this a try and so I followed your tutorial video on how to setup TNet from scratch.
Well my FPS setup uses the standard FPS Input + Character Motor + Mouse Look scripts. If I am not entirely mistaken (and please forgive me, I never touched the networking part of Unity or TNet before) all I had to do was the following to add basic multiplayer support to the game:
1. Create a TN Manager object (script) + TN Auto join in the main menu scene
2. Add the Player Prefab to the TN Manager array. Call the Tnets connect function via the 'Start Game' button.
3. Declare the Game Scene in Auto Join (+ a few other parameters).
4. Go to the actual game scene and add TN Create -> assign your Player Prefab to the array and uncheck 'persistent'.
5. Edit the Player Prefab: Add TNObject and TNAutoSync to it. Set TNAutoSync to UnityEngine.Transform position; updates per second = 20; and check Only Owner Can Sync.
6. Following the tutorial I added a custom cs script to the prefab with the following code:
public class Game_Player : MonoBehaviour {
// Use this for initialization
static public Game_Player instance;
void Awake() {
if (TNManager.isThisMyObject){
instance = this;
}
}
}
7. Start the server, start a few clients and check out what's happening!
Now starting the server (external exe) and connecting to it with a few clients works just fine. However each client is controlling each avatar at the moment he joins the server.
It's like
everyone is controlling all players at the same time... I don't understand this as I checked the 'Only owner can sync' checkbox at the AutoSync script for the Player Prefab and all Player Prefab (Clone)s do have a unique TNObject ID...
Any help with this is highly appreciated! I have the feeling that I made a pretty obvious and simple mistake...
Best Regards,
Jake