UNet Sample Projects

What? What is this madness? Have they been updated? Is unet a little better now?

I’ve been getting to grips with Unity Networking for a few weeks now, and whilst initially it seemed impossible to reproduce what I could do with Photon, as things have ‘clicked’ and I have got my head around the way a server authoritative system works, I’ve found that it actually works very well. In fact I’ve found that there are a number of things that are easier to implement with Unity Networking compared with Photon.

Admittedly there still seems to be a few bugs, and documentation is particularly poor in a lot of places. It’s worth noting however, that a number of what I first thought of as bugs, actually turned out to be as a result of my misunderstanding of how things worked.

I’m by no means a Photon networking expert, but having used both I’ve found that I already prefer Unity Networking, and as it continues to develop I can only imagine that preference will strengthen.

1 Like

@Munchy2007 if you do things yourself, there’s no problem, sure… but @tonyBkln thanked them for the sample projects, which utilize the network transform component. You can start 2 instances of the project running on 127.0.0.1 and there’s still - in that ideal networking environment - desync between the server and client lol

Hi Guys!
Does somebody know how I can find and connect internet match in WebGL?
I created new topic, but no one answers.

Maybe someone can tell me, how I can find and connect internet match in WebGL(UNET) ?
Thanks in advance

NetworkManager.useWebSockets = true;

Yeah, I enabled webSockets. I can create local match, but I dont understand how I can find intenret match(matches list) and connect someone (not localy) in WebGL. MatchMaker doesn’t work in WebGL

MatchMaker not supported. For more information, please ask in a new thread.

Ok, thanks. If you can give an answer, please do it in this thread.
http://forum.unity3d.com/threads/how-connect-to-server-in-webgl.380180/
It is very important to me now.

I have a lot of problems with syncvars when I have a mix of strings, ints and sturcts in my script in 5.3

The data you’re trying to sync should be as small as possible. Are you trying to sync a string over the network? Are you trying to sync a struct over the network?

See what you can do to make changes so that you’re only syncing ints. If these strings are from a set of known ones, maybe change it to an enum so you can sync with ints.

They are small, the sting contains “h” and another is “” and the struct has only 3 floats

If I get size errors then I can use a fragmented channel. The serialization gets messed up I guess.

Ah. Either a 5.3 bug or a bug serializing your struct. Maybe you can log the variable on the server and see what’s being sent?

This is strange, actually the next time I did it, it worked. Maybe a code generation issue or something. As soon as Sean comes back to forum I want to ask him about when and how code gen happens, the bad thing is that it’s done in IL and on DLLs so it’s a little time consuming to debug but still worth taking a look at. However SyncListInt doesn’t work , at least I could not make it work.

Haha sometimes a small change that does nothing will have unity recompile… and maybe the bug went away in that time.

Actually I have an issue still in a specific case which I could not reproduce in a minimal project. I get InDexOutOfRange exception when initializing object from syncvar message at client and I changed channel to ReliableFragmented as well but it didn’t work. Should pin it down.

I have been building off the NetworkStarter example. It works with one killer issue, after about a minute or so the client will get disconnected from the relay server. It’s almost as it the client was intentionally dropped. The player who created the game does not get disconnected and can continue to play. Anyone else experiencing this?

I’m certainly looking into using approach #1, thank you for these detailed explanations.

I just started following the Unity networking tutorial, it works but it is using NetworkTransform (its horrible at this point), can you please provide me a script example how to sync the player’s movement.

Even if its using this simple script provided by the tut:

using UnityEngine;
using UnityEngine.Networking;

public class PlayerMove : NetworkBehaviour
{
    void Update()
    {
        if (!isLocalPlayer)
            return;

        var x = Input.GetAxis("Horizontal")*0.1f;
        var z = Input.GetAxis("Vertical")*0.1f;

        transform.Translate(x, 0, z);
    }
}

What I am trying to achieve is a moba-style game where the player is the host and allows up to 7 other players to join. So I would have to sync their positions as well as up to 3 projectiles/bullets per player per 10 seconds.

On impact this will cause damage and/or add force to the impacted player. I am confident once I have a starting point I can make it as elaborate as needed myself.

I’ve read a lot of mixed reviews regarding uNet, I hope this is possible to achieve, at this point is is moot.

Thank you all.

@zKici I have moved quite a bit away from unity in general at the moment. And when I return to it I doubt I will use unet very much at all. I’m doing a lot of ajax and server stuff for my job so I think I’d be better off running my own server solution and creating sockets with c# instead of a unity class.

As for unet, all I can say is that my best attempt at it a few months ago was still a major failure haha. No networking solution is 100% lag free so there are some things you kind of just have to deal with, but until unet has better support and examples that don’t have desync immediately on localhost, I’ll be rolling my own solutions.

My latest approach that was somewhat successful with unet was to have most of the game offline and singleplayer then later add in an object that interfaced with a server and received information for moving ‘network dummies’ that represented where other players were. I imagine this is more efficient than unity’s solution of having the full class of each player for every machine and different logic based on whether or not that instance owns whichever player.

It would appear that in my quest to reinvent the wheel, I’m coming up with less complicated solutions that are easier to use than unet. I believe that means it has failed as an attempt to be an easy introduction to networking :smile:

Thanks for the quick response, do you have any trials / experience with Photon Bolt and/or Photon PUN+?

If so would that be my best suited approach for this?

All I can tell you about photon is that I haven’t used it, but it needs a windows OS to run.

Regarding networking in general - make small enough projects to grasp how the system works right now and then check on it frequently for updates. I can’t really say much :stuck_out_tongue: I had a few small projects and they were unsuccessful.