{"id":1511,"date":"2012-12-15T22:54:53","date_gmt":"2012-12-15T19:54:53","guid":{"rendered":"http:\/\/unitycoder.com\/blog\/?p=1511"},"modified":"2013-03-31T18:14:13","modified_gmt":"2013-03-31T15:14:13","slug":"photon-networking-multiplayer-game","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2012\/12\/15\/photon-networking-multiplayer-game\/","title":{"rendered":"Photon Multiplayer Scene"},"content":{"rendered":"<p><a title=\"start webplayer demo\" href=\"http:\/\/unitycoder.com\/upload\/demos\/PhotonMultiplayerScene1\/\" target=\"_blank\" rel=\"attachment wp-att-1512\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1512\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2012\/12\/15\/photon-networking-multiplayer-game\/photon_network_multiplayer_scene\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/12\/photon_network_multiplayer_scene.jpg?fit=680%2C521&amp;ssl=1\" data-orig-size=\"680,521\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"photon_network_multiplayer_scene\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/12\/photon_network_multiplayer_scene.jpg?fit=680%2C521&amp;ssl=1\" class=\"alignnone size-full wp-image-1512\" alt=\"photon_network_multiplayer_scene\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/12\/photon_network_multiplayer_scene.jpg?resize=680%2C521\" width=\"680\" height=\"521\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/12\/photon_network_multiplayer_scene.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/12\/photon_network_multiplayer_scene.jpg?resize=300%2C229&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/a><\/p>\n<p>Simple steps for making your own top-down multiplayer scene from the Free Photon AngryBots Example<\/p>\n<p><strong>Start:<br \/>\n<\/strong>&#8211; Download this: <a title=\"http:\/\/u3d.as\/content\/exit-games\/photon-angry-bots-demo\/2i9\" href=\"http:\/\/u3d.as\/content\/exit-games\/photon-angry-bots-demo\/2i9\" target=\"_blank\">http:\/\/u3d.as\/content\/exit-games\/photon-angry-bots-demo\/2i9<\/a><br \/>\n&#8211; Import it to a empty project<br \/>\n&#8211; You need to register for the free account: <a title=\"http:\/\/cloud.exitgames.com\/\" href=\"http:\/\/cloud.exitgames.com\/\" target=\"_blank\">http:\/\/cloud.exitgames.com\/<\/a>&#8211; Then from your account, Application Dashboard, you need to create new app<br \/>\n&#8211; Get the app ID<br \/>\n&#8211; 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<\/p>\n<p><strong>Steps<\/strong>:<br \/>\n<strong>1.<\/strong>\u00a0\u00a0 \u00a0Open scene \u201d2_AngryBots_MP\u201d<br \/>\n<strong>2.\u00a0<\/strong>\u00a0 \u00a0Save your new scene as \u201c2_MyGameScene_MP\u201d<br \/>\n<strong>3.\u00a0<\/strong>\u00a0 \u00a0Delete \u201cEnvironment(static) \u201c, \u201cEnvironment(semi-static)\u201d, \u201cEnvironment(sounds)\u201d, \u201cEnvironment(dynamic)\u201d, \u201cMoodBoxes\u201d, \u201cMisc\u201d<br \/>\n<strong>4.\u00a0<\/strong>\u00a0 \u00a0Create plane, 0,0,0 size: 100,1,100 (now player wont fall)<br \/>\n<strong>5.<\/strong>\u00a0\u00a0 \u00a0Create box (or empty gameobject ) at 0,0,0 (we use this as spawnpoint), Set tag to: Spawnpoint<br \/>\n<strong>6.<\/strong>\u00a0\u00a0 \u00a0From main camera, Disable script: Quality Manager<br \/>\n<strong>7.\u00a0<\/strong>\u00a0 \u00a0From main camera, Delete script: \u201cReflectionFx\u201d (so we get rid of the error..)<br \/>\n<strong>8.\u00a0<\/strong>\u00a0 \u00a0Some error from footsteps (it wants to check what material it hits?)<br \/>\n&#8220;NullReferenceException: Object reference not set to an instance of an object<br \/>\nMaterialImpactManager.GetPlayerFootstepSound (UnityEngine.PhysicMaterial mat) (at Assets\/Scripts\/Managers\/MaterialImpactManager.js:28)&#8221;<br \/>\nTemporary fix: Open \u201cFootstepHandler.js\u201d, comment out lines:<br \/>\n\/\/ sound = MaterialImpactManager.GetPlayerFootstepSound (physicMaterial);<br \/>\n\/\/audioSource.pitch = Random.Range (0.98, 1.02);<br \/>\n\/\/audioSource.PlayOneShot (sound, Random.Range (0.8, 1.2));<br \/>\n\/\/sound = MaterialImpactManager.GetMechFootstepSound (physicMaterial);<br \/>\n\/\/sound = MaterialImpactManager.GetSpiderFootstepSound (physicMaterial);<br \/>\n<strong>9.<\/strong>\u00a0\u00a0 \u00a0Error:<br \/>\nNullReferenceException: Object reference not set to an instance of an object<br \/>\nMaterialImpactManager.GetMaterialImpact (UnityEngine.PhysicMaterial mat) (at Assets\/Scripts\/Managers\/MaterialImpactManager.js:48)<br \/>\nMaterialImpactManager.GetBulletHitSound (UnityEngine.PhysicMaterial mat) (at Assets\/Scripts\/Managers\/MaterialImpactManager.js:43)<br \/>\nAutoFire.Update () (at Assets\/Scripts\/Weapons\/AutoFire.js:56)<br \/>\nTemporary fix:\u00a0\u00a0 Comment out these lines from \u201cAutoFire.js\u201d<br \/>\n\/\/ Ricochet sound<br \/>\n\/\/var sound : AudioClip = MaterialImpactManager.GetBulletHitSound (hitInfo.collider.sharedMaterial);<br \/>\n\/\/AudioSource.PlayClipAtPoint (sound, hitInfo.point, hitSoundVolume);<br \/>\n<strong>11.<\/strong>\u00a0\u00a0 \u00a0Now to camera.. Open \u201cPlayerMoveController.js\u201d<br \/>\nFind line:<br \/>\nvar cameraTargetPosition : Vector3 = character.position + initOffsetToPlayer + cameraAdjustmentVector * cameraPreview;<br \/>\nComment it out, add new line (to keep our\u00a0 camera directly on top of the player)<br \/>\nvar cameraTargetPosition : Vector3 = character.position + new Vector3(0,15,0);<br \/>\n<strong>12.<\/strong>\u00a0\u00a0 \u00a0!Note: If you want to test the game, in build settings you need to set all the levels to the Build List<br \/>\n0_Preloader<br \/>\n1_BeginScene<br \/>\n2_MyGameScene _MP<br \/>\n3_EndScene<\/p>\n<p><strong>Cleaning up the loading \/ lobby screen<\/strong><br \/>\n&#8211;\u00a0\u00a0 \u00a0Open scene \u201c0_Preloader\u201d<br \/>\n&#8211;\u00a0\u00a0 \u00a0Delete all the logos<br \/>\n&#8211;\u00a0\u00a0 \u00a0Open scene \u201c1_BeginScene\u201d<br \/>\n&#8211;\u00a0\u00a0 \u00a0Delete all the logos<br \/>\n&#8211;\u00a0\u00a0 \u00a0Select Main Cameram, there is Main Menu:\u00a0 You can set \u201cMainLogo\u201d image<br \/>\n&#8211;\u00a0\u00a0 \u00a0Open MainMenu.cs:\u00a0 You can set your game &amp; room names here<br \/>\n&#8211;\u00a0\u00a0\u00a0 Done<\/p>\n<p><strong>*Misc Notes:<\/strong><br \/>\n&#8211; 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..(?)<br \/>\n&#8211; No idea how to remove photon apps from the list..<br \/>\n&#8211; Most of the unity photon tutorials \/ links &amp; demo packages seems to be broken..oO?<br \/>\n&#8211; 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..<br \/>\n&#8211; 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)<\/p>\n<p><strong>Webplayer:<\/strong><br \/>\n<a title=\"http:\/\/unitycoder.com\/upload\/demos\/PhotonMultiplayerScene1\/\" href=\"http:\/\/unitycoder.com\/upload\/demos\/PhotonMultiplayerScene1\/\" target=\"_blank\"> http:\/\/unitycoder.com\/upload\/demos\/PhotonMultiplayerScene1\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Simple steps for making your own top-down multiplayer scene from the Free Photon AngryBots Example Start: &#8211; Download this: http:\/\/u3d.as\/content\/exit-games\/photon-angry-bots-demo\/2i9 &#8211; Import it to a empty project &#8211; You need to register for the free account: http:\/\/cloud.exitgames.com\/&#8211; Then from your account, Application Dashboard, you need [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1512,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[4,3],"tags":[382,35,106,381,380,129,362,383],"class_list":["post-1511","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-demos","category-unity3d","tag-angrybots","tag-demo","tag-game","tag-multiplayer","tag-networking","tag-photon","tag-scene","tag-tutorial"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/12\/photon_network_multiplayer_scene.jpg?fit=680%2C521&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-on","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/1511","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/comments?post=1511"}],"version-history":[{"count":14,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/1511\/revisions"}],"predecessor-version":[{"id":1801,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/1511\/revisions\/1801"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/1512"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=1511"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=1511"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=1511"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}