Search Unity

Learning networking?

Discussion in 'Editor & General Support' started by lucidcoder, May 29, 2013.

  1. lucidcoder

    lucidcoder

    Joined:
    Mar 23, 2010
    Posts:
    138
    So I am currently well underway with my current pet-project, a Quake2-like arena FPS. All weapons are ingame, functioning, interacting with physics, and able to transfer "damage" to any objects with a Damage Receiver component. Weapon, ammo, health, and armor pickups are functional. The player is able to interact with physics rigidbodies and explosion forces despite being a Character Controller. All that's missing now is the character models and the actual networked multiplayer aspect of the game. With this in mind, I'm not sure where to go from here. I've done networking with sockets in Java, but getting this working in Unity is something I've never actually done before.

    First of all, where can I start with learning how to set up networked games in Unity? There's tutorials on the asset store, but as an undergrad student on a budget, if I can avoid having to shell out money for a tutorial, that would be most desirable. I'm aware of the Network View component, but I'm at a total loss as to what it's capable of or what the scripting engine hooks are (OnClientConnect? Something like that? I've never done this before, so I wouldn't know.)

    Secondly, there's one particular issue I've had at the back of my mind all this time. The character models have to be visible on the other players' screens, but cannot be visible to the player they are attributed to (think of how the Source engine does this--your character model and your "viewmodel"--the gun you're holding--are two separate things). Likewise, I don't want other players to see a big floating gun in midair, so the gun "viewmodel" (what the player sees in the first-person view) has to only be visible to the player it's attributed to. How are these things accomplished? What kind of scripting or Network View-creativeness is required to accomplish this?

    Finally, do I have to change my code to accomodate for networking, particularly with the Instantiate() function, i.e. when firing a rocket from the rocket launcher? Or can I leave the code as-is? What sort of hiccups should I be on the lookout for along the way?

    Any amount of help would be appreciated!