1. We've introduced thread tags, search within a thread and similar thread search. Read more here.
    Dismiss Notice
  2. Learn how you'll soon be able to publish your games to China in four simple steps with Xiaomi. Sign up now for early access.
    Dismiss Notice
  3. Get further faster with the Unity Plus Accelerator Pack, free for new Unity Plus subscribers for a limited time. Click here for more details.
    Dismiss Notice
  4. We've released our first Timeline Experimental Preview, our new tool for creating cutscenes and more! To check it out click here.
    Dismiss Notice
  5. Unity 5.5 is now released.
    Dismiss Notice
  6. Check out all the fixes for 5.5 in patch releases 1 & 2.
    Dismiss Notice
  7. Unity 5.6 beta is now available for download.
    Dismiss Notice

Photon Unity Networking

Discussion in 'Multiplayer Networking' started by tobiass, Aug 23, 2011.

  1. RF008

    RF008

    Joined:
    Oct 28, 2016
    Posts:
    20
    Hi i want to do matchmaking based on player ranks. i need sample script where i can make match between two players based on the rank.
    i have tried old forum posts those are outdated i am looking for solid sample Thanks
    Thanks
     
    Last edited: Mar 1, 2017
  2. RF008

    RF008

    Joined:
    Oct 28, 2016
    Posts:
    20
    Try to use vpn it was simple
     
  3. MohammadAlizadeh

    MohammadAlizadeh

    Joined:
    Apr 16, 2015
    Posts:
    5
    Hi
    My photon cloud for some mysteries reason can't connect and gives me time-out error
    is there any restriction over Iranian users? i turned on VPN or Proxy but didn't work
    i could use it before (last year) and have fun with it but now says 'Peercreated' :(
    i'm using the latest version of Photon and Unity 5.4.0 p2
    Thanks

    unity log:
    Deeeeer.png
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    1,811
    @Shivam_Dhoot: We don't have support for Proxys in Photon.
    You could potentially run a Photon server in the network instead of using the Cloud. Check out our Server SDK. Running a Cloud-compatible Photon Server does not require any compilation. A little setup is doing it.
    Of course, in the net, the ports have to be unrestricted. If you can't get that, I don't know if we can help.
    This week, I was off sick and busy. I hope you can figure out something with the Server .exe.
     
  5. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    1,811
    @MohammadAlizadeh: I'm sorry to say, but Iranian users are in fact blocked. The hoster for our cloud machines applies this restriction. I think you could get the Photon Server SDK and run a server locally for development.
    I hope you get your chance to make your multiplayer game.
     
  6. MohammadAlizadeh

    MohammadAlizadeh

    Joined:
    Apr 16, 2015
    Posts:
    5
    Uhh ok i got it..I'm using unity's Unet now, works great
    Thanks for reply
     
  7. RF008

    RF008

    Joined:
    Oct 28, 2016
    Posts:
    20
    Hello
    i need sample script for matchmaking based on ranks i need script where i can set some rank to user and check if it was in between say rank 5 - 8 or 9-12 etc.
    Ex player a have rank of 6 and player b was having rank of 8 then they need to join the game.
     
  8. stvster

    stvster

    Joined:
    Mar 4, 2013
    Posts:
    42
    Hi,Would this be an appropriate place to post a Photon Multiplayer Car Test?
    Thanx,
    Steve
     
  9. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    1,811
  10. stvster

    stvster

    Joined:
    Mar 4, 2013
    Posts:
    42
    Thanx tobiass.
     
  11. zazoum

    zazoum

    Joined:
    Sep 3, 2011
    Posts:
    62
    Hello, new to Networking, my first multiplayer game, a top-down 2D shmup arena.
    I used PUN and everything runned smoothly eventually in my first attemps and tests except a thing. The shmup ships move around and one sees another move smoothly. But a small, a bit lag seems to be created a the game runs and gets bigger and bigger over time. This leads to jumps in the "other" ships' movement about at the 5 minute mark.
    I live in Greece and set up the preferences to EU Photon Server. I also tested this to different connections, so I don't think it is a "my" connection problem.
    The player observes only one script nested to the "other" ships gameobjects which is the following:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class NetworkCharacter : Photon.MonoBehaviour {
    5.  
    6.     Vector3 realPosition = Vector3.zero;
    7.     Quaternion realRotation = Quaternion.identity;
    8.  
    9.  
    10.     void Start () {
    11.    
    12.     }
    13.    
    14.  
    15.     void Update () {
    16.         if( photonView.isMine ) {
    17.  
    18.         }
    19.         else {
    20.             transform.position = Vector3.Lerp(transform.position, realPosition, 0.1f);
    21.             transform.rotation = Quaternion.Lerp(transform.rotation, realRotation, 0.1f);
    22.         }
    23.     }
    24.  
    25.     public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) {
    26.         if(stream.isWriting) {
    27.  
    28.  
    29.             stream.SendNext(transform.position);
    30.             stream.SendNext(transform.rotation);
    31.         }
    32.         else {
    33.  
    34.            
    35.             realPosition = (Vector3)stream.ReceiveNext();
    36.             realRotation = (Quaternion)stream.ReceiveNext();
    37.         }
    38.  
    39.     }
    40. }
    There are of course 2 other scripts in the ship, one for movement and rotation, and one for camera, but those are not observed.
    Anybody has an idea?
     
  12. zazoum

    zazoum

    Joined:
    Sep 3, 2011
    Posts:
    62
    Furthermore, are there series of up to date video tutorials that explain all the features of PUN? There are some in in Photon website as links, but they are from like 2014. Should I trust them?
     
  13. Zymes

    Zymes

    Joined:
    Feb 8, 2017
    Posts:
    49
    Is Photon right for me if I want my players to:

    - Host their own dedicated server
    - Allow at least 100 players per server
    - Allow unlimited global players

    Is it still free at this point or is there a huge license cost?
     
  14. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    123
    I'd be interested in that as well.
    It's somewhat unclear to me what exactly we're paying for when we want to host our own servers...

    Also, does photon support [SyncVar] ?
     
  15. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    1,811
    We submitted v1.81 to the store. It should be up in a while.

    v1.81 (16. March 2017)
    Updated: Basic Demo Launcher.cs: removed Log Level setup, it's now done in the Photon Settings.
    Updated: Chat Demo ChatGui.cs: removed running in background setup, it's now done in the Photon settings.
    Fixed: NetworkingPeer.cs: Fixed Scene Object OwnerShip transfer on late Join.
    Fixed: ColorPerPlayer.cs and ColorPerPlayerApply.cs for a more robust connection with PlayerRoomIndexing.cs instance.
    Fixed: Ownership handling when returning to a game.
    Updated: Setting the log levels via code will now override the logging settings ("Pun Logging" and "Network Logging") from the PhotonServerSettings config.
    Updated: Demo Hub scene to better highlight tutorial links versus links to online documentation.
    Updated: Link for PhotonAnimatorView trigger doc url.
    Added: Callback OnOwnershipTransfered. Called when a PhotonView Owner is transfered to a Player.
    Added: Callback OnPhotonPlayerActivityChanged. Called when a remote Photon Player activity changed. This will be called ONLY is PlayerTtl is greater than 0. Check PhotonPlayer.IsInactive for the player.
    Added: GetCustomRoomList(). Enables you to fetch a short, filtered list of room names from an "SQL lobby".
    Fixed: Basic Demo Launcher: Fixed 5.4+ SceneManager OnSceneLoad callback to not throw errors when coming back to the demo hub
    Fixed: ColorPerPlayerApply.cs: Disable routine was not safe and would throw errors
    Changed: WebGL exports will now use secure https "GetPing" requests. This enables Best Region for content on https hosting.
    Changed: The fallback thread to keep connections doesn't have to run when in offlineMode.
    Updated: The Photon assemblies to v4.1.1.9, which includes several fixes. E.g. "WouldBlock Exception" and "BlockCopy Exception". More info is in the release history file for the dll.
     
  16. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    1,811
    @zazoum: The steering of a game affects how incoming position updates need to be smoothed. If the control is direct, you might want a character to "skip" to the latest known position, should it differ from the local one. If the control is smooth and slow, the interpolation can work with that.
    Sadly, we did not find the one awesome solution to cover all. You need to get behind it and experiment.
    About the tutorials: As usual, tutorial quality may vary quite a bit. The basics of PUN are still the same as 2013 but code might differ somewhat (due to renaming, new options, etc). If the tutorial isn't about something you already know, you should be able to learn something.

    @Zymes: If your players should host Photon, you need a "Redistributable License". Usually, those are for up to 50 CCU, so please ask us by mail: developer@exitgames.com. I'm not sure if we can cover the "unlimited servers and unlimited CCU per dedicated host" requirement.

    @dadude123: Well, you might be hosting Photon yourself but you sure didn't write it. So you're paying for software. It's not like you have to all the work ;)
     
  17. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    123
    I'm sorry you misunderstood me, I didn't word that right! I didn't mean to question the initial price, that one is fine! :)

    I was asking about that CCU limit (and the costs associated with increasing that limit). When I'm hosting my own servers and I don't use any sort of matchmaking or anything else that would cause any sort of traffic to the servers hosted by you guys, then does the CCU even affect me?
     
  18. Zymes

    Zymes

    Joined:
    Feb 8, 2017
    Posts:
    49
    Photon looks very interesting compared to UNET but you guys need to work out a system/license or whatever for an approach where players can host their own dedicated servers like in ARK, Conan Exiles, Team Fortress, Blackwake, and many other games do. Not just a small session of ~4 players.

    This is the only sane solution for indie developers who can't host hundreds of dedicated official servers because of the sheer cost and instead have the community do it.
     
  19. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    1,811
    @dadude123: Maybe I just didn't get your post yesterday. Thanks for the clarification! :)
    We are scaling the Photon Server price by CCU (even if you host it entirely) to be able to offer a cheaper solution for smaller games. If we didn't, there would only be one, probably medium-high price for licenses. Bigger CCUs also mean bigger projects usually and those tend to cause somewhat more support, etc..
    Some details:
    You can get a 100 CCU license for free and run your game on it. Whenever needed, you can buy additional licenses and or CCUs to expand. There are optionally one-time fees for the licenses or you can subscribe to them to lower initial costs of your game.
    With the Photon Server SDK, you get the full package: Matchmaking, Load Balancing on multiple machines (if needed) and extensibility via C# with a proper framework to customize if needed. It's not a combination with our Photon Cloud service.

    @Zymes: We offered "redistributable" licenses for quite a while but the demand was really low. Maybe it is because we didn't offer a service which does the server-listing (when customers host, the servers need to be found).
    That said: A team of us is working on Bolt and that might be a good fit for your case. It's hosted in-Unity and as long as you create a list of "servers", you can achieve what you described.
     
  20. RF008

    RF008

    Joined:
    Oct 28, 2016
    Posts:
    20
    Hi i am working on helicopter game similar to https://play.google.com/store/apps/details?id=com.extremedevelopers.battleofhelicopters
    this was made in photon unity i am trying to sync the player position but when i do that i am getting issue with jerkey movement i have tried lerp and some other options but all are having some sort of jerk movement in the game the game above is smooth i want to know how to send the player movement with out jerk i am thinking of sending player keyinput but that might go out of sync in the game i am looking for some sample script to move smooth.

    please provide me good starting point.
     
  21. yepfuk

    yepfuk

    Joined:
    Sep 23, 2015
    Posts:
    40
    I have a problem on my game. Player movements are very laggy. How can I solve this?

    Here is the script and PhotonTransformView component.

    Code (CSharp):
    1.  private void Update()
    2.     {
    3.         if (photonView.isMine == false)
    4.         {
    5.             timeToReachGoal = currentPacketTime - lastPacketTime;
    6.             currentTime += Time.deltaTime;
    7.             transform.position = Vector3.Lerp(positionAtLastPacket, realPosition, (float)(currentTime / timeToReachGoal));
    8.         }
    9.     }
    10.  
    11. public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo msgInfo)
    12.     {
    13.         if (stream.isWriting)
    14.         {
    15.             stream.SendNext(playerCurrentHealth);
    16.             stream.SendNext(transform.position);
    17.             stream.SendNext(transform.rotation);
    18.         }
    19.         else
    20.         {
    21.             int oldHealth = playerCurrentHealth;
    22.  
    23.             playerCurrentHealth = (int)stream.ReceiveNext();
    24.  
    25.             currentTime = 0f;
    26.             positionAtLastPacket = transform.position;
    27.             realPosition = (Vector3)stream.ReceiveNext();
    28.             lastPacketTime = currentPacketTime;
    29.             currentPacketTime = msgInfo.timestamp;
    30.  
    31.             transform.rotation = (Quaternion)stream.ReceiveNext();
    32.         }
    33.     }
    I also tried this, but nothing changes;

    Code (CSharp):
    1.  public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo msgInfo)
    2.     {
    3.         if (stream.isWriting)
    4.         {
    5.             stream.SendNext(playerCurrentHealth);
    6.             stream.SendNext(transform.position);
    7.             stream.SendNext(transform.rotation);
    8.         }
    9.         else
    10.         {
    11.             int oldHealth = playerCurrentHealth;
    12.  
    13.             playerCurrentHealth = (int)stream.ReceiveNext();
    14.  
    15.             transform.position = (Vector3)stream.ReceiveNext();
    16.             transform.rotation = (Quaternion)stream.ReceiveNext();
    17.  
    18.         }
    19.     }
    Thanks for advance.
     

    Attached Files:

    Last edited: Mar 19, 2017 at 9:07 PM
  22. RF008

    RF008

    Joined:
    Oct 28, 2016
    Posts:
    20
    i have tried to use smooth movement form the video https://www.assetstore.unity3d.com/en/#!/content/17070
    but still there was jittery movement.

    any script that will over come my jittery movement is appreciated.

    i have tried this script but still i see jittery movement.

    @tobiass
    public void UpdateNetworkedPosition(){
    m_NetworkPosition = HeadPos;

    float pingInseconds = (float)PhotonNetwork.GetPing () * 0.001f;
    float timeSinceLastUpdate = (float)(PhotonNetwork.time - m_lastNetworkreceivedTime);
    float totalTimePassed = pingInseconds + timeSinceLastUpdate;

    Vector3 extrapolatedTargetPosition = m_NetworkPosition + transform.forward * m_Speed * totalTimePassed;
    Vector3 newPosition = Vector3.MoveTowards (transform.position, extrapolatedTargetPosition, m_Speed * Time.deltaTime);

    if (Vector3.Distance(transform.position , extrapolatedTargetPosition) > 2f) {
    newPosition = extrapolatedTargetPosition;
    }

    newPosition.y = Mathf.Clamp (newPosition.y, 0.5f, 50f);

    transform.position = newPosition;
    }
     
  23. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    196

    Few questions :
    - Is it jumping from places to places or too slow to reach it's target?
    - Is it a RigidBody or a simple GameObject?

    make sure you also validate network smoothing using the dedicated demo scene "DemoSynchronization-Scene", it will puunder different smoothing technics several cubes. This is your goto scene to pick up the one that suits your needs.

    Bye,

    Jean
     
  24. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    196
    As I just mentioned to @yepfuk make sure you check the demo scene "DemoSynchronization-Scene", it will show the basics smoothing technics available, if none of these are suitable, then you'll have to come up with a dedicated solution, but it's very unlikely that you'll need to go that route.

    else, can you describe what you are trying to move around, it will help knowing this to provide possible ways to improve the situation.

    Bye,

    Jean
     
  25. RF008

    RF008

    Joined:
    Oct 28, 2016
    Posts:
    20
    Hi thanks for the answer
    player movement over network was not that smooth we can see jerks i want seamless smooth movement.
    now player will move nicely with some slight lag when moving i dont want to see any lag at all i want a smooth movement
    i have tried lerp from the "DemoSynchronization".

    it will work but i want a very smooth movement, player should not see any lag at all, for the networked player.
     
  26. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    196
    Hi,

    there is a difference between "smooth" and "lag". Lag will always be, but smoothness depends on how you are going to deal with the lag.

    The very nature of networking synchronization implies a lag, it's not something you can avoid, and is inherent to any similar networking solution you'll implement. Depending on your player types of movement, you could extrapolate on the direction, speed and predict the likely position of the networked player and compensate lag this way, else a simple lerping interpolation will be the go to solution for a truly smooth movement, but yes, you will have the lag more noticeable.


    Depending on your game play, you could be studying TrueSync lock step system, which guarantees total synchronization for all players, but the solution is very different in terms of implementation. https://www.photonengine.com/en-US/TrueSync



    Bye,

    Jean
     
  27. yepfuk

    yepfuk

    Joined:
    Sep 23, 2015
    Posts:
    40
    Thank you for reply,

    - The characters jumping from places to places.
    - Players are RigidBody.

    I will check the DemoSynchronization-Scene again.
     
  28. BalazsBalazs

    BalazsBalazs

    Joined:
    Oct 7, 2013
    Posts:
    9
    Is Photon a thief?
    When I bought this asset, it was 100ccu for LIFETIME, not only 60 month!!
    I only bought this asset for the lifetime 100ccu, and now?
    After lots of sell, they just change it for 5 year???!

    How they calculated the 5 year from lifetime? heh?
    If hey change it to 30-50 year, I say: its ok.. but 5 year?
    I think it is very disgusting and stealing! Also lots of user not use the max ccu
    all the time...

    I love using photon, but I think it is not fair!
    I paid for lifetime 100ccu, not for 60 month. How can Unity allow this?
    Someone, just upload something to sell, and after with the filled pockets, just delete or decreases the asset ?

    It is really not fair from a big company like Photon... I can not believe it.
    I not will pay anymore for photon... they are just steal from small users...
     
  29. Kamil-Says

    Kamil-Says

    Joined:
    Jun 30, 2014
    Posts:
    151
    Lol, stop crying like a baby. 5 years licence is still fine for $95. You gonna upgrade the subscription sooner or later after the release of the game. I have seen a lot big companys changing their subscription plans. It's bussiness, accept it.
     
  30. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    1,811
    Please mail us to developer@exitgames.com. Include the invoice ID you got from the store and the email address of the Photon Cloud account to which you applied the purchase. We will help you.