Search Unity

Third Party Photon Unity Networking

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

  1. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Actually think 60kbs is a lot for games! (dont hang me up on this)

    60 kbs per second per game is 60x60x60 for one active hour. Thats 216 mb per hour per game session? With 500 CCU (online) thats 50x216mb = 10800 mb = 10.8 GB of data per hour. Now multiply that with 24x30 and then you get 7,8TB per month which is what they had to allow you to use, which is a lot .

    A qucik check at leaseweb - then a 5TB extra bandwith costs 53$ (on sale).
     
    Last edited: Apr 8, 2015
  2. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937

    COD hosts can go up to 100KBS. I'm not saying that it's efficient at all, I'm saying it's certainly not that high. However I could make it far more efficient if I summed it all into one bit array, and did some compression, but photons 'message' limitation gives me no motivation to focus on the memory part. :)

    Anyhow I will probably lower the sendrate and sacrifice detail in movement. :)
     
  3. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Updated my answer a bit...
     
  4. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    Thanks for your help. :)
     
  5. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    Just setup the PhotonServerSettings (in the project) and the Wizard will not pop up again. You can set it up for your own server, if you like to use ConnectUsingSettings(), too.
     
  6. Megagamefan100

    Megagamefan100

    Joined:
    Oct 24, 2012
    Posts:
    26
    Is there a way to use something like IP and Port to connect to? basically if my friend makes a server on his computer and gives me the port and the IP I can connect to his server
     
  7. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
  8. Megagamefan100

    Megagamefan100

    Joined:
    Oct 24, 2012
    Posts:
    26
    What I wan't to do is have 2 input boxes 1 for IP and the other for the Port, so if a friend starts his game on his computer and I start my game I can put in his IP and port in the game menu
     
  9. Megagamefan100

    Megagamefan100

    Joined:
    Oct 24, 2012
    Posts:
    26
    Okay now I get it
     
  10. Vibs_appit

    Vibs_appit

    Joined:
    Feb 16, 2014
    Posts:
    53
    Hey @tobiass ,

    I have been working with Photon for a few weeks. I wanted to know if there is a quicker way to get hold of a networked player's local copy at the time it was instantiated on the network. In OnPhotonPlayerConnected, I get PhotonPlayer, but I wanted to change that player's local name and I can't do that if I have no reference to the local obj.
    Currently I am getting the obj with Gameobject.FindGameObjectsWithTag, but this is super ugly and I thought there must be a simpler way to achieve this. Any suggestion is welcome. Thanks!
     
  11. danish115

    danish115

    Joined:
    Aug 28, 2014
    Posts:
    47
    i want to play the game play scene when there may be more than one and less than 5 players are in the room. anybody can tell me how it is possible? I also want to check the time. After that time is over more than one and less than 5 players automatically play the game play scene. i have searched all the way but there is no clue, hint or anything else related to my problem. I think photon only supports the players enter game play scene one by one. I have never found any demo , example according to this problem like more than one player enter in the room and play the game play scene simultaneously. if there is any demo, example, tutorial or anything else please refer me and i am thinking that photon do not support this type of things. if support it the give me any reference tutorial. if not then also do let me confirm by you. It will be very thankful to you.
     
  12. superluigi

    superluigi

    Joined:
    Feb 6, 2013
    Posts:
    38
    I was really excited to try Photon but the excitement is slowly but surely fading. I can't even get past the first step. After some digging I read that I need to take out the "plugins" folder that's in the "Photon Unity Networking" folder and place it in the "assets" folder. The problem is that there's already a "plugins" folder in the "assets" folder, one that I didn't create. It came with the pun import. So I tried moving the contents from the first "plugins" folder into the second but I keep getting errors. So I decided to put everything back the way it was, figuring that the docs are outdated or something, because it wouldn't give me any errors that way. So then I created a unityscript script and coded this:
    #pragma strict

    function Start ()
    {
    PhotonNetwork.ConnectUsingSettings("1.0");
    }

    but now I get an error saying: Unknown identifier: 'PhotonNetwork'.

    Is photon not compatible with Unity 5 and unityscript?
     
  13. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    The PhotonPlayer wraps up the info about a user. Name, custom properties, etc. The other player's PhotonPlayer objects are in PhotonNetwork.otherPlayers. It does not include a list of objects Instantiated by that player though.
    To rename a GO when it's instantiated via network, I propose to add a script on the prefab and implement OnPhotonInstantiate. PUN will call that method on any instantiated game object. There you can easily modify the name, etc.
     
  14. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    This should help:
    http://answers.unity3d.com/questions/940061/how-to-check-time-when-player-is-join-the-room-in.html

    In general: You already know about the callbacks that happen when someone joins. In each case, you can check the length of PhotonNetwork.otherPlayers and start a timer when the amount of players is right for you.

    I think I found your post in several threads. Please, if you don't find the answer to your question, create a new thread with a proper subject that gives a hint what you want to know.
     
    danish115 likes this.
  15. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    Yes, there is already a folder. In that case, copy the content of Assets\Photon Unity Networking\Plugins into the Assets\Plugins folder. The Demos from the PUN package won't work with that setup, so please delete the "Demos" folder in your project when you move to JS/UnityScript. They are C# anyways but if you want to check them out, import PUN to a new, empty project.
    If you want to use the UtilityScripts, then move that folder, too, into Assets\Plugins\. Alternatively delete that folder.
     
  16. TheSquidBot

    TheSquidBot

    Joined:
    Apr 24, 2015
    Posts:
    2
    Window>Photon Unity networking doesn't work on a mac, any alternatives?
     
    Last edited: Apr 24, 2015
  17. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    Hey guys. We have been having a very strange bug with Photon. We have been noticing it off and on since we released. What happens is we get these null players in our games. Photon says a player is connected when he is non-existent.

    At first I wasn't sure if this bug was on my side or Photons. But after the latest update I really realized there is some sort of big problem on the cloud server side. All rooms are auto-generated in this game, and rooms are made and filled on demand. When a new version is released old players continue playing in their rooms while new players play in the new rooms. An update has been released for 4 days now and we still have a room left over from the old version with one null player permanently connected to the room causing the room to forever remain. I tried kicking this player using CloseConnection, but nothing happens.

    Any idea what's happening here? If there is no immediate solution is it possible for me to manually close a room?

    Screenshot of admin version of Warland. Null player room is highlighted(Note "4W", which is a 4 day old version of this game).

     
    Last edited: Apr 24, 2015
  18. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    @brilliantgames: This is a very rare issue which we can't yet reproduce but are working to fix. There is a workaround and we will take a look at the details.
    It will help us, if you can mail us your appId, GameVersion, PUN version, the region and the name of the room you're looking at. Send that to: developer@exitgames.com
    To get rid of the room, you can join it and set isVisible and isOpen to false from inside. That takes the room out of rotation for the lobby.
    Sorry for the hassle.
    Great looking game, btw.! :)
     
  19. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    Doesn't work? It could be affected by moving the scripts around. Any errors in the console?
    I will look into this but essentially, the menu entries are just shortcuts. You can find and edit the PhotonServerSettings file in the project if you want to edit it (if you use ConnectUsingSettings() to connect)...
     
  20. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937

    Thanks for the response. I was gone for the weekend. However I noticed the room disappeared. Did you guys remove it? Cause I didn't. :)

    Edit: Just to let you know, this bug has happened multiple times. Because of the message detection system I implemented, it doesn't affect the game much anymore(System detects if any messages have been recieved, and removes/disables/kicks player if none after 15 seconds). Makes me wonder if its being caused by the same player.
     
    Last edited: Apr 27, 2015
  21. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    @brilliantgames: Ok, good to know it doesn't affect your game really bad. If you can detect it, any client can close the room and make it invisible to hide it from the matchmaking.
    We didn't close this room in particular but either we restarted the affected machine for a update or some security mechanism kicked in finally.
    If you encounter the issue fairly often, we would love to know the details about your app to check the logs and look out for future issues. Feel free to mail us those anytime. Thanks!
     
  22. dimitroff

    dimitroff

    Joined:
    Apr 3, 2013
    Posts:
    131
    Hey guys,
    Any plan to add caching to the GetComponents() #2095 call in NetworkingPeer.ExecuteRPC, every time I do an update, I have to add my own code to cache this call.
     
  23. danish115

    danish115

    Joined:
    Aug 28, 2014
    Posts:
    47
    how to solve lagging issue. PhotonNetwork.networkingPeer.RoundTripTime is start from 80 and goes to 200 above. any help please before i am secured up.
     
  24. danish115

    danish115

    Joined:
    Aug 28, 2014
    Posts:
    47
    is there any racing game tutorial or demo which we provide ease to implement or all you have just making people fool of giving such thing which have no implementation detail. you guys just little bit code of join room and instantiate prefab. tell me any demo about ping, any demo about synchronisation of positions, anyone told in any tutorial about rpc and how to use and what is its work. any free demo or tutorial about racing games ?? :mad::mad::mad::mad::mad::mad::(:(:(:(:mad::mad::mad::mad::mad::mad:o_Oo_Oo_Oo_Oo_Oo_O
     
  25. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824
    bold letters, angry tone, excess of emojis...
     
    tobiass and danish115 like this.
  26. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824
    Hey people I need help destroying players object, I'm totally stuck. I've tried everything with no luck.

    Once the player dies it calls respawn method witch activates level cam, calls rewpawning and (suposedly) destroys player gameobject.

    All work but the player destruction. I've tried tons of things and the latest one is this one witch to me looks ok but it does not work.

    Code (CSharp):
    1.  
    2.         netTanks =GameObject.FindGameObjectsWithTag ("Player");
    3.    
    4.         foreach(GameObject go in netTanks)
    5.             {
    6.  
    7.             if(go.GetComponent<PhotonView>().isMine){
    8.                 PhotonNetwork.Destroy (go);
    9.                 Debug.Log ("respawning_destroy");
    10.             }
    11.         }
    The instantiated players are correctly tagged and no errors trown in this aspect.
    Respawning destroy log never shows up so the is mine if seems not working but I can´t see why.
    netTanks is an array.

    the go objects do have photon view attached.


    Here the full method.

    Code (CSharp):
    1.      void Respawn(){
    2.         Debug.Log ("respawn start");
    3.  
    4.  
    5.         levelCam.SetActive(true);
    6.         Debug.Log ("levelcamera");
    7.  
    8.         netTanks =GameObject.FindGameObjectsWithTag ("Player");
    9.    
    10.         foreach(GameObject go in netTanks)
    11.             {
    12.  
    13.             if(go.GetComponent<PhotonView>().isMine){//si es mi tanke
    14.                 PhotonNetwork.Destroy (go);
    15.                 Debug.Log ("respawning_destroy");
    16.             }
    17.         }
    18.  
    19.         rm.SpawnMyPlayer ();
    20.         Debug.Log ("respawning call");
    21.  
    22.  
    23.    
    24.     }
     
  27. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824
    I decided another strategy, go upwards in the hierachy to get the photon view.
    Code (CSharp):
    1. PhotonView pvPlayer =transform.root.GetComponent<PhotonView>();
    2.         if (pvPlayer.isMine) PhotonNetwork.Destroy(transform.root.gameObject);
    If anyone finds out what was wrong in previous code please share.
     
    danish115 likes this.
  28. danish115

    danish115

    Joined:
    Aug 28, 2014
    Posts:
    47
    hi guys can anybody tell me how to manage positions in all players in racing game in photon ??
     
  29. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824

    min22.

    Watch full video anyway. I recommend full series till the bots. Witch you could skip. Skip all the part related to blender and cosmetic stuff.

    What you need is called prediction, read about most suitable prediction "formula" for your game type.
     
    danish115 likes this.
  30. danish115

    danish115

    Joined:
    Aug 28, 2014
    Posts:
    47
    position means who is 1st, 2nd and so on ... :eek:
     
  31. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824
    That is not related to networking then.
     
    danish115 likes this.
  32. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824
    simply have the master client decide the positions locally and dont break your brain any longer.
     
    danish115 likes this.
  33. danish115

    danish115

    Joined:
    Aug 28, 2014
    Posts:
    47
    ok thanks can you please define it in more detail ?
     
  34. danish115

    danish115

    Joined:
    Aug 28, 2014
    Posts:
    47
    or suggest any tutorial or anything else about it ??
     
  35. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824
    Not sure, but it will depend ond your project. That said, racing games and defining the position I'm pretty sure that is a widely discussed topic in the forum.

    If you have a raceline, I might make sense something like get the shortest distance to raceline from lets say, your cars center point, or front point, or an empty obj in the car that is used for car position reference.

    Considering raceline has start and endpoint you should be able to know what distance from origin is the hitpoint or the shortest distance, knowing this, you can know whe poisitions of each player and number them.
     
  36. danish115

    danish115

    Joined:
    Aug 28, 2014
    Posts:
    47
    i am facing only one problem that how can i differentiate which player have which positions. like i am using waypoints to calculate the script now every player has its own waypoint but i can not differ which player has which waypoint. how can i overcome this problem.
     
  37. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    Good point.
    The downside of caching this would be that new components can't get the callbacks. This is not what you want in all cases.
    Maybe the middle ground is an option to cache this and to have an option to refresh the cache on demand.
    What do you think?
     
  38. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    I'm not entirely sure but the destroy for some part of the GO might affect the children and your list "netTanks" becomes (partly) invalid in the moment you destroy one piece?
    The way you do it now is more elegant, I'd say. Destroy the root of a GO.
    You could also re-use the whole GO and just reset it on respawn...
     
  39. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824
    Yeah but the tanks gets destroyed, with parts unchilded and scatered away so better respaw :)
     
  40. danish115

    danish115

    Joined:
    Aug 28, 2014
    Posts:
    47
    [QUOTE="tobiass,]
    Logic on calculating positions in a race On Photon Cloud.
    I am Basically making bike racing game on uity
     
  41. dimitroff

    dimitroff

    Joined:
    Apr 3, 2013
    Posts:
    131
    Yeah, I guess some kind of a manual control will be a good solution, because GetComponent is pretty costly, when you have a lot of RPC calls.

    Kamen
     
  42. VoLkizz

    VoLkizz

    Joined:
    Mar 29, 2014
    Posts:
    40
    Hi everyone! I working on a soccer type game, and have so far nicely synced players, but have problems with a ball. It works well only with the first player that entered the game. All other players has glitch ball and interactions with a ball behave differently.
    I know that it somehow connected with ownership of a ball, but i didn't really get how it works. If it is, please explain)
    - Ball is scene object,
    - has photon view,
    - each player has collider(trigger) that let us keep the ball (instantiate spring joint between player and ball) and kick it.

    Please, point me to some solution or reference (ownership transfer in docs is not really clear...)

    Thanks in advance!
     
  43. danish115

    danish115

    Joined:
    Aug 28, 2014
    Posts:
    47
    i want to get all other players in array for changing their tags.

    public string[] otherPlayers;

    void Start()
    {
    for(int i = 0; i<= PhotonNetwork.otherPlayers.Length; i++)
    {
    otherPlayers = PhotonNetwork.otherPlayers.name;
    Debug.Log("other players = " + otherPlayers);
    }
    }

    but this will debug nothing. Anyone tell me how this will be possible ?
     
    Last edited: May 6, 2015
  44. Redz0ne

    Redz0ne

    Joined:
    Oct 19, 2010
    Posts:
    332
    First off, I want to apologize for not reading the full thread here (in case what I'm about to ask has already been answered... But in my defence, this is a bit of a mega-thread already.)

    So, I have my eye on this but I'm wondering if I try out the free version on the asset store and later decide to buy this full package, will there be any hiccups?

    Reason I ask is that its price-point is good for what it offers but I'm one of those "I like to try it first" types which I suspect the free version will give me an idea what I can do with this.
     
  45. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    I remember reading this question somewhere. I don't remember if I answered or not. Please link to a separate topic for this question, so everyone can try to help you better - in one place. Thanks.
     
  46. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    You can't change the name of another player. If you want to have some sort of custom/modified name locally, you will need to add this to your logic and keep a value per player.
     
  47. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    The free version has all the same features as the paid asset. It's the same API.
    There are two distinctions: For free, the concurrent-user limit is 20. It's free to try and develop as long as you want. Second: In Unity 4.x, you would need Unity iOS/Android Pro to export to those mobile platforms. In Unity 5 Free, even PUN Free exports to mobile.

    To warrant the price, PUN+ includes a 100 CCU subscription without monthly fees. This means you can have approximately 8k monthly active users and they can play for $0 extra/month.
     
  48. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824
    Glad to clarify the PUN+ process because I had not very clear either.

    TELEPORTING:
    I'm being unable to teleport properly when entering teleport pads.
    I've the observed transforms with an script that has the OnPhotonSerializeView method that allows me to sync position and rotation.

    The first time it is load, when joining room, it performs the teleporting properly, the bool teleport true makes the if below goes trough the transform.position=realPosition so if you enter the room with the sesion started all the players do appear in their position without lerping from the spawnpoint to their actual position. So the first teleport does work.

    What I'm unable to teleport is when the player enters the teleport pad. The triggers has a simple script that translates the player to the destination, but for the rest of the clients see the player lerp from the teleport base to the destination.
    It is strange because I'm forcing (suposedly) to go trough the same teleport code lines that work when joining.

    When the player enters trigger sets a global variable to true.
    Code (CSharp):
    1. NertworkCharacter.teleporCall = true;
    So in the NertworkCharacter_CS it should trigger the teleport
    Code (CSharp):
    1.     if (teleporCall==true)
    2.         {
    3.             teleport=true;
    wich according to the log, the teleport call is set to true, witch causes the teleport to be true witch should make the player be teleported in the rest of the clients, but it doesnt.

    I know in the case this worked this would not the best solution because it will disable the smooth lerping for a moment in all the clients for all the players.

    So it might be worth to try to make it right. The idea to make it right I had in mind was to grab the photon ID of the root element that enters the trigger. and for that object only avoid the lerping, but I dont know if it is possible to receive different streams for different Id.

    Here the transform "observer" script I use.

    Code (CSharp):
    1.  
    2.     public bool sync_pos;
    3.     public bool sync_rot;
    4.  
    5.  
    6.  
    7.     //Mainbody
    8.     Vector3 realPosition = Vector3.zero;
    9.     Quaternion realRotation = Quaternion.identity;
    10.  
    11.     PhotonView pV;
    12.     public static bool teleporCall;
    13.     bool teleport = true;
    14.  
    15.  
    16.     void Start () {
    17.         pV= GetComponent<PhotonView>();
    18.         if (pV==null)
    19.         pV= GetComponentInParent<PhotonView>();
    20.     }
    21.  
    22.     void Update () {
    23.         Debug.Log ("teleporCall" +teleporCall);
    24.  
    25.         if (teleporCall==true)
    26.         {
    27.             teleport=true;
    28.         }
    29.         if (pV.isMine) {
    30.             //si es el mio, no hacer nada. Ya lo actualizamos en local
    31.         }
    32.         else {
    33.             if(sync_pos ==true)
    34.             transform.position = Vector3.Lerp (transform.position, realPosition, 0.1f);
    35.  
    36.             if(sync_rot ==true)
    37.             transform.rotation = Quaternion.Lerp(transform.rotation, realRotation,0.1f);
    38.                  
    39.         }
    40.     }
    41.  
    42.     public void OnPhotonSerializeView (PhotonStream stream, PhotonMessageInfo info) {
    43.  
    44.         //este es nuestro jugador. Enviamos nuestra posicion a la red.
    45.         if(stream.isWriting){
    46.      
    47.             stream.SendNext (transform.position);
    48.             stream.SendNext (transform.rotation);
    49.         }
    50.      
    51.         else
    52.         {
    53.             realPosition = (Vector3) stream.ReceiveNext ();
    54.             realRotation = (Quaternion) stream.ReceiveNext ();
    55.  
    56.                 // la primera vez no hacemos el lerp sino que ponemos el objecto directamnte en real position
    57.                 if(teleport ==true)
    58.                 {
    59.                 transform.position = realPosition;
    60.                 transform.rotation = realRotation;
    61.                 teleporCall=false;
    62.                 teleport=false;
    63.  
    64.                 }    
    65.         }
    66.     }
    67. }
     
  49. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,070
    You detect and set teleport based on position (the player has to be on the pad). The remote copies of your char will lag behind and might not be on the pad when you are, so they don't know there's a teleport the moment you do it.
    You should probably send some extra value when you serialize the position to let others know of a teleport. To save overhead, you can send this value as last one if teleport is true and skip it otherwise. The receiver of course needs to check if the optional parameter is there (at all) and if it's there and true, it teleports (overrides lerping).
     
  50. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824
    Hi tobiass, finally managed to add the teleport. The only things I could not do is to save bandiwth so parameter of teleport is only send when it changes. I tried to place an if statement withing the is writting like this:
    Code (CSharp):
    1. if (teleporCall==true) stream.SendNext (send_Teleport);
    But with the if statmenet it makes it not to work correctly.

    The photon View that observes this script is set to unreliable on change. I wonder if it will send only the params that change or all the params withing OnPhotonSerializeView.

    Someone might find it usefull so here goes the code.
    Code (CSharp):
    1. using System.Collections;
    2.  
    3. public class NertworkCharacter : Photon.MonoBehaviour {
    4.  
    5.     public bool sync_pos;
    6.     public bool sync_rot;
    7.  
    8.  
    9.  
    10.     //Mainbody
    11.     Vector3 realPosition = Vector3.zero;
    12.     Quaternion realRotation = Quaternion.identity;
    13.  
    14.  
    15.     PhotonView pV;
    16.  
    17.     public static bool teleporCall;
    18.     bool initial_Teleport = true;// for initial teleport
    19.     bool send_Teleport = false;
    20.     bool receiveTeleport=false;
    21.  
    22.     void Start () {
    23.  
    24.         pV= GetComponent<PhotonView>();
    25.  
    26.         if (pV==null)
    27.         pV= GetComponentInParent<PhotonView>();
    28.  
    29.     }
    30.  
    31.     // Update is called once per frame
    32.     void Update () {
    33.         Debug.Log ("teleporCall" +teleporCall);
    34.         Debug.Log ("send teleport" + send_Teleport);
    35.  
    36.  
    37.         if (teleporCall==true) send_Teleport = true;
    38.  
    39.         if (teleporCall==false) send_Teleport = false;
    40.      
    41.  
    42.         if (pV.isMine) {
    43.             //si es el mio, no hacer nada. Ya lo actualizamos en local
    44.         }
    45.  
    46.         else {
    47.  
    48.             if(sync_pos ==true)
    49.             transform.position = Vector3.Lerp (transform.position, realPosition, 0.1f);
    50.  
    51.  
    52.             if(sync_rot ==true)
    53.             transform.rotation = Quaternion.Lerp(transform.rotation, realRotation,0.1f);
    54.                  
    55.         }
    56.     }
    57.  
    58.     public void OnPhotonSerializeView (PhotonStream stream, PhotonMessageInfo info) {
    59.  
    60.         //este es nuestro jugador. Enviamos nuestra posicion a la red.
    61.         if(stream.isWriting){
    62.      
    63.             stream.SendNext (transform.position);
    64.             stream.SendNext (transform.rotation);
    65.             stream.SendNext (send_Teleport);
    66.         }
    67.  
    68.         //este es un jugador externo. Recivimos su posicion entre otros parametros.
    69.         else
    70.         {
    71.             realPosition = (Vector3) stream.ReceiveNext ();
    72.             realRotation = (Quaternion) stream.ReceiveNext ();
    73.             receiveTeleport = (bool) stream.ReceiveNext ();
    74.  
    75.  
    76.                 // la primera vez no hacemos el lerp sino que ponemos el objecto directamnte en real position
    77.             if(initial_Teleport ==true)
    78.                 {
    79.                 Debug.Log ("initial teleport");
    80.                 transform.position = realPosition;
    81.                 transform.rotation = realRotation;
    82.                 initial_Teleport=false;
    83.  
    84.                 }
    85.  
    86.             if(receiveTeleport ==true)
    87.             {
    88.                 Debug.Log ("received teleport" + receiveTeleport);  
    89.                 Debug.Log ("someone has teleported");
    90.                 transform.position = realPosition;
    91.                 transform.rotation = realRotation;
    92.                 receiveTeleport=false;
    93.                 teleporCall=false;
    94.                 send_Teleport = false;
    95.             }
    96.         }
    97.     }
    98. }
    This code could ebe compacted a bit more but for testing I "duplicated" the teleport lerp overiding.
    The teleport scripts modifies the static bool and has a yield to change its value in a sec to false.