extending operations on island Demo

thetnswe
thetnswe ✭✭
edited February 2011 in Photon Server
Hi.. I've got a few questions about Operations..

Q1. In the Unity Island demo, why are you just storing only float[2] for positions? I understand that you're syncing with Wingrid demo and Position is calculated from Terrain and Camera position... But anyway if you're syncing player's avatar, you're gonna need to store Y position anyway. How can I extend that?

Q2. To Sync all the position, rotation and animation states for every characters in MMO, do I need to add new operations for each extended? Now I am trying to add Rotate Operations to sync the rotation values between avatar in different clients.

Below is my approach to extend the operation..

public static void Rotate(Game game, string itemId, byte? itemType, float[] rotation, bool sendReliable)
{
var data = new Hashtable { { (byte)ParameterCode.Rotation, rotation } };
if (itemId != null)
{
data.Add((byte)ParameterCode.ItemId, itemId);
}

if (itemType.HasValue)
{
data.Add((byte)ParameterCode.ItemType, itemType.Value);
}

game.SendOperation(OperationCode.Rotate, data, sendReliable, Settings.ItemChannel);
}

but SendOperation doesn't know OperationCode.Rotate and it seems to be handling from the server side... Do I really need to access the server code everytime I add the new operations? Or is that any way to store Rotation data in the Item without touching on the serverside?
«1

