- 最后登录
- 2022-10-8
- 注册时间
- 2010-12-6
- 阅读权限
- 100
- 积分
- 14150
- 纳金币
- 76544
- 精华
- 23
|
本文分享unity3d简单步骤制作多人游戏场景教程,原标题:【Unity】Photon多人场景
首先下载这个:http://u3d.as/content/exit-games/photon-angry-bots-demo/2i9
导入到一个新项目
你需要注册一个免费帐号http://cloud.exitgames.com。然后从你的帐号,应用控制面板创建新应用
获得应用ID
将ID粘贴到Unity(窗口>hoton unity networking>设置>你的应用ID_______)*注意:你需要删除ID字符间的空格,否则也许无法生效。
步骤:
打开场景“2_AngryBots_MP”
另存为新场景"2_MyGameScene_MP"
删除“Environment(static)”,“Environment(semi-static)”,“Environment(sounds)”,“Environment(dynamic)”,“MoodBoxes”,“Misc”。
创建plane平面,0,0,0 尺寸:100,1,100(现在角色不会掉落了)在0,0,0(使用这个作为spawnpoint)
创建box箱子(或空的游戏对象),设置标签为spawnpoint
主摄像机,禁止脚本:Quality Manager
主摄像机,禁止脚本:ReflectionFx(减少出错的几率...)
脚步声出现一些错误(需要检查接触的材料?)
“NullReferenceException: Object reference not set to an instance of an object
MaterialImpactManager.GetPlayerFootstepsound (UnityEngine.PhysicMaterial mat) (at Assets/Scripts/Managers/MaterialImpactManager.js:28)”
临时解决办法:打开“FootstepHandler.js”,注释掉下列代码:
// 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. 错误:
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)
临时解决办法:打开“AutoFire.js”,注释掉下列代码:
// Ricochet sound
//var sound : AudioClip = MaterialImpactManager.GetBulletHitSound (hitInfo.collider.sharedMaterial);
//AudioSource.PlayClipAtPoint (sound, hitInfo.point, hitSoundVolume);
10. 现在设置摄像机...打开“PlayerMoveController.js”
找到下列代码:
var cameraTargetPosition : Vector3 = character.position + initOffsetToPlayer + cameraAdjustmentVector * cameraPreview;
注释掉,添加新代码(设置摄像机位于角色的上方)
var cameraTargetPosition : Vector3 = character.position + new Vector3(0,15,0);
11. 注意:如果你想测试游戏,在创建设置你需要设置所有的关卡到创建列表
0_Preloader
1_BeginScene
2_MyGameScene _MP
3_EndScene
清除加载画面
打开场景“0_Preloader”
删除所有标志
打开场景“1_BeginScene”
删除所有标志
选择主摄像机,这里是主菜单:你可以设置“MainLogo”图片
打开MainMenu.cs:你可以设置你的游戏和房间名
完成
其他注意事项:
我的联网功能在关闭unity后就失效了,过了一会又好了……多尝试几次,重启几次unity,然后它会开始正常工作...(?)
还没有找到从列表移除photon应用的办法
很多unity photon教程的链接或demo貌似都失效了...O0?
请通过地址进行web3D交互展示:http://www.narkii.com/blog/showWork_5409.shtml
|
|