Issues after following Pun-Basic tutorial

Options
So I've noticed a few peculiarities after following this tutorial: https://doc.photonengine.com/en-us/pun/v2/demos-and-tutorials/pun-basics-tutorial/intro

First off, if I try and attach Visual Studio to Unity for debugging, it will freeze when the new scene is trying to load, so it makes it quite hard to test.

Second, attached to my player prefab is the "cameraWork" script, and in the "playerManager" script, in the start() mono method we check the following:
CameraWork _cameraWork = gameObject.GetComponent<CameraWork>();

        if (_cameraWork != null) {
            if (photonView.IsMine) {
                _cameraWork.OnStartFollowing();
            }
        } else {
            Debug.LogError("<Color=Red><a>Missing</a></Color> CameraWork Component on playerPrefab.", this);
        }
However, even though there is a cameraWork script attached I always get the missing component error. Any ideas as to why this is the case?

Also, the PUN-Basics scenes that come with PUN2 don't quite match the tutorial and I was wondering why.

Comments

  • ambid17
    Options
    For those that have the time to dig into this issue, here is my gitlab repo: https://gitlab.com/ambid17/infekt
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @ambid17,

    Thank you for choosing Photon!

    First off, if I try and attach Visual Studio to Unity for debugging, it will freeze when the new scene is trying to load, so it makes it quite hard to test.
    That is expected, to use breakpoints to debug code you need Photon Server read more here.
    However, even though there is a cameraWork script attached I always get the missing component error. Any ideas as to why this is the case?
    Maybe it is a timing issue in Unity (Script Execution Order), can you try putting the CameraWork script on top (above) the PlayerManager one in the Inspector of the same GameObject.
    Also, the PUN-Basics scenes that come with PUN2 don't quite match the tutorial and I was wondering why.
    What kind of differences did you spot? Maybe we left some since the tutorial was first written by @jeanfabre for PUN Classic and was ported to PUN2 by me.
  • ambid17
    ambid17
    edited February 2019
    Options
    Thanks for the response @JohnTube

    I'm not sure what I did but after several Unity restarts, the editor no longer freezes when debugging. I believe it was because of a conditional breakpoint (it worked after deleting all breakpoints). See this article's first response:forum.unity.com/threads/unity-freeze-when-connecting-vs-debugger.529863/

    The cameraWork script was already above the PlayerManager, however I tried to move it up even higher, and it still didn't work.

    The only example that comes to mind is relatively minute, just a naming difference in the GameManager. One is named FeedBackText while in the tutorial it's named progressLabel. I overwrote the changes after copy/pasting the scripts from the demo folder, so I don't remember any more off the top of my head.
  • ambid17
    Options
    I did find another error after some testing. When leaving the game room, the CalledOnLevelWasLoaded() method in the PlayerManager gives the following error: MissingReferenceException: The object of type 'PlayerManager' has been destroyed but you are still trying to access it.

    It tries to access the Script's transform and it didn't work because, well, it was deleted. I'm not sure how to prevent this.
  • jeanfabre
    Options
    Hi,

    I can't repro this. Are you using PUN classic or PUN 2 and which version? if you don't have the latest, can you update and test ( make sure you back up first)

    Bye,

    Jean