Search Unity

Third Party Photon Player

Discussion in 'Multiplayer' started by kqmdjc8, Mar 1, 2019.

  1. kqmdjc8

    kqmdjc8

    Joined:
    Jan 3, 2019
    Posts:
    102
    Hello, I'm kind of new into Photon, but I managed to create simple scene on which 2 clients control 2 cubes on a scene. Tutorial which I followed has some kind of mistake, so I re-written code by myself.

    Problem is that on 1 client there are 3 cubes, but on 2nd client there are 2 cubes.

    Spawning players works like this:
    - first Menu loads Game scene with PhotonLoadLevel(game).
    -then there is SPAWNER object on Game scene which in void start does: PhotonInstantiate(player);

    Commands I wrote are just approximate, I don't remember exact functions. On original tutorial there was some RefreshInstance function but it didn't work.
     
  2. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,735
  3. kqmdjc8

    kqmdjc8

    Joined:
    Jan 3, 2019
    Posts:
    102
    Yeah, at first I wrote this post and after I've gone deep into forum and posted it on Photon post. I'm sorry
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    So, did you progress?
     
  5. kqmdjc8

    kqmdjc8

    Joined:
    Jan 3, 2019
    Posts:
    102
    Hey, yeah I did after watching some tutorials on YouTube for PUN1 and I understood how everything works. I just hate working with documentation but it seems like I will have to get used to it.
     
  6. kqmdjc8

    kqmdjc8

    Joined:
    Jan 3, 2019
    Posts:
    102
    Could you just explain if this is the method is right?(it works) In menu I have Manager which is not destroyed over scenes. Upon pressing button it connects to random room or creates one if there are none available and then:
    1. Photon load level.
    2. OnJoinedRoom() PhotonInstantiate(Player);

    And in player movement script:
    If (!PhotonViewIsMine) return;
    (ignore code if you are not player creator)
     
  7. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    > connects to random room or creates one if there are none available
    This is similar to what ConnectAndJoinRandom.cs does. Fine for a start.
    The workflow sounds good, yes.
     
  8. kqmdjc8

    kqmdjc8

    Joined:
    Jan 3, 2019
    Posts:
    102
    Could you help me with 1 more thing? As I understand Photon, when for example player A shoots bullet in straight line he is the "owner" and he sends bullet's position to other players several times a second. Bullets most often fly I straight lines, so can't player A only send information - startPos,startRot and it will be created locally on other players game? In my scene there can easily be like 50 bullets on scene. Won't that be too much for Photon to send every position and rotation?
     
  9. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    You are right: Sending updates for each bullet would be overkill and mostly useless info for short-lived bullets.
    We don't have a sample for it but what you suggest works: Send when and where someone shoots in which direction and everyone can move the bullet with some precision (not perfect but fine for visuals) without new input.
     
  10. kqmdjc8

    kqmdjc8

    Joined:
    Jan 3, 2019
    Posts:
    102
    Thanks for all the help, you are awesome tobiass
     
  11. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,072
    :) Thank you!