Giter Site home page Giter Site logo

insthync / litenetlibmanager Goto Github PK

View Code? Open in Web Editor NEW
101.0 11.0 17.0 4.27 MB

Higher level implementation for LiteNetLib (https://github.com/RevenantX/LiteNetLib)

Home Page: https://insthync.github.io/LiteNetLibManager

License: MIT License

C# 99.93% JavaScript 0.07%
unity3d litenetlib hlapi unity-networking

litenetlibmanager's Introduction

litenetlibmanager's People

Contributors

insthync avatar nfmynster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

litenetlibmanager's Issues

SyncFieldIntArray does not sync if only its one value (on index) is changed

So if you do this it does not trigger sync:

SyncFieldIntArray myIntArray = new SyncFieldArray();
...
myIntArray.value[0] = 5;

Because that setter logic works only if whole array is replaced.

My solution was to add indexer like this:

[Serializable] 
    public class SyncFieldIntArray : LiteNetLibSyncField<int[]> 
    { 
        public int this[int i] 
        { 
            get { return Value[i]; } 
            set { 
                Value[i] = value; 
                hasUpdate = true; 
                if (onChange != null) 
                    onChange.Invoke(false, Value); 
            } 
        } 
    } 

And then call it as myIntArray[0] = 5;

Maybe there is better way but this was not hard and works ... would be nice if some solution would be integrated so i would not need to watch for this edit every update :)

SerializationSurrogates not avaiable anymore

Hello,
Found about your work some hours ago, and I can't get it to work, it looks like the "SerializationSurrogates" dependcy is missing (Even on github) and I couldnt find it.

Any ideas?
Thanks in advance

Rooms Support ?

I used this HLAPI for a Survival project and it gave a great result but when I moved to something smaller "Battle Royale FPS" with about 32-100 player per room , I got some problems , I am using it as World-Based "all players in one room , scene" but in Battle Royale it supposed to be Room-Based "each 100 player per room" I used UNET before & PUN and both of them support Rooms & Lobby , Mirror too but this a lot easier & less complex & giving good performance .
So my Question, does LiteNetLibManager support Rooms , or is Planned to be Added ?
I am trying to add using Rooms code from Mirror,UNET but I don't achieve any progress

  • Sorry for all this chit-chat :)

In-scene network objects aren't initialized properly

Using in-scene network objects becomes tricky, as they aren't owned by the server.
Therefor, you can't rely on the IsOwner to invoke RPCs.

Am I doing something wrong, or can I transfer the ownership over to the server?

Server not seeing clients

Hello @insthync
I'm starting out with this library and have a few questions. I can't seem to get the clients position updated properly.

I have these two fields defined at top of my LiteNetLibBehaviour.

    [SerializeField]
    private LiteNetLibSyncField<Vector3> position = new LiteNetLibSyncField<Vector3>();
    [SerializeField]
    private LiteNetLibSyncField<Quaternion> rotation = new LiteNetLibSyncField<Quaternion>();

I'm instantiating my players by having them in the LiteLibAssets, which the Network Manager calls NetworkSpawn all, nothing modified there.

Inside Update(), I'm doing setting the field values.

    private void Update()
    {
        if (IsOwnerClient)
        {
            position.Value = transform.position;
            rotation.Value = transform.rotation;
        }
        else
        {
            transform.position = position.Value;
            transform.rotation = rotation.Value;
        }
    }

Now, I'm not sure who has ownership, but I did modify the ValidateBeforeAcces() method, as I want the clients to be able to modify their own fields as well, ie fully clientside authority.

        protected override bool ValidateBeforeAccess()
        {
            return behaviour != null && behaviour.IsOwnerClient;
        }

The problem is that the server ALWAYS sees the clients spawned in Vector3.zero and aren't updating their position
The clients can see the server and the server's position & rotation updates.

Thanks a bunch.

Support for child network behaviors

Support for this would be awesome.

I've basically just made the identity a serialized field, so you gotta drag it in manually on each behavior, but seems like there's more work needed.

Thank you.

Latest LiteNetLib has breaking changes

Upgraded to latest version of LiteNetLib and now getting the following errors in the Transport code
\LiteNetLibTransportServerEventListener.cs(8,59): error CS0535: 'LiteNetLibTransportServerEventListener' does not implement interface member 'INetEventListener.OnNetworkReceive(NetPeer, NetPacketReader, byte, DeliveryMethod)'

\LiteNetLibTransportClientEventListener.cs(8,59): error CS0535: 'LiteNetLibTransportClientEventListener' does not implement interface member 'INetEventListener.OnNetworkReceive(NetPeer, NetPacketReader, byte, DeliveryMethod)'

MixTransportEventListener.cs(9,46): error CS0535: 'MixTransportEventListener' does not implement interface member 'INetEventListener.OnNetworkReceive(NetPeer, NetPacketReader, byte, DeliveryMethod)'

LiteNetLibDiscovery.cs(39,13): error CS0123: No overload for '_serverListener_NetworkReceiveEvent' matches delegate 'EventBasedNetListener.OnNetworkReceive'

LiteNetLibDiscovery.cs(48,13): error CS0123: No overload for '_clientListener_NetworkReceiveEvent' matches delegate 'EventBasedNetListener.OnNetworkReceive'

[Question] Time sync

Hi, i figured it will be better to ask "profesional" :) - What is best way to handle sync of time related things on client and server with LiteNetLibManager like skill CD's? I had tryed to save timestamp for skill when it was casted and sync it trouh synclist to client and both on server and client handle CD based on that timestamp when was casted + duration. This i thought will be most stable and it is working but it seems like its having issues with times less than 1-2 secs so i had probably missed some detail.

I will eventually have more timers + need to sync daytime cycle (tho this one is probably special case and will not require this ammount of precision) so if you can give me some advice releated to that it would be very appretiated. Its not that important right now (im still fighting with extreeme amount of animations i need to implement) but its probably better to ask in advance :) (i hope you dont mind - if there is nothing for handling those cases inside your library its probably fine, i will fix it one day somehow my self probably but sometimes its better to ask somebody who was already dealing with same type of stuff instead of inventing wheel again if you know what i mean :) )

Setting owner makes object disapear from client

Im calling SetOwnerClient on my class derived from LiteNetLibBehavior on server and when i do so its no longer synced to my client. Did i overlooked something? Im not sure if im supposed to use that function but i expected if i do so i will be able to change transform rotation and so from that client. Im also calling it on multiple objects in loop if its relevant.

LiteNetLibSyncList syncing

I have LiteNetLibSyncList<MyClass> on my player object and im spawning two separate players on scene and to one of them im adding few items to that synclist on server but i see those items synced to both players instead of one i have added them to (Operation method is called with add value) ... its possible its some mess on my part but it seems ok - is there any chance this LiteNetLibSyncList is mistakenly synced to both player objects?

If i set forOwnerOnly = true it seems better (im not getting on client update from different object's list anymore) but im getting weird results on server - if i ask inside netfunction on server directly about count on that list it says 0 but if i ask on my stored entity in dictionary it says 2 (which is ok) ... im uterly confused what is happening. (It seems to be using always list on first spawned object inside that netfunction)

TL;DR: I just want to ask if you had used somewhere LiteNetLibSyncList<MyClass> on multiple networkspawned objects and can tell me its working properly and no sync confusion between objects is happening in your case.

I want to ensure there is no bug involved because im running out of options i can look what could went wrong on my part. Syncfields seems to behave correctly. (EDIT: i have rewriten it to string syncfield and it does same weird thing :/ ... i guess objectid is messed up for some reason but i could be wrong ... i dont know how to debug it properly :( )

Performance Benchmarking

What's the best solution to BENCHMARK the Game with LiteNetLibManager performance ?
Like is there's any way except testing the client with 100 friend every time I add a new networked feature ? Cause literally I don't have these 100 friend ,
I tried to run 100 client and server on my PC but I it hanged since the first 5 clients and server , so if there anyway to test that number of players in this High-level Api , I would be happy to know it.

And another question , how to smooth the movement ? I sync the positions through LiteNetLibTransform , owner client send the transform , but my players and vehicles looks smooth on their owner client and laggy on the other clients ? Any fix to this ?

Third question, I know , a lot of stupid questions , sorry
How much Bytes, KBs should the game with 1 player and server consume per second , mine consume 13Bytes Send and 40Bytes Receive , a lot of SyncFields and RPCs , it's Multiplayer Open-World Zombie Survival & Shooter , is my Game Bandwidth correct or high for 1 player ?

  • you have one of best networking-stacks I used but no Community for support, so I am sorry again for this stupid questions

Network Children Identities

When I make GameObject with LiteNetLib Identity & add some other GameObjects with LiteNetLibIdentities as Childrens to the GameObject mentioned above , only the first child get Initial() called & get ObjectId , others don't get ObjectId which makes them function less.

If I Spawned the Parent Object with Children , this happens , but if I Spawned Children one by one they get ObjectId & work , but I already having the Parent as Scene Objects like Car (The Parent Object) and Car Seats (The Children Objects).

I test them using the Latest version & 1 year ago Version , both of them gives the same result.

Any Solution for that ?

  • another question , what you would recommend me for Survival/Shooter MMO to sync the Player Movement , Sync the position using LiteNetLibTransform or sync the Input and let the clients do the physics or sync the Input and let the Server do physics then sync Transform to all clients ?

  • another question , I know I am asking a lot , I don't know if that LNLManager Bug or Unity one but , I created Networked Wildlife AI and gave it CapsuleCollider to get detected by other enemies , when I send the animal to satisfy area where he get his life need satisfied it doesn't get detected by the SatisfyArea OnTriggerEnter(Collider other) function
    even if the animal CapsuleCollider was isTrigger on or not , I have CapsuleCollider on the SatisfyArea Object with big radius and isTrigger on , does that make any sense ?

Network Spawned character does not appear on client

Im trying to learn how this basic stuff works but i need one small push in right direction.
I have server and client connected to it, i do Assets.NetworkSpawn(spawnObj, 0, connId); on server but that object does not appear on client ... i suppose i have missed some step and this part does not seems to be in docs. Im trying to spawn player character for connected client.
Thx for any help/info.

TL;DR: I need some "checklist" what to set where / do through code to make networkspawned object appear as player on owning client

[Question] Looong distance sync optimisation

Hi, may i ask quick question after some time? :) ... i never know what is proper channel to do that, hopefully its ok here. Im trying to figure out if this library is suitable for case when i have position driven by some third party stuff due avoiding floating point precission problems with large maps (i have position stored elsewhere than transform - im not sure if thats relevant) and what i want is to sync only object/player with positional variables close enough to current player - I know about two features - those subscribers and there is also some visibility checker if i remember correctly. My question is - what is best approach for something like that? I can do it from scratch the old fashioned way with commands if its too problematic but that spawning logic with automatic syncing of vars and lists is very helpfull :)

PS: Im very greatfull you found some time to expand docs, thanks for that. There are still some thing not that clear to me (like when subscribers gets rebuilded/recalculated) but overall there is lot of new usefull info there. ๐Ÿ‘

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.