How make a game like fortnite with this plug in

Hi everyone,
We have a question for choose the online plugin for our game, it is based on fortnite. Players reach number between 60-100, we have to synchro near object, life object, bullets, player movement... all this without lag. What is the best plug in ?

Comments

  • lennart862
    lennart862 ✭✭
    edited March 2019
    Hi davidedeblasio2003,
    I wouldn't suggest you use Photon Cloud because of the 500msg/s limit there. But if you want to try it any way I would suggest you do it that way:

    Add a collider to each player

    If a player enters into your collider you should add the players actor nr into your own "player IDs to send array" (The other player does that locally too of course)

    If a value of your character changes like position or velocity you send it to this player IDs array

    Every like 2 seconds every player sends his position to one player. This player waits 2.5 seconds after the first message arrived and bundles all the messages to one array. This player sends this array to everyone else. Apply the position data to these characters which are outside of your collider. (That helps you sending fewer messages)

    The player who received all the messages sends also the new actor nr of the player which has to receive and bundle the messages next within the array. If the new actor nr equals the actor nr of your player you will do that bundling stuff next. But there is, unfortunately, a problem with Photon which I would like them to fix: You cant just add 1 to your actor nr to get the next actor, because there perhaps are spaces between you and the next actor. (Caused by players who are leaving the room) You will have to do an ID system on your own.

    Don't use interest groups in this case. Updating interest groups in each OnTriggerStay would cause additional traffic. Instead, use raise events option to send directly to players.

    I would suggest you send small data types where possible. You can send x and y velocity in just one short instead of using to floats there (3 bytes instead of 10) by using my script:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public static class CrunchTwoShorts {
    
    public static short Encrypt(short FirstShort, short SecondShort)
    {
    string shortmix = "abcde";
    string shorta = "" + FirstShort;
    string shortb = "" + SecondShort;
    
    // start x
    if (FirstShort >= 10 || FirstShort <= -10)
    {
    if (FirstShort < 0)
    {
    shortmix = shortmix.Replace("b", "" + shorta[1]);
    }
    else
    {
    shortmix = shortmix.Replace("b", "" + shorta[0]); //Wird bei einer einstelligen Zahl zur 0 von 09 und bei einer zweistelligen Zahl zur 1 von 15
    }
    
    if (FirstShort < 0)
    {
    shortmix = shortmix.Replace("c", "" + shorta[2]);
    }
    else
    {
    shortmix = shortmix.Replace("c", "" + shorta[1]); // Wird bei einer einstelligen zahl zb. zur 9 bei 09 und bei einer zweistelligen Zahl zur 5 von 15
    }
    }
    else
    {
    shortmix = shortmix.Replace("b", "0");
    
    if (FirstShort < 0)
    {
    shortmix = shortmix.Replace("c", "" + shorta[1]);
    }
    else
    {
    shortmix = shortmix.Replace("c", "" + shorta[0]);
    }
    }
    
    // start y
    if (SecondShort >= 10 || SecondShort <= -10)
    {
    if (SecondShort < 0)
    {
    shortmix = shortmix.Replace("d", "" + shortb[1]);
    }
    else
    {
    shortmix = shortmix.Replace("d", "" + shortb[0]); //Wird bei einer einstelligen Zahl zur 0 und bei einer zweistelligen Zahl zur 1 von 15
    }
    
    if (SecondShort < 0)
    {
    shortmix = shortmix.Replace("e", "" + shortb[2]);
    }
    else
    {
    shortmix = shortmix.Replace("e", "" + shortb[1]); // Wird bei einer einstelligen zahl zb. zur 9 bei 09 und bei einer zweistelligen Zahl zur 5 von 15
    }
    }
    else
    {
    shortmix = shortmix.Replace("d", "0");
    
    if (SecondShort < 0)
    {
    shortmix = shortmix.Replace("e", "" + shortb[1]);
    }
    else
    {
    shortmix = shortmix.Replace("e", "" + shortb[0]);
    }
    }
    
    
    
    if (FirstShort >= 0 && SecondShort >= 0)
    {
    shortmix = shortmix.Replace("a", "" + 1);
    }
    
    if (FirstShort < 0 && SecondShort >= 0)
    {
    shortmix = shortmix.Replace("a", "" + 2);
    }
    
    if (FirstShort < 0 && SecondShort < 0)
    {
    shortmix = shortmix.Replace("a", "" + -1);
    }
    
    if (FirstShort >= 0 && SecondShort < 0)
    {
    shortmix = shortmix.Replace("a", "" + -2);
    }
    
    return short.Parse(shortmix);
    }
    
    static short shortaR;
    static short shortbR;
    
    public static void Decrypt(short ToDecrypt, out short a, out short b)
    {
    short ShortToDecrypt = ToDecrypt;
    string shortaB;
    string shorta;
    string shortb;
    
    a = 0; b = 0; //Für exception
    
    shortaB = ShortToDecrypt + "";
    
    if (ShortToDecrypt >= 0)
    {
    if (shortaB[1] == 0)
    {
    shorta = "" + shortaB[2];
    
    shortaR = System.Int16.Parse(shorta);
    }
    
    if (shortaB[1] > 0)
    {
    shorta = "" + shortaB[1] + shortaB[2];
    
    shortaR = System.Int16.Parse(shorta);
    }
    
    if (shortaB[3] == 0)
    {
    shortb = "" + shortaB[4];
    
    shortbR = System.Int16.Parse(shortb);
    }
    
    if (shortaB[3] > 0)
    {
    shortb = "" + shortaB[3] + shortaB[4];
    
    shortbR = System.Int16.Parse(shortb);
    }
    }
    
    if (ShortToDecrypt < 0)
    {
    if (shortaB[2] == 0)
    {
    shorta = "" + shortaB[3];
    
    shortaR = System.Int16.Parse(shorta);
    }
    
    if (shortaB[2] > 0)
    {
    shorta = "" + shortaB[2] + shortaB[3];
    
    shortaR = System.Int16.Parse(shorta);
    }
    
    if (shortaB[4] == 0)
    {
    shortb = "" + shortaB[5];
    
    shortbR = System.Int16.Parse(shortb);
    }
    
    if (shortaB[4] > 0)
    {
    shortb = "" + shortaB[4] + shortaB[5];
    
    shortbR = System.Int16.Parse(shortb);
    }
    }
    
    if (shortaB[0] + "" == "1")
    {
    a = shortaR;
    b = shortbR;
    }
    
    else if (shortaB[0] + "" == "2")
    {
    a = (short)-shortaR;
    b = (short)shortbR;
    }
    
    else if (("" + shortaB[0]) + ("" + shortaB[1]) == "-1")
    {
    a = (short)-shortaR;
    b = (short)-shortbR;
    }
    
    else if (("" + shortaB[0]) + ("" + shortaB[1]) == "-2")
    {
    a = shortaR;
    b = (short)-shortbR;
    }
    }
    }


    You lose accuracy because the script is rounding to whole numbers. You can only insert whole numbers from -99 to 99.

    Lag can be avoided by using interpolation and extrapolation.

    Maybe Photons documentation can help you too: https://doc.photonengine.com/en-us/pun/current/gameplay/rpcsandraiseevent

    I hope I could help you,
    Lennart
  • S_Oliver
    S_Oliver ✭✭✭
    edited May 2018
    Hello,
    @lennart862 pls post ur script on pastebin.com and link it here.
    @davidedeblasio2003 I think Photon Pun is not the right solution for your Project. You should go for authoritative dedicated server ,-logic using a classic server-side code.
    Photon offers a server sdk for this.

    Great Article about Server side code and things you have to deal with
    http://www.gabrielgambetta.com/client-server-game-architecture.html
  • @lennart862 @S_Oliver thanks for the info, if I increment and buy more msg/s limit can I do it ? How I can integrate amazon GameLift with photon, do you have book or info for that ?
  • S_Oliver
    S_Oliver ✭✭✭
    If u have a Dedicated Server and using Photon server sdk u dont have msg/s limit its up to you.The Photon Server Sdk offers you a 100ccu limit. https://doc.photonengine.com/en-us/onpremise/current/getting-started/photon-server-in-5min

    Check the Website for more!
  • S_Oliver said:

    Hello,

    @lennart862 pls post ur script on pastebin.com and link it here.

    @davidedeblasio2003 I think Photon Pun is not the right solution for your Project. You should go for authoritative dedicated server ,-logic using a classic server-side code.

    Photon offers a server sdk for this.



    Great Article about Server side code and things you have to deal with

    http://www.gabrielgambetta.com/client-server-game-architecture.html

    @S_Oliver Can photon realtime work in this scenario?

    Can you put some more light on
    'You should go for authoritative dedicated server ,-logic using a classic server-side code'

    PS. I'm familiar with PUN2 and followed basic tutorial provided with documentation.
    I made working build, where 4 players can join on single map and move around.