Dec
15
2012

Photon Multiplayer Scene

photon_network_multiplayer_scene

Simple steps for making your own top-down multiplayer scene from the Free Photon AngryBots Example

Start:
– Download this: http://u3d.as/content/exit-games/photon-angry-bots-demo/2i9
– Import it to a empty project
– You need to register for the free account: http://cloud.exitgames.com/– Then from your account, Application Dashboard, you need to create new app
– Get the app ID
– Paste it to Unity (in Window / Photon unity networking : Settings : Your app ID ________________________ ) *Note: You need to trim extra leading or trailing spaces from the app id yourself, otherwise it wont work

Steps:
1.    Open scene ”2_AngryBots_MP”
2.    Save your new scene as “2_MyGameScene_MP”
3.    Delete “Environment(static) “, “Environment(semi-static)”, “Environment(sounds)”, “Environment(dynamic)”, “MoodBoxes”, “Misc”
4.    Create plane, 0,0,0 size: 100,1,100 (now player wont fall)
5.    Create box (or empty gameobject ) at 0,0,0 (we use this as spawnpoint), Set tag to: Spawnpoint
6.    From main camera, Disable script: Quality Manager
7.    From main camera, Delete script: “ReflectionFx” (so we get rid of the error..)
8.    Some error from footsteps (it wants to check what material it hits?)
“NullReferenceException: Object reference not set to an instance of an object
MaterialImpactManager.GetPlayerFootstepSound (UnityEngine.PhysicMaterial mat) (at Assets/Scripts/Managers/MaterialImpactManager.js:28)”
Temporary fix: Open “FootstepHandler.js”, comment out lines:
// sound = MaterialImpactManager.GetPlayerFootstepSound (physicMaterial);
//audioSource.pitch = Random.Range (0.98, 1.02);
//audioSource.PlayOneShot (sound, Random.Range (0.8, 1.2));
//sound = MaterialImpactManager.GetMechFootstepSound (physicMaterial);
//sound = MaterialImpactManager.GetSpiderFootstepSound (physicMaterial);
9.    Error:
NullReferenceException: Object reference not set to an instance of an object
MaterialImpactManager.GetMaterialImpact (UnityEngine.PhysicMaterial mat) (at Assets/Scripts/Managers/MaterialImpactManager.js:48)
MaterialImpactManager.GetBulletHitSound (UnityEngine.PhysicMaterial mat) (at Assets/Scripts/Managers/MaterialImpactManager.js:43)
AutoFire.Update () (at Assets/Scripts/Weapons/AutoFire.js:56)
Temporary fix:   Comment out these lines from “AutoFire.js”
// Ricochet sound
//var sound : AudioClip = MaterialImpactManager.GetBulletHitSound (hitInfo.collider.sharedMaterial);
//AudioSource.PlayClipAtPoint (sound, hitInfo.point, hitSoundVolume);
11.    Now to camera.. Open “PlayerMoveController.js”
Find line:
var cameraTargetPosition : Vector3 = character.position + initOffsetToPlayer + cameraAdjustmentVector * cameraPreview;
Comment it out, add new line (to keep our  camera directly on top of the player)
var cameraTargetPosition : Vector3 = character.position + new Vector3(0,15,0);
12.    !Note: If you want to test the game, in build settings you need to set all the levels to the Build List
0_Preloader
1_BeginScene
2_MyGameScene _MP
3_EndScene

Cleaning up the loading / lobby screen
–    Open scene “0_Preloader”
–    Delete all the logos
–    Open scene “1_BeginScene”
–    Delete all the logos
–    Select Main Cameram, there is Main Menu:  You can set “MainLogo” image
–    Open MainMenu.cs:  You can set your game & room names here
–    Done

*Misc Notes:
– My photon networking stopped working for a while after closing unity and coming back later.. Just kept trying for a while, restarted unity few times and it started working..(?)
– No idea how to remove photon apps from the list..
– Most of the unity photon tutorials / links & demo packages seems to be broken..oO?
– One problem with the angrybots photon example: Monsters are already in the scene..(so if player#1 has killed some monster, and other player joins, he still sees the mobs..), you need to create spawning system..
– By default unity 4.x seems to have in Physics settings: [x] Raycast hits triggers, disable that (otherwise your bullets hit the enemy activeradius trigger spheres)

Webplayer:
http://unitycoder.com/upload/demos/PhotonMultiplayerScene1/


6 Comments + Add Comment

Leave a comment

Connect

Twitter View LinkedIn profile Youtube Youtube Join Discord Twitch

UnityLauncherPro

Get UnityLauncherPRO and work faster with Unity Projects!
*free unity hub alternative

@unitycoder_com

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.