NWH Vehicle Physics 2 Documentation
Docs ยป Setup:Multiplayer:PUN2

Photon Unity Networking 2 (PUN2)

Setup guide for NWH Vehicle Physics 2 multiplayer using Photon Unity Networking 2 framework.

Make sure that your vehicle and scene are already set up for single-player. If not, check the Quick Start guide.

Check your Photon Unity Networking 2 setup with provided Photon demo scenes (e.g. slot cars) to verify that the Photon setup has been done correctly

Adding PUN2 to the scene

  • Create a new GameObject and name it PhotonManager.
  • Add OnJoinedInstantiate and ConnectAndJoinRandom to the newly created object.
  • Set position offset to some higher value (e.g. >10).
  • Set Auto Connect to true.

Adding PUN2 to the vehicle

  • Double click on PUN2.unitypackage (NWH\Vehicle Physics 2\Scripts\OptionalPackages\Multiplayer) to import the required assets.
  • Add PhotonMultiplayerVehicle component to your vehicle. This will automatically add other necessary scripts:

  • Add PhotonView component to the vehicle.
  • Make sure that under Photon View component Observe option is not set to Off. You can use any other option.
  • Set Observable Search to Manual.
  • Observed Components should look as in the following image. If any component is missing from the list add it.

Instantiating

  • Objects that will be instantiated by OnJoinedInstantiate need to be placed under Resources folder. If you do not have such folder create one, its location does not matter. Drag your vehicle prefab to that folder.
  • Assign the vehicle prefab under Prefabs To Instantiate of OnJoinedInstantiate script.
  • Press Play. Vehicle will instantiate after a few seconds.
  • Build your project and open two windows side by side to test it out.
Previous Next

NWH Vehicle Physics 2 Documentation

Table of Contents

Table of Contents

  • Photon Unity Networking 2 (PUN2)
      • Adding PUN2 to the scene
      • Adding PUN2 to the vehicle
      • Instantiating
  • About
  • Setup
  • Input
  • Vehicle Controller
  • Wheel Controller
  • NWH Common Scripts
  • Trailers
  • GUI
  • Multiplayer
  • Render Pipelines
  • Add-ons
  • FAQ
  • Troubleshooting
  • Demos
  • Changelog
  • Upgrade Notes
  • Support