Battle royale game

Options
hello to all, I am writing to ask you if it was possible to build a battle royale through photon PUN. I already had experience with photon so I think I know how to move, now I'll explain how I thought about making the game, I would need to know what you think:
- 40/60 players per room;
- these can build (as fortnite) and the built objects will be instantiated locally so as not to have the photon view, or if they must necessarily have the sync frame rate reduced to a minimum;
- the prioettili seems to me that they must necessarily have the photon view even if I'm not sure.
The main question is this:
Can photon synchronize 40-60-80 player without laggare?
I thought maybe to insert a collider big enough for each player and when this collide with another collider increases its frame rate in order to be synchronized at best when two players are close, otherwise your frame rate is reduced to a minimum.
Is there any course or good tutorial for the photon servers and how to manage them better for a similar game?
Thanks so much

Comments

  • lennart862
    lennart862 ✭✭
    edited March 2019
    Options
    Hi AndreaDeBlasio,
    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 loose accuracy because the script is rounding to whole numbers. You can only insert whole numbers from -99 to 99.

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

    I hope I could help you,
    Lennart