Comments

  • In the other topics, if we want to add more operations, we've to extend Operation.cs from the MMO server... What's the difference between the Operations.cs from Client side and Operation.cs in server side.. In the Island Demo, Move() is defined in client side and also I found out Move.cs extended from Operation.cs in server side although the server side dlls are not loading from the Unity.. Where do they load it? if I have to fix the serverside code, how can I update the new dll?
  • Another things that I am unclear is why do we have different type of classes with same name on the different namespace.. For example, Item.cs contains in the client side and also on the server side ... And also the server side contains another dll that also contains Item.cs on the different namespace.. I am really confuse.. :( can someone help me.. please
  • Many questions.. I suggest you walk through the basic server setup guide (doc folder the last time I checked). With that you will probably be able to understand the architecture in general and the demo projects better.
    As for the rotation in the island demo, I believe that it is already synched so no need to add it. The animations could be synched with raise event or set properties.
  • About the why there are same class names in different name spaces:
    The classes in the server namespace are unknown to the client, the client namespace is unknown to the server. In general these classes interact through rpc calls (operations, events). Client classes do not require any thought about thread safe access since everything in the client runs in one game loop. The server is multi-threaded and therefore all classes require special handling. since you were asking about item class a bit more specific: server item is a major part of the interest management framework, client item only a container for properties and position and so on.
  • thetnswe wrote:
    In the other topics, if we want to add more operations, we've to extend Operation.cs from the MMO server... What's the difference between the Operations.cs from Client side and Operation.cs in server side.. In the Island Demo, Move() is defined in client side and also I found out Move.cs extended from Operation.cs in server side although the server side dlls are not loading from the Unity.. Where do they load it? if I have to fix the serverside code, how can I update the new dll?
    Operations.cs in the client contains the RPC calls to execute operations on the server.
    Operations on the server are dispatched by operation code (look for switch case statements). Operation subclasses like Move.cs convert the hashtable sent by the client to a class with properties. Pretty much the same happens with Event subclasses, just the other way around: class properties are converted into a hashtable that is dispatched with EventAction on the client. As I wrote before, I highly recommend that you walk through the blank server setup guide - it will make your life with photon a lot easier.
  • ok... thanks for it.. Can you please give me the links of how to setup the blank server processes?
  • There should be a PDF in the doc folder in the server SDK that you downloaded?
  • I don't undertand one word from you "As for the rotation in the island demo, I believe that it is already synched so no need to add it." .... Why the rotation is not needed to synchronise.. I don't see any rotation sync in island demo.. What if I am replacing characters with my own whici is not capsule, the items moving looks awful..
  • The unity client avatar is a cube and not a tube like the win grid avatars.
    If you start two unity clients and change the rotation with the mouse look direction you will see the cube rotate on the other client.
  • did you mean that Photon.MmoDemo.Client.UnityGrid where it's avatar is a cube... I think it doesn't provide feature for rotaion sync... And I don't understand why you sync only x and z positions and I can't even change the Y position too.. in the island demo example, you set the Y pos from the terrain and cam height.. What If I don't have terrain? I think we also need to sync Y pos too
    if (Input.GetKey(KeyCode.Keypad8) || Input.GetKey(KeyCode.W))
    {
    this.MoveRelative(Game.MoveUp);
    }

    if (Input.GetKey(KeyCode.Keypad4) || Input.GetKey(KeyCode.A))
    {
    this.MoveRelative(Game.MoveLeft);
    }

    if (Input.GetKey(KeyCode.Keypad2) || Input.GetKey(KeyCode.S))
    {
    this.MoveRelative(Game.MoveDown);
    }

    if (Input.GetKey(KeyCode.Keypad6) || Input.GetKey(KeyCode.D))
    {
    this.MoveRelative(Game.MoveRight);
    }
  • That is not true. X and z are only synched for the win grid because it's 2d, the unity client syncs 3D, you can even jump (with space).
    And there is rotation sync - just tested it when I submitted the 2.4.6 dll.
  • may be we're looking to the different Unity demo... Which demo are you talking about... There are only four Unity Demos and nothing of them can do any jumps and rotation... unless the island demo use Fps controller, it doesn't sync rotations... Here is the list of demo that I found
    demo-realtime-unity
    Photon.MmoDemo.Client.Unity3D
    Photon.MmoDemo.Client.UnityGrid
    Photon.MmoDemo.Client.UnityIsland

    If possible, can you give me the link to download the project you're talking about
  • UnityIsland. Included with the SDK.
    Maybe something got overwritten when you merged the code with the original island demo?
    Or have you been talking about the unity grid all the time?
    If so, please check what the island can do.
  • nope.. I was talking about the island demo all the time.. For me, the island demo doesn't even see players from the other clients.. Now I got one more problem.. I just upgraded to Unity 3.2 and some of the demos are not working anymore including island ones... Have you checked that it's compatible with Unity 3.2?
  • If you're free, can you please upload the successful integration of island demo with ur Photon.... My version just doesn't work like you said and there's no graphics placed on the FPS controller so there's no way to see the cube anyway... Now, i upgraded to 3.2 and downgrade to 3.1 back and the radar doesn't work anymore seems to be that the player's information is not sending anymore...

    One more question is that how did you sync the rotation and y position .... The only player information send to the server is done by the following code and it just send float[] value for position and not even the Y Position... So .. how did you sync the Y Position and also the rotation?

    this.engine.Avatar.MoveAbsolute(GetPosition(this.transform.position));

    Note : Other demos are still working..
  • thetnswe wrote:
    For me, the island demo doesn't even see players from the other clients.. Now I got one more problem.. I just upgraded to Unity 3.2 and some of the demos are not working anymore including island ones... Have you checked that it's compatible with Unity 3.2?

    I seem to have a same problem with IslandDemo after upgrades to Photon 2.4.5/Unity 3.2.0. Cubes of other players nor actor text is being created in unity, radar is working as well as actors from WinGrid demo (cylinders).
  • It worked for me with 3.2 - server has to be compiled with the 2.4.6 photon.socketserver.dll.
    the only thing in 3.2 is that the graphics look a bit weird. trees are very shiny.
  • We will soon provide you with a complete sample download. The issues which arise due to merging the files are simply not necessary.

    In the mean time, you should try to follow the steps to merge the demo once more - with a clean start from the SDK zip.
    The readme.txt in the demo's folder provides trouble shooting tips for known problems. Also described here: http://developer.exitgames.com/mmo/unityislanddemo.
  • I did this 50 times before and it always worked I'm either totally dumb today, or something changed and I really need photon.socketserver.dll (2.4.6) which I can't find anywhere is it about to be released yet (all I have is 2.4.2)? Tree glow problem was there since Unity 3 released. Its related to underwater effects (trees should glow when under water, right now they work the opposite) otherwise i'm not aware of any other shiny trees problems. Also it has to do with fact that Island Demo is being outdated as its Unity 2.x demo, was replaced by Bootcamp to better demonstrate new features of Unity 3.x. Maybe Photon demos should make the same transition. I can't get Bootcamp to work correctly with Photon yet and your support would surely help me a lot :).
  • check here for the update: viewtopic.php?f=5&t=397
    official release is scheduled for tomorrow.
  • Xeevis wrote:
    I can't get Bootcamp to work correctly with Photon yet and your support would surely help me a lot :).
    you will be happy to hear that we are about to release a lite lobby bootcamp demo.
    bootcamp uses much more resources so I 'm not really sure if it's a good fit for an MMO world.
  • I think it is actually cause its the one unity example that shows best that dirty tricks to fake stuff are more important than having the "real thing" as the bootcamp is full of fake with only little "the real thing" :)
    also if you set the rendering to not use deferred it will be worlds faster :)
  • Boris wrote:
    you will be happy to hear that we are about to release a lite lobby bootcamp demo.
    bootcamp uses much more resources so I 'm not really sure if it's a good fit for an MMO world.
    I am making small high-quality MMO project as kind of a demonstration/proof of concept (not actuall game) to learn and test enough to actually make full scale MMO. Bootcamp is great as it demonstrates new capabilities of Unity and encircles much more advanced aspects to toy with (working model/targeting/interactive UI/locomotion/etc). I can play with it and learn faster than working with shallow Island :). In case need arise it can be stripped down which is also a good excercise. I was able to find other peer just positioning was all wrong, im not in a hurry there I have entire server package full of game content to update and merge with photon :). MMO demo would be great but I can surely work with lite lobby if positioning part is at least somewhat similar.
  • Hi Boris.. you haven't answered this question yet ... please :) and what do you mean recompiling using server dll 2.4.6... Which projects do I need to recompile in the server SDKs?? Can you please explain in more steps of how can I do that?

    One more question is that how did you sync the rotation and y position .... The only player information send to the server is done by the following code and it just send float[] value for position and not even the Y Position... So .. how did you sync the Y Position and also the rotation?

    this.engine.Avatar.MoveAbsolute(GetPosition(this.transform.position));
  • you have to copy the new dll to the lib folder and recompile mmodemo.server and copy the new build to the photon deploy directory.

    About the position and rotation sync:
    Player.cs line 141 in Photon.MmoDemo.Client.UnityIsland\Assets\Photon
    this.engine.Avatar.MoveAbsolute(GetPosition(this.transform.position), GetRotation(rotation));
    
    and line 71
    public static float[] GetPosition(Vector3 position)
        {
            float[] result = new float[3];
            result[0] = position.x * MmoEngine.PositionFactorHorizonal;
            result[1] = position.z * MmoEngine.PositionFactorVertical;
            result[2] = position.y;
            return result;
        }
    
  • Hi Boris...
    then I am sure that I am getting the wrong version of the MMO Demo as my player.cs doesn't have this

    this.engine.Avatar.MoveAbsolute(GetPosition(this.transform.position), GetRotation(rotation));

    instead of this
    this.engine.Avatar.MoveAbsolute(GetPosition(this.transform.position));

    there hasn't got any parameters for rotation and MoveAbsolute() only accept position value... Here is the function MyItem class
    public bool MoveAbsolute(float[] newPosition);

    Please re-check the demo that you're providing for download..

    Thanks
  • Are you maybe working with ExitGames-Photon-MMO-Demo_v2-0-5-1.zip instead of ExitGames-Photon-Server-SDK_v2-4-5.zip ?
    just checked ExitGames-Photon-Server-SDK_v2-4-5.zip, it's definitely there.
  • yes.... then I am totally wrong from the start.. lolz ... why do u have two similar version of it..... thanks for pointing me to the right project...
  • that explains a lot :)
    the one you used is in the "previous releases" section, it used to be a separate download.
  • I still have the weird subscribe/Unscribe behavior after updating 2.4.6 dll and also recompiling the whole project... the player from other clients disapper after 2 secs of creating it.... and they never appears if you don't make your view size to maximum at the program start...