comparing between different Unity examples.

Options
thetnswe
thetnswe ✭✭
edited February 2011 in DotNet
Hi,
I am really confuse of what the examples for Unity does. You have island demo and realtime demo which is using different structures of Photons and I am really confuse of which one to use for my project. Realtime demo write their own game code by extending IPhotonPeerListener where as the island demo has got Game class in the dll and there's no way to add our won specific features and it also doesn't contains information for all the player inside one world. Although it's using item approach and consider all the players as a item and also it doesn't have feature to send events across the player where as it does in realtime Unity demo.. But I think the island demo is more advanced and it also has all the MMO features such as interest areas and etc...

Can you please guide me of how can I store all the players information into the server and also how can I send the events to all the peers in the island demo?
«1

Comments

  • dreamora
    Options
    You would need to integrate DB related functionality to store anything persistently, on which you can find dozens of articles on the web for C# + MySQL and alike.
  • Boris
    Options
    The demos show what the server can do for you.
    The client implementations are different because different developers made them.
    Both approaches are probably not ideal and many developers will favor even another approach.
    The mmo client lib uses a dll because it allows the unity island and the windows forms client to use the same code.
  • Tobias
    Options
    By the way: the code for the used "mmo" DLL is available as source. Just open the solution file in Mono Develop or Visual Studio and change where needed. It's just easier to copy the assembly and not re-compile it in the Editor everytime you build.
  • thetnswe
    Options
    Can you please tell me where is the source for the Photon that uses in the island demo.. I was looking for it and couldn't find them... I saw the Game.cs implementation on dotnet client and it's not the same..
  • Boris
    Options
    Projects
    Photon.MmoDemo.Common
    and
    Photon.MmoDemo.Client.Unity3D (includes files found in Photon.MmoDemo.Client.DotNet)
  • thetnswe
    Options
    I've got a few questions that I don't understand.

    Q1.. How do the player's avatar get registered in the item list? I didn't see any spawn function called while creating player of my own where the other items are created using "MMOEngine.AddItem(item);
    item.Spawn()" functions.

    Q2.. how to access the list of items that're being created from the Dictionary<byte, Dictionary<string, Item>> Items which is from the game class?

    Q3.. What does the NPC class do?NPC Item is inherit from Item class so what I think is that the Photon server handles all the clients and NPC as item and they're distinguished using the type?
  • Boris
    Options
    Q1.. How do the player's avatar get registered in the item list? I didn't see any spawn function called while creating player of my own where the other items are created using "MMOEngine.AddItem(item);
    item.Spawn()" functions.
    item.UpdateInterestManagement() does the trick.
    item.Spawn() does the same.
    Q2.. how to access the list of items that're being created from the Dictionary<byte, Dictionary<string, Item>> Items which is from the game class?
    the byte key is the item type. So usually it would be "(byte)ItemType.Avatar".
    Q3.. What does the NPC class do?NPC Item is inherit from Item class so what I think is that the Photon server handles all the clients and NPC as item and they're distinguished using the type?
    an item is just the representation (the avatar) of a player or a npc. so class npc would be the controller of the item, like the actor is for a normal player.
  • thetnswe
    Options
    Thanks.. for the quick reply... :) I will try to understand the Photon structure and will update any new status...
  • thetnswe
    Options
    I still have some problems accessing the item list that the server handles.

    Q1... Radar class can count how many items are created no matter what application they're creating from.. I create a new class that count how many avatar are in the world and so as Bots.. It seems to be wrong when accessing Items "Dictionary<byte, Dictionary<string, Item>>" . It just count the local item/avatar count and doesn't update the item count if created from another application. How does the Radar class works? The only thing that I see from the Radar class is

    if (!this.itemPositions.ContainsKey(itemId))
    {
    this.itemPositions.Add(itemId, position);
    return;
    }

    this is kind of confused to me. It just check whether the player's avatar contains or not. If so where does other positions comes from which contains in the itemPositions list. I don't see anything added to that list but they're already in there.
  • Boris
    Options
    the Dictionary<byte, Dictionary<string, Item>> contains only the items that have appeared in your interest area, that's why there are less items in it.
    The radar receives all position changes of all items in the world in a slower interval. It's meant to showcase what's happening in the world, normal mmorpgs would not have this.
  • thetnswe
    Options
    Hi.. I think there's something wrong with the server.... I also count the number of avatar and it always show 1(for my Avatar) where it suppose to show 2 avatars as I opened another instance of this application which seems to spawned at the same position..
  • thetnswe
    Options
    Also.. can you explain how did you get all the item positions and add them into the radar coz I couldn't find when did u add the position lists to the radar..
  • thetnswe
    Options
    sorry for posting too many post. I solved this item count as you're right that it doesn't create item unless you're in the interest area... But I still have one more problem while accessing the avatar. I build my MMO world and run two instances of these applications. ALthough the items created from both parties are known, it always show one avatar while accessing the avatar item information.
  • Boris
    Options
    the radar is updated with event RadarUpdate.
    I don't understand the other question, can you please rephrase?
  • thetnswe
    Options
    when I run two instances of island demo and adding some AI from Win grid demo, the radar can show exactly where the Avatar and AI positions is ... But when I print out how many avatar in the world, it only have two assuming that it know the owener from Wingrid demo as a avatar and the one on your self. It doesn't know the avatars from other instances of the island demo no matter what I create a new instance of the island demo, it show only two as a avatar. So.. How did you subscribe an item as a avatar on the Win Grid Demo coz avatar subscription on the island demo seems to be wrong.
  • dreamora
    Options
    Thats because the AIs are no real avatars.
    they are minions of the win grid avatar (they aren't spawned as own things but as things owned by the win grid actor that joined) and the win grid is also updating and controlling them.
    if you want them to be real avatars, you will have to use real clients or make the server spawn new AI Avatars and manage them, not client controlled & owned "item minions"

    Counting the avatars will really only tell you the avatar and that would be the island demo clients + win grid avatar. Unsure out of head if the function gives you all or just others.
    Also keep in mind that the client when you ask him about the avatar won't tell you the global number (that would be horrible and definitely undesireable), it will tell you the number of them in its sync range. Not globally
  • thetnswe
    Options
    Hi..
    I know that AI's are not avatar type... What I really want to know is how can I register myself as an Avatar? I am running two clients and it's s just showing as one avatar. In the Island Demo, client itself doesn't subscribe as an avatar "

    Player playerBehaviour = (Player)player.AddComponent(typeof(Player));
    playerBehaviour.Initialize(this.engine, EPlayerType.ELily);
    this.world = game.WorldData;
    this.selfId = game.Avatar.Id + game.Avatar.Type;
    Operations.RadarSubscribe(game.Peer, game.WorldData.Name);

    "

    although they're not subscribing as a avatar, the avatar counts become one..... and it's always be the one unless you're adding owner from the wingrid demo which assuems that the wingrid demo is adding PhotonPeer as an new owner.
  • dreamora
    Options
    Taht code there is just the unity side.
    The real Photon related handling, subscription etc in general hides behind the "initialize" / the game class / the assembly you put into your unity project whichs sources you have in the servers SLN (you can't have those in unity as unity has a multithread-phobia ;))
  • thetnswe
    Options
    so... what you means is that I shouldn't do it as it will only counts upon you coz it creates only at Unity side.. So. what is the anotheer approach for achieving what I want?

    The avatar for the client is added as an item type avatar into the game as soon as the Game object is created . So.. theoritically, if I play two instances of island demo, it should create two avatars right?? But when I pritn the avatar count, why is it always becomes one no matter of how many instances that I am running ... This doesn't also deal with camera interest area as the avatar spawn from the island demo are on the same position and they should be able to see each other..
  • dreamora
    Options
    I'm unsure what the avatar count represents in detail, haven't looked it up.
    But its possible that it tells you how many remote avatars you see / have in sync range in which case it would not count you so the real avatar count in sync range is what it tells you + 1 so Remote Avatars + Local Avatar
  • thetnswe
    Options
    i made the range to 20000 x 20000 so it basically means that the player avatar can see every items in the world... But it's just not counting up for the instances of other Applciations unless you're creating from Win-Grid demo...
  • dreamora
    Options
    I thought when you login with 2 island demo instances you saw 1
    so assuming it would report only remote avatars the value would be correct.

    also with such ranges you could just as well use litegame but I guess you did for testing purpose
  • thetnswe
    Options
    it always show one avatar no even I open more than 5 instances of island demo even if create the avatar at the same position.. but when I simulate player from Win Grid Demo, they're correct. I think there's something wrong with Game Initialise on the Unity client
  • Boris
    Options
    it think the problem is that every unity client enters the world with the same id "Unity". The island demo does not allow the same Ids and kicks the other client.
  • thetnswe
    Options
    I tried using "this.engine = new Game(this, settings, Guid.NewGuid().ToString()); " to make sure that every client gets the different but it still has the same problem. Although the Win-Grid Demo uses "Environment.UserName + ++this.gameCounter" to get the different ID.. If I simulate more players from the Win-Grid demo and it works perfectly... It just having the problem with running two instances of the same island demo even by using different ID everytime... Have u ever get this kind of problem.. I am really stuck on this and couldn't continue unless it has been sorted out.. Please help me
  • thetnswe
    Options
    By the way, it doesn't seems of kicking clients with same ID as the Radar shows correctly for both avatars running with the same game ID.. and also although the Item.UpdateInterestMangement() spawns the avatar, the callback functions OnItemSpawned() is never reached? Can you please explain me why?
  • Boris
    Options
    Which version do you use? The current one doesn't have OnItemSpawned() anymore.

    Maybe the problem with not seeing others is related to this bug: viewtopic.php?f=5&t=397
    But then again this was a recent change and you seem to use an older version.
  • thetnswe
    Options
    awww. ok ... then I will try testing with the new bug fix ones.. Hopefully it will works :)
  • thetnswe
    Options
    Thanks... I didn't know that you release the new SDK 2.4.5 as I was using 2.4.4... Now this problem is solved.. Thanks so much for your help although I've got alot of questions to ask you about Photon Server. I am really new to MMO development and it becomes a must requirement for our company future project to make an MMO.. But I still have same errors sometimes and I have to restart the Photon service. .Any ideas of what's happening?
  • thetnswe
    Options
    I think it doesn't update immediately and I have to make the application windows update for both instances and it works.. I checked run In Background and confuse why is has got some delays on it?

    Note : Simulated players created from the Win-Grid demo can shows up immdiately and unity instances sometimes never shows up the avatars...