15
2012
Photon 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/
Related Posts
6 Comments + Add Comment
Leave a comment
Recent posts
- MotionVector Effect: Object “disappears” when paused
- [GreaseMonkey] Unity Forum Fixer
- UnityHub: Make Hub application background Translucent
- Customize SpriteShapeRenderer quality (but has issues)
- Editor tool: Copy selected gameobject’s names into clipboard as rows (for Excel)
- Editor tool: Replace string in selected gameobject’s names
- UnityHub: Enable built-in Login Dialog (no more browser login/logout issues!)
- Use TikTok-TTS in Unity (with WebRequest)
- Create Scene Thumbnail Image using OnSceneSaved & OnPreviewGUI
- webgl+javascript TTS
- Using Moonsharp (LUA) + Unity Webgl
- Using 3D gameobject prefabs with Unity Tilemap + NavMesh Surface
Recent Comments
- [Asset Store] Point Cloud Viewer & Tools on
- [Asset Store] Point Cloud Viewer & Tools on
- Vector3 maths for dummies! on
- UnityHub: Make Hub application background Translucent on
- UnityHub: Make Hub application background Translucent on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- [Asset Store] Point Cloud Viewer & Tools on
hmm.. Doesnt work inside company firewalls(?)
This neither, http://doc.exitgames.com/photon-server/Realtime_Demo_Live/#cat-
some useful links:
basics of the whole system: (use that PhotonNetwork.Instantiate() to spawn mobs)
http://doc.exitgames.com/photon-cloud/Marco_Polo_Tutorial/
How to check in script if this is the master, otherwise you’ll spawn from every client also..)
“if (!PhotonNetwork.isMasterClient) {”
http://forum.exitgames.com/viewtopic.php?f=17&t=1844
Should try making the same for this:
Badumna Cloud Bootcamp Demo
https://www.assetstore.unity3d.com/#/content/8564
New Photon Unity Networking Tutorial Series:
http://forum.unity3d.com/threads/241158-New-Photon-Unity-Networking-Tutorial-Series
Good photon tutorials:
OnPhotonSerializeView – Part 1 Lesson 1
http://youtu.be/8St-bqfmufA
Dev Story: Das Tal’s Backend & Exit Games’ Photon (with details how it works)
http://blog.exitgames.com/2014/09/dev-story-das-tal/