Search Unity

Third Party PUN. OnTriggerEnter event

Discussion in 'Multiplayer' started by heemun, Aug 7, 2014.

  1. heemun

    heemun

    Joined:
    Apr 15, 2014
    Posts:
    18
    Hello.
    I have a simple multiplayer project. A player joined a room can control a cube, moveing and rotating it.
    I want to load another scene when two players strikes each other.

    I added OnTriggerEnter method in CubeController script, but nothing happend when 2 cubes get in contact (cube prefab has Box Collider with Is Trigger enabled).

    How can i chekc OnTriggerEnter event? I guess it should be checked in sync script with PhotonView component right? Should i send and receive to PhotonStream something special?

    And how should i bring both players to a new scene? LoadLevel + Join a specific room?
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    I don't know why your collision does not cause a callback but I can help with the loading of a scene.
    Maybe the colliders have to be moved by physics and not by position updates? PUN will only update the position directly, I think.

    Before you connect, set PhotonNetwork.automaticallySyncScene = true.
    To load a new level, let the Master Client decide which and then call PhotonNetwork.LoadLevel(). The other client will load that level, too.
     
  3. heemun

    heemun

    Joined:
    Apr 15, 2014
    Posts:
    18
    Thanks.

    About PhotonNetwork.LoadLevel(). This method will load new level for all clients, right? But i only want to load new level for the two players, who got in touch. It's like MMORPG games, where two players move into battlefield when they contact each other.
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,066
    So you have more than the 2 players in a room and want only those 2 to load another scene?
    How many players do you plan in one such room?

    One of the 2 players should then send the other an RPC "play with me in scene X". You can send RPCs to specific players and X can be the integer number for the scene to load.
     
  5. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    " Note that trigger events are only sent if one of the colliders also has a rigidbody attached."