Search Unity

Third Party Photon Unity Networking

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

  1. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648

    I figured out my problem. I didn't realize i was deactivating the gameObject that OnDisconnectFromPhoton was being called on. My mistake.

    Cheers!
     
    tobiass likes this.
  2. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Is there no way to edit the values of PhotonTransformView component during game play?
    They are set off by default?
    I'm adding that component dynamicly
     
  3. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    At the moment, those values are not settable, afaik. However, there is no reason why they shouldn't be set.
    The only caveat is that values that affect the owner of a GO and the receivers of updates might need to be synced as well.
    You should be able to modify the sources. It might take a while until we can update PUN in this regard.
     
  4. Leonid

    Leonid

    Joined:
    Aug 20, 2013
    Posts:
    90
    Hello! I was wondering, Total traffic per month is calculated correctly in the Dashboard? It seems to be too high. According to the dasboard, i've had a 3.5Tb traffic in last month, but i was not charged for extra traffic (i have a 100+500ccu plan, 1.8Tb of traffic)
     
  5. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    @Leonid afaik, the traffic value is correct. Hard to say without having a look.
    Please mail us (developer@photonengine.com) and include your AppId.
     
  6. human890209

    human890209

    Joined:
    Feb 27, 2017
    Posts:
    9
    Hi, I can only buy one PUN+ at unity asset store. Cause it lasts 60months and One App may need multiple PUN+ to upgrade PUN, Chat or Voice services. And One User may have multiple multiplayer games. How to buy multiple PUN+ at asset store?
     
    imaginationrabbit likes this.
  7. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    The 100 CCU licenses can be bought on our page as well. At the moment, I think there is no way to allow multiple purchases in the Asset Store, unless we define the package as "per seat", which is not what we want.
    Please head over to our page, should you need those subscriptions.
     
  8. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    I was thinking about something today.
    If I have my Master client control all the AI forces on my game.
    Wouldn't only the master client need the PhotonTransformView component on the AI forces
    But the other clients connected don't need it on the AI forces?
    Cause other wise wouldn't it try to sync it twice?

    I was thinking the master client would tell all clients this AI moved. And then once it moves the clients would tell all clients that it moved as well if they also have PhotonTransformView Component?
    Or am i wrong about that?
     
  9. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    The PhotonTransformView is called in two modes: Writing and Reading. You are right, the MasterClient is the only who writes data but to apply it on the clients that receive such updates, the PhotonTransformView needs to read the values and apply them.

    Same component is doing both.
     
  10. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    I'm a bit confused on something.
    I change Scene
    PhotonNetwork.LeaveRoom();

    Then OnLeftRoom() I PhotonNetwork.JoinOrCreateRoom()

    JoinOrCreateRoom failed. Client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster.

    I've had this issue before and I just solved it by leaving the Lobby and using OnLobbyJoin but my game is a bit further in develop now and I've changed some things so I'm trying not to have to leave the Lobby.

    I noticed in the log though that it disconnects from the Master when I leaveRoom. And it never connects back.
    When I look at the help tool in my IDE it says for LeaveRoom() that it returns to Master server where I can join or create rooms.
     
  11. Beike

    Beike

    Joined:
    Dec 10, 2017
    Posts:
    13
    After I use SetInterestGroups to set a group to true,how can I update the gameobject which have been instantiated in this group when this group is false?
     
  12. commodore

    commodore

    Joined:
    May 30, 2012
    Posts:
    40
    Is there something I could use to inform players that they need to update to the latest version of the game to access multiplayer? My players are spread out across multiple versions at the moment.

    So when ConnectUsingSettings (gameVersion) is called, it would check some global gameVersion.
     
  13. The_sky

    The_sky

    Joined:
    Aug 18, 2013
    Posts:
    3
    I have a question. When I press home button on Android devices, this fuction OnLeftRoom was called, and game has disconnected. Thanks!
     
    Last edited: Dec 15, 2017
  14. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    Well, the error message you posted after this says it all: You are trying to join a room while in the wrong state and in the wrong callback. Just move joining the next room into OnJoinedLobby or OnConnectedToMaster.

    @Beike: I'm not sure if I get your question right. Your game object is in an interest group which you then set to ignore?

    @commodore: A remote configuration is not built-in to Photon, no. PlayFab and Unity Analytics have remote configs / values. If you implement your own authentication service for Photon, you can also use that to block users of old versions when they connect / authenticate.

    @The_sky: That doesn't sound like a question. Or I missed it :)
     
  15. Beike

    Beike

    Joined:
    Dec 10, 2017
    Posts:
    13
    Let me repeat it again.There are Group 1 and Group 2.When player join room,His Group 1 is in interest, his Group 2 is not in interest.So the gameobject in Group 1 will be instantiated and the gameobject in Group2 will not be instantiated.
    I want after player click the button which called "JoinGame",set Gourp 2 in interest and receive the gameobject in Group 2.In other words, to instantiate the gameobject in Group 2 again,because when he join the room,they are not be instantiated.I wait for you reply for a long time.I really hope you can help me to solve this problem
     
  16. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Ya I know it was saying it was in the wrong state. What the tool tip shows in my editor is super miss leading though.
    So for my understanding. If you change rooms. You have to leave the lobby and join lobby back before you can join a room by using OnJoinLobby? Thats what I was trying to do is leave and join a new room with out ever leaving the lobby.
    I guess it doesn't really matter. I just applied some logic inside PhotonDissconnect to fix a small issue I had.
     
  17. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    @Shadowing: When you join a room, the client definitely leaves the lobby (rooms are on other servers than the lobby/matchmaking).
    PUN should keep track of the last lobby you were in and when you leave the room, return to that lobby. But you don't have to join a specific lobby, if you want to join a room of it. JoinRoom just needs the room name (which is unique per region) and CreateRoom has an optional parameter to tell which lobby you want the room to show up in.

    @Beike: I'm sorry you've been waiting. I usually try to be active here but got sick.
    What you plan to do, is not implemented in PUN. When a GO doesn't get instantiated due to interest grouping, then it's (currently) lost.
    I think it should be possible to modify PUN to cache instantiate events in groups and to re-run them whenever you change groups. The client does get the event (as we send the instantiate in group 0, no matter what and that means it's always received). But right now, PUN skips the instantiate and doesn't remember it.
    Check out DoInstantiate() in the NetworkingPeer or PhotonNetwork classes. This is where the group (written in the View's data) gets checked in where we skip the instantiate due to PhotonView group. You can cache it.
     
  18. Beike

    Beike

    Joined:
    Dec 10, 2017
    Posts:
    13
    When I instantiate a prefab, DoInstantiate() will be called, but when I join a room, it will not.In this way,the player who join room can't know the GO.Could you show me how to do?Thank you very much!
     
  19. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    I don't think thats possible either Beike. I was testing that group option too and I'm not sure what groups does. What I do know is it doesn't do what I thought it did. I thought it would allow me to only instantiate to a certain group but it doesn't.

    for my understanding you can't tell OnPhotonSerializeView to only sync to certain players. So since you can't do that there is no point in trying to get instantiate to only send to certain players. The only way I think it could be done is if your game only uses RPC calls only. Then you could do a RPC call to Instantiate. Thats gonna get wacky though lol. cause you got ownership issues and sync photon IDs you would have to sort out.

    If I was gonna guess. Beike is trying to do what I was wanting to do but I decided not to pursue it. I was trying to create a MMO with Photon networking lol. Photon Networking only allows so many calls with in a single room. So with groups controlling independent NPC calls. You are going to reach the maximum allowed pretty fast. I think its like 450 @tobiass ?

    So I'm gonna just do instances in my game. If you are a single player playing the game you will see other single players in the zone but NPC mobs won't be in network between players. If you join a group with someone then you won't see single players in the game and the mobs will be network together. So thats what I'm doing. I might use another networking just for character movement only and still use photon for rpc calls. Seems a bit silly having 4 different networking in my game haha. Then i'll have www networking, photon, photon chat and one for character sync.
     
  20. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi Everyone.

    We've just updated PUN to v1.88. It's an important release with an updated internal Library.

    v1.88 (20. December 2017)
    Fixed: In Offline Mode, objects instantiated with PhotonNetwork.Instantiate get removed properly when the client 'disconnects' from Photon.
    Changed: FriendInfo.Name to "UserId", which matches the updated way we use UserId / Nickname.
    Added: UseAlternativePorts to control if the new ports should be used. The "classic" port numbers are replaced for any incoming host-address (in UDP connections).
    Fixed: Calling ExecuteRpc() in one case now uses the actorNr, instead of the originatingPlayer.ID. In some cases, the originatingPlayer might be null.
    Changed: PhotonTransformView.cs making position, rotation and scale model public to allow for scripted addition and control of this component
    Added: Room.PlayerTtl and EmptyRoomTtl, which is also settable (when in a Room).
    Added: Room.PlayerTtl and EmptyRoomTtl well known properties for rooms (in RoomInfo and in enum GamePropertyKey).
    Internal: To simplify setting individual properties (in PUN's code), LoadBalancingPeer.OpSetPropertyOfRoom(byte propCode, object value) is now protected internal and accessible by the Room.
    Added: AuthValues.SetAuthPostData(Dictionary<string, object> p). If the data is a dict, the server serializes it to Json and sends that as Content-Type: "application/json".
    Added: Parameter "becomeInactive" to PhotonNetwork.LeaveRoom(). It defaults to true, which was the behaviour before, too. In a room with PlayerTTL != 0, you can use becomeInactive = false to leave a room for good.
    Added: Region Russia East "rue".
    Added: Link to the Culling Demo doc page to the CullArea component and its Custom Editor.
    Changed: Default mode of the Cull Area is now set to 'Top Down Or 3D Mode'.
    Removed: surplus attribute ExecuteInEditMode in Editor script.
    Changed: The room option "CheckUserOnJoin" is now always used. This means you have to use UserIDs to be able to rejoin a room. This was enabled before in most cases but now it's mandatory. If you don't set a userID, the server will assign a temp one for the "session".
    Updated: To Photon3Unity3d.dll v4.1.1.18, which contains a few important fixes. See plugins\release_history.txt.

    Bye,

    Jean
     
    tobiass likes this.
  21. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    As said: Your client will get the PUN event Instantiate but discard it before DoInstantiate gets called (due to the group you're not interested in).

    This could be changed, as you have the source but helping you do that is outside our free support "boundaries", due to lots of other work.

    If you don't want to analyze the system in PUN, you could also use RaiseEvent and the event cache any way you see fit to get your vision to work (without using our definition how networked objects should sync / instantiate). Either way (modifying PUN or reinventing that wheel) requires some extra work for the special case you got.
     
  22. Beike

    Beike

    Joined:
    Dec 10, 2017
    Posts:
    13
    Sorry,I can't understand.Could you show code?
     
  23. Justice0Juic3

    Justice0Juic3

    Joined:
    Apr 29, 2013
    Posts:
    188
    Hey, this afternoon I noticed Photon Cloud wasn't working properly.
    The servers won't show up but creating a server works well. I'm starting to get really worried right now! :(
    What is going on?!
     
  24. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    Note: Taking over @tobias, as he will be away from the office for few weeks (I am part of Photon Support Team)

    Basically, PUN architecture was designed differently than what you want to achieve. As tobias said, this fall outside the free support unfortunatly, the best way if you want to gain total control over these calls is to resort to .RaiseEvent() and manage your case without relying on PUN, simply use the raw SDK to achieve this.

    Bye,

    Jean
     
  25. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    It all seems fine. When in doubt, always check the status monitoring page: https://www.photonengine.com/en-US/status

    Bye,

    Jean
     
  26. NightStalker101s

    NightStalker101s

    Joined:
    Nov 12, 2014
    Posts:
    4
    I'm using the free PUN asset and on import I get a few issues. Some, I have fixed by rename deprecated function calls, but there is this error and I just don't understand what is being sent where that is causing this.

    Assets/Photon Unity Networking/Editor/PhotonNetwork/PhotonEditor.cs(154,27): error CS0123: A method or delegate `PhotonEditor.PlaymodeStateChanged()' parameters do not match delegate `System.Action<UnityEditor.PlayModeStateChange>(UnityEditor.PlayModeStateChange)' parameters
     
  27. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi Everyone,

    We are releasing a beta package of our next PUN version ( will be referred as PUN 2 ) featuring major internal changes, API changes as well as performances and optimization improvements, while retaining the same design pattern principles ( PhotonViews, RPC, Cloud, etc)

    You can download it here

    Go to our forum dedicated thread for more info

    Few things to know:

    - This version is NOT READY FOR PRODUCTION, use it at your own risk.
    - Unity 5.3.7 is the minimal version

    Known Issues:
    - Only UDP type connection works, TCP and web socket are not leveraged yet

    New Features:
    - Improved Namespace to avoid clash with other assets
    - LoadBalancing (LB) API has been revamped for a better separation between PUN and LB
    - The PUN API changed in numerous place
    - Performance and optimization is improved with less caching of data and better memory usage to avoid unnecessary allocations where possible.
    - Explicit registration for PUN callbacks is now necessary, although automated when using 'PunBehaviour' ( watch out when overriding OnEnable() and OnDisable() you must call the base or registration will not occur
    - Demos now using the Unity UI system instead of the deprecated one which had a very design pattern for coding.

    Future Features:
    - Documentation overall pass to cover all changes and new features
    - Completed Demos
    - Network Prefab will no longer be required as a Resource but will need explicit registration
    - More optimizations and performances improvements

    We welcome your feedback on this

    Bye,

    Jean
     
    Munchy2007 likes this.
  28. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429

    Hi,

    - Which version of Unity are you using?
    - Did you try on a fresh project?
    - Did you ran the API updater from Unity? If your project had errors prior importing, it may not have been triggered.

    Bye,

    Jean
     
  29. NightStalker101s

    NightStalker101s

    Joined:
    Nov 12, 2014
    Posts:
    4
    I am running Unity 2017.3.0f3 Personal
    Yes, it was on a fresh project. Same errors.
    API updater? I didn't have any issues importing the asset itself. I only had issues once the asset was imported with script errors.

    One of the first errors is "Assets/Photon Unity Networking/Editor/PhotonNetwork/PhotonEditor.cs(154,27): error CS0123: A method or delegate `PhotonEditor.PlaymodeStateChanged()' parameters do not match delegate `System.Action<UnityEditor.PlayModeStateChange>(UnityEditor.PlayModeStateChange)' parameters" which is only followed by other errors after I adjust the code.

    After fixing that one I get "
    Assets/Photon Unity Networking/Editor/PhotonNetwork/PhotonEditor.cs(154,27): error CS0123: A method or delegate `PhotonEditor.PlaymodeStateChanged()' parameters do not match delegate `System.Action<UnityEditor.PlayModeStateChange>(UnityEditor.PlayModeStateChange)' parameters"
     
    Last edited: Dec 29, 2017
  30. Justice0Juic3

    Justice0Juic3

    Joined:
    Apr 29, 2013
    Posts:
    188
    Hi,

    Sorry for the late reply. I noticed the servers were up and running. On my Photon Cloud dashboard as well.
    I think that these things cause the problems:
    -The version number was different on my server browser-script
    -The way I created rooms was deprecated (kept giving warnings about customProperties should've changed to CustomProperties) Haven't changed all code because I wasn't entirely sure if it'll work afterwards.

    Sort of solved it by temporarily working on an older version of Unity3D.

    Peace out,
    JJ3
     
  31. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    Hi tobiass, Jean-Fabre,
    I wonder if you could help with a question about connectivity :-

    Here is the scenario
    1. Two players connect to Photon, join a room and start play.
    2. Each player constructs a hierarchy of Photon instantiated GameObjects.
    3. A network glitch / delay occurs. (For testing, this means stopping my wifi; both players are running on the same PC.)
    4. A small delay here, less than the PlayerTtl and RoomTtl values.
    5. Resolve the network connection. (For testing, this means restarting the wifi connection.)
    6. Shouldn't play resume seamlessly now for both players?
    What I actually see here is that both clients are sending bytes, both appear to be connected and both see 2 players in the room, yet neither are receiving bytes. To determine byte transmissions, I was printing these values in both players' sessions :-
    • PhotonNetwork.networkingPeer.BytesOut (this was increasing throughout)
    • PhotonNetwork.networkingPeer.BytesIn (this increased during step 2 but remained static after step 3)
    Here are the software details
    Unity: 2017.2.1f1 Personal (64bit)
    Photon: Photon Unity Networking v1.87
    Here is some code for context
    Code (CSharp):
    1.         PhotonNetwork.networkingPeer.DisconnectTimeout = 60000;
    2.         PhotonNetwork.networkingPeer.SentCountAllowance = 40;
    3.         PhotonNetwork.AuthValues = new AuthenticationValues(<<string with name>>);
    4.         PhotonNetwork.ConnectUsingSettings(<<string with version>>);
    5.         ... <code snipped>
    6.         m_roomOptions = new RoomOptions()
    7.             { IsVisible = true
    8.             , IsOpen = true
    9.             , MaxPlayers = 2
    10.             , PlayerTtl = 60000
    11.             , EmptyRoomTtl = 60000
    12.             };
    13.         ... <code snipped>
    14.         PhotonNetwork.CreateRoom(<<string with room>>, m_roomOptions, TypedLobby.Default)
     
    Last edited: Jan 1, 2018
  32. Nikolasio

    Nikolasio

    Joined:
    Dec 6, 2014
    Posts:
    59
    Hi,

    I'm trying to load a networked player object that is customised on runtime.

    Before, I had a few player prefabs and chose one of them to instantiate in the room. That works fine.
    Now, I have so many customisation possibilities that it's not advisable to put all those combinations into prefabs.
    So I have one runtime player game object which, after customisation in the intro/shop scene, I want to instantiate in the game scene/room.

    Does anybody know a workaround for customising a prefab on runtime (which is against their 'raison d'être', I know) so that it can be instantiated in the room with the right values?
    I'm just starting to read myself into 'scriptable objects'. Is this the way to go?
     
    Last edited: Jan 2, 2018
  33. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    nop, resuming is not automated, you need to either call Connect() and then Rejoin() or ReconnectAndRejoin(), Keep track of wether your player was in a room ( keep the room Id in playerPrefs for example), and when you get disconnected or when the app resume from the background you then know you need to reconnect and rejoin.

    Bye,

    Jean
     
  34. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    It depends where the data originates from, if all this is known during edit time, then yes scriptable object is one way, but if the data is subject to change by the player itselfm then you'll need a server to save data for each player and server that back to your apps via a REST api, which means you will likely use json as a data structure.

    Then once you have this json, your network object can be a stub or a base that can parse this data and instantiate GameObject and setup components ( which it can then attach to itself) to create the necessary complexity on demand.

    Does that make sense? and does that answer your question?

    Bye,

    Jean
     
  35. Nikolasio

    Nikolasio

    Joined:
    Dec 6, 2014
    Posts:
    59
    Hi Jean,

    Yes that makes sense. I'm using Simple IAP System to save all shop related data via json on a local database which I'm planning to couple to a Playfab backend later on.
    The actual data itself are sprites for customisation on the character. The sprites are set on unity's new sprite atlases and will be loaded from a remote data server via assetbundles in a later stage.

    What's still a bit unclear to me, is how I can instantiate a customised photon player . For manual instantiation via asset bundles I would use PhotonNetwork.AllocateViewID() and the example code is pretty clear to me (https://doc.photonengine.com/en-us/pun/current/gameplay/instantiation) but as mentioned there I would still have to instantiate a prefab in the room.
    As where I have a player's game object that will be customised on runtime (mainly some sprite swaps via the sprite renderer) and then, after customisation, I would have to instantiate this game object.
    If I understand your second paragraph, I would instantiate a player prefab, and then, maybe in the awake function of this prefab, setting up the needed customisations via the playerprefs? Or is there another way?

    An additional question:
    During customisation, some spine animations will be set up too. Spine.AnimationState and Spine.Skeleton are not Unity serialised objects. I've read the docs on serialization, but are there some more practical examples on how to serialize such classes?
     
  36. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    Hi Jean,

    Thank you for your reply.

    Unfortunately that suggestion does not seem to work for this scenario. ReconnectAndRejoin() returns the error "ReconnectAndRejoin() failed. Can only connect while in state 'Disconnected'. Current state: Connected".

    Just to reiterate, neither the Ttl has expired (as per the code I posted) nor has OnDisconnectedFromPhoton() been called.
    1. So why is Photon not receiving updates when the connection is restored?
    2. If it is actually going to give up with the connection before the Ttl expires should it not be firing the OnDisconnectedFromPhoton() event?
    Cheers,
    Doug.
     
  37. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    Do you run both instance on the same computer or do you use different devices?

    There is a timeout for disconnection, indeed you can't resume connection if photon still thinks it's connected. This type of cases has been covered on our forum, and there is a way to find out about these glitches without waiting for the timeout:

    Check this: http://forum.photonengine.com/discu...we-disconnect-internet-while-connected#latest

    Bye,

    Jean
     
  38. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    Using manual ID allocation is dangerous and I strongly advice not to use this, you don't need it.

    instead, have one networked Prefab for all your players acting as a base, and that prefab instance will instantiate using regular Unity instantiation your actual bundled Prefab matching your data for that player, and then you simply use composition:

    Your base instance knows about the customized player instance it created, and control it either checking out transform and what not for synchronizing data, and inject these data on the other end ( when isMine is false). So you have a pair of prefab instance: one that is networked and is invisible, it simply act as a middle man, and your visual instance with all the customization requires and both can/must communicate together.

    If that still doesn't make sense, I'll do a quick sample showing a simple working setup like yours ( infact PUN 2 features a demo where this technic is applied, it's a car racing game and player can choose different cars, and I use this technic to deal with this very issue).

    Bye,

    Jean
     
  39. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    Hi Jean,

    I am currently only running both on the same PC purely for testing purposes.

    That's a great link- much appreciated.

    Just as a quick follow up if I may, based on that link- with Disconnect being explicitly called all Photon instantiated GameObjects get destroyed. Is there a callback that is raised to capture that the objects are about to be destroyed by Photon?

    If so, then I can just use that event to capture their state to recreate them if the connection can be reestablished. I can't see anything about this in the Photon documentation so I assume that this GameObject recreation would have to be handled another way.

    Cheers,
    Doug.
     
    Last edited: Jan 4, 2018
  40. Nikolasio

    Nikolasio

    Joined:
    Dec 6, 2014
    Posts:
    59
    Hi Jean,

    Thx for this demo, this makes sense.

    In the demo the car prefab gets instantiated in the SetupCarOnTrack() method. So I would instantiate a player prefab here. And then do some changes on the prefab's components to set up the respective runtime customization? Only a Spine skin and Spine animationstate (non unity serialised objects) will be set on this prefab btw.
     
  41. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    No no, if you detect such disconnection, you need to then disconnect programmatically, because Photon is still thinking it's connected ( until the timeout will be reached, internally Photon is aware, but we have to implement a timeout because sometimes internet connection has glitches that can be recovered, and sometimes not, hence the link with the hack to catch every glitch possible, simply by checking when was the last time the server responded).

    so, call Disconnect() and connect again, simply.

    Bye,

    Jean
     
  42. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    Yes, you are correct, ignore Spine components, in your case, it will be anything that make sense for your own prefab and customization needs.


    Bye,

    Jean
     
  43. Nikolasio

    Nikolasio

    Joined:
    Dec 6, 2014
    Posts:
    59
    Hi Jean,

    Thx!

    What do you mean by ignoring the Spine components?

    EDIT: Disregard question above. I see what you mean, ignoring the original Spine Skeleton Animation component (and just using the data needed for the customization).
     
    Last edited: Jan 6, 2018
  44. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    Hi Jean,
    Ok, got it working. Some code was needed in OnPhotonInstantiate() as well to recreate the hierarchy back together.
    Thank you very much for your time and assistance.
    Cheers,
    Doug.
     
  45. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    Cool! I am glad you can progress.

    Bye,

    Jean
     
  46. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    I have a bit of a issue with setting rotation when using PhotonNetwork.Instantiate.

    I notice if I use transform.rotation on a spawn transform for the rotation argument. It does the wrong rotation.
    I see that transform.rotation doesn't give what is in the rotation values in the inspector. Its way off.

    The only way I know how to solve this is using
    transform.eulerAngles

    And then setting the rotation after Instantiate with transform.eulerAngles = SpawnTransform.eulerAngles

    I know this isn't totally a photon networking question. I wanted to ask here anyways.
     
  47. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    Hi Shadowing,
    One thing that threw me a little recently that may be similar is with child objects. Is your object parented to another? If so, are you seeing a difference between local and world co-ordinates ?
    Doug.
     
  48. Jean-Fabre

    Jean-Fabre

    Joined:
    Sep 6, 2007
    Posts:
    429
    Hi,

    Yes, rotation in Unity is tricky especially if you come from a regular 3d background and used to 3dsMax or similar.

    As Doub_B said, Make sure you are in the same context in terms of parenting to compare two rotations.

    Bye,

    Jean
     
  49. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    Thanks for the replies guys.

    Ya im familiar with local and global. Doing transform.localRotation and transform.rotation both return the same values. Which do not equal what is in the inspector transform. It always reads something like .3, .75, .2 for rotation.
    I've been using unity now for 3 years and I guess I never really messed with rotation much until now. First game is a 2d canvas game. I use local and global all the time. so I fully understand the difference. For some reason rotation seems different?
     
  50. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    Hi Shadowing,
    In that sense you are correct.