



全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1新建一个renderTexture命名为minmapTexture新建一个fps角色2、新建一个cmeraFollow脚本并付给摄像机。using UnityEngine;using System.Collections;public class cameraFollow : MonoBehaviour public Transform target;void LateUpdate () transform .position =new Vector3 (target .position.x,transform .position .y,target.position .z);3target为fps,并将摄像机的dipth改为14、给地形一个标签命名为ninmap5、将所有的culling target 改为minmap将main camera 的target texture 改为minimap。6、新建一个plane 将minmaTexture托给他会制动生成一个minmapTexure 材质7新建一个shader 命名为maskShade8 把里面的脚本删除了然后再粘贴如下脚本。Shader Custom/Mask Properties _MainTex (Main Texture, 2D) = white _Mask(Mask Texture, 2D) = white SubShader Tags Queue=Transparent Lighting OnZwrite offBlend SrcAlpha OneMinusSrcAlphaPassSetTexture_Maskcombine textureSetTexture_MainTexcombine texture ,previous9、在photoshop中绘制你要的地图形状并保存alpha通道保存为tag格式。并且注意要修改它的textureType为advant 并且把aphaformgrayScale勾选。】10、选中生成的材质shader菜单下的mask 把从ps中绘制的地图现状拖过去即生成了小地图。11、如果看不到小地图就调节总摄像机下的normalized View port Rect改为 x:0 y:0,w:1, H:1 12下面在游戏中生成小地图。13新建一个c#脚本输入如下代码using UnityEngine;using System.Collections;public class guiTexure : MonoBehaviour public RenderTexture minmapTexture;public Material minmapMaterial;/void OnGUI () if( Event.current.type=EventType.Repaint )Graphics .DrawTexture (new Rect(0,0,256,256),minmapTexture, minmapMaterial);13将他拖到任何一个物体上using UnityEngine; minmapTexture;为minmapTexture minmapMaterial为生成的minmapTexture材质运行一下小地图出来了哈哈很好玩赶快试一下吧方法2:script ExecuteInEditMode()public var Enemy_ : Texture; /define enemy texturepublic var Box_:Texture;/define the box texturepublic var Player_:Texture;/define player texturepublic var radarBG : Texture; /small map texturepublic var centerObject : Transform; /chracter positionpublic var mapScale = 0.3; /地圖縮放public var mapCenter = Vector2(50,50); /地圖中心function OnGUI () bX=centerObject.transform.position.x * mapScale; bY=centerObject.transform.position.z * mapScale; bX=centerObject.transform.position.x * mapScale; bY=centerObject.transform.position.z * mapScale; GUI.DrawTexture(Rect(mapCenter.x-55,mapCenter.y-50,128,128),radarBG); / 上面的mapCenter.x-32是地圖的x位置,mapCenter.y-32是y位置,64,64是地圖的大小 DrawBlipsForEnemies(); DrawBlipsForPlayer(); DrawBlipsForBox();function DrawBlipsForBox() /draw box texture in small map var gos : GameObject; gos = GameObject.FindGameObjectsWithTag(Box); var distance = Mathf.Infinity; var position = transform.position; for (var go : GameObject in gos) drawBlip(go,Box_); function DrawBlipsForPlayer() /draw player texture in small map var gos : GameObject; gos = GameObject.FindGameObjectsWithTag(Player); var distance = Mathf.Infinity; var position = transform.position; for (var go : GameObject in gos) drawBlip(go,Player_); function DrawBlipsForEnemies() /draw enemy texture in small map var gos : GameObject; gos = GameObject.FindGameObjectsWithTag(Enemy); var distance = Mathf.Infinity; var position = transform.position; for (var go : GameObject in gos) drawBlip(go,Enemy_); function drawBlip(go,aTexture) /draw position in small map centerPos=centerObject.position; extPos=go.transform.position; dist=Vector3.Distance(centerPos,extPos); dx=centerPos.x-extPos.x; dz=centerPos.z-extPos.z; deltay=Mathf.Atan2(dx,dz)*Mathf.Rad2Deg - 270 - centerObject.eulerAngles.y; bX=dist*Mathf.Cos(deltay * Math
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 微服务协同模式-洞察及研究
- 麻醉药过敏讲课件
- 成都商业街临街店铺租赁全权委托合同
- 2025年防爆电气维修安装资质认证试题
- 提升烟台公共服务的公众参与度研究
- 广告平台选择与整合策略
- 财务案例分析模板dtudcghfhdu
- 时尚百货店品牌入驻五年期店面租赁合同
- 乡村生态餐厅承包经营授权书
- 茶楼跨界营销与品牌联合推广合同
- 2022年桂林市卫生学校教师招聘笔试题库及答案解析
- 栏杆安装单元工程施工质量验收评定表完整
- 光污染以及其控制
- T∕CSUS 04-2020 装配式磷石膏隔墙体技术标准-(高清版)
- (全新)政府专职消防员考试题库(完整版)
- 2022年广东省公务员考试申论真题及参考答案
- 美国治理猪蓝耳病的经验PRRS控制与清除策略ppt课件
- 建设项目工程总承包合同 GF—2020—0216
- 微波技术与天线 第5章
- 卫生监督协管试题库
- 钢灰库钢制灰库技术协议
评论
0/150
提交评论