Implimentation choices?

Options
microdot
edited July 2011 in DotNet
This is awkward for me, usually I don't struggle with new concepts from systems I haven't worked on before but I am looking to the community for some advice relating to Photon implimentation.

I am working on a realtime "racer" with many MMO characteristics. These ideas and concepts are not really public domain but I need to know whether Lite or MMO is the way to go. Perhaps my question isn't too clear - potentially because I've never used Photon.

I must stress I am using realtime physics (of course) - and updates need to be quick. I am sure I'll have to build in prediction algorithms but for now, let me just get started with the basic concepts.

Which out of the Unity3D demo's should one be looking at for the above requirement.

Regards,
Micro.

Comments

  • Boris
    Options
    The focus of the mmo demo is open world interest management, I don't think that is what you need for a racer. Lite is designed for rooms that don't need a more granular interest management so everyone in that room receives everything from all other players in the same room. I'd say you should go with Lite.
  • Kaiserludi
    Options
    If you would want to implement one huge track consisting of for example ALL public roads of a whole country and all this is one huge single racetrack with many thousands of players in the same race, then something like MMo would make sense for you, as it would for example handle for you, that you do not get every position update of every vehicle thousands of km away from you, which you could not see on the screen anyway, but that you still get all the updates from opponents, currently not so far away from you, and such things.

    A typical racegame with a few dozens or less players per race would be a perfect match for the room-concept of Lite, which manages for you, that you only get position updates (to stay with the example), etc. from players in the same race.
  • Thank you to both of you! It's doesn't get clearer than that. I guess one can get sidetracked by dynamic streaming content for example which has nothing to do with either of these implementations.

    Lite it is. Now to get a grip with the demo and I should be all set.
  • Okay, I'm back. After poking around in the RealtimeDemo code, I decided to try the process out for myself. After setting up a blank object for the scripts and configurign as in the demo I'm presented with the following events:

    in PhotonClient.cs, method internal virtual void Connect()
    this.Peer.Connect(this.ServerAddress, this.ServerApplication);
    
    returns true (correct details for connect).

    in Game.cs, method public override void Update()
    this.Peer.SendOutgoingCommands();
    
    is executed, meaning that if either that, DispatchIncomingCommands() or this.Peer.Service(); is executed that the callback
    public override void PeerStatusCallback(StatusCode statusCode)
    

    should be hit... it never does. Where should I focus effort looking at possible causes for this problem?

    Thanks in advance
    -Micro

    PS: Tried with both debug and release builds of the dll's - no change.
  • Interesting, it's working now... reimport of assets and all is well. If anyone can explain this please do. For now - happy to have some progress.
  • Tobias
    Options
    Sounds weird.
    Maybe the server was not ready to take connections yet and you would have to wait for a timeout (which takes much longer than a regular response)...?
    I don't have other ideas. Maybe something was "stuck", if you say reimport helped.

    At least, it's working now.
  • Thanks Tobias.

    Quick question, because it would seem that this is the only way around my problem at the moment. In the demonstration ..\Photon-Unity3D_v6-4-1_SDK.zip\demo-realtime-unity

    DemoGUIAndInput.cs controls the cube movement and any gui rendering for the spawned player object. The control is seperate to the player object itself. The player is simply a prefab loaded at runtime per spawn in the environment. In my current implimentation - pre netcode - I have prefab with many scripts attached to it - one of these scripts is control as well as GUI.

    Do I have to re-engineer the entire gameplay mechanism to have control in a DemoGUIAndInput type class instead with all the current logic removed from the player prefab? This is a lot of work but need to know.

    Regards.
  • Tobias
    Options
    You definitely don't have to follow the code- and control-style as implemented in that demo.
    Do it any way you usually do or any way Unity does this usually.

    I had special requirements in our demo: I wanted to re-use the networking code and the "logic" it has for different platforms with very different code for the visual stuff. That's why the game and player are not related to anything Unity-specific (like input).

    A nice side-effect of this separation of logic and visuals is: You can now run multiple game instances in parallel and control any of those.
    This is good for testing in some cases but definitely not in each case.
  • sebako
    Options
    for unity I'd suggest you to keep logic as separate as necessary. For example camera control should be one script while you need to maintain maybe keyboard input at the same time. But keyboard input should not be handled by the camera control script - so you need to find a way to make them work together. Unity itself has plenty of methods doing that, such as Sendmessage, finding GameObjects and such.
  • Thanks - yet again - for the quick feedback. Making more sense now - you'd definitely want to keep the logic unrelated to Unity if your demo's.

    Let me play around a bit more and in the meantime 2 more questions:

    1.) Interpolation - build in on internal receives for each player or something that needs to be implimented by myself at some point.
    2.) Is there a way to determine whether the view you're receiving updates on is in fact yours? I recall having some problems where I intercepted GUI updates for other players. This is because original code didn't have more than one human player, along with some AI.

    Thanks again!
  • Tobias
    Options
    1) Interpolation is not built in. You have to solve it - this can be easy or complicated, depending your game's requirements.
    2) In Lite (the room-based server logic, we provide), every player gets a ActorNumber assigned. It's easy to compare yours with those of events. Plus: by default, Lite does not send events back to their origin. You don't get your own events this way.
  • Thanks Tobias,

    Interpolation is easily solved so not a problem. The ActorNumber I'll have to investigate, I mean the scene is loading a cloned prefab for each entity, 0 - n. If you are player 0, locally and 1 - n are the players in the room, how do you intercept ActorNumber?

    Is this attached to the cloned prefab? Either way I'll check it out later tonight - think implimenting a workable solution there after is fairly straight forward.
  • Tobias
    Options
    ActorNumbers in Lite start with 1. You could use 0 if you're not yet in a room and if the server is sending an event (useful if your room is maybe steering AI enemies or sending other event on its own).