纳金网
标题:
悬浮小地图代码
[打印本页]
作者:
晃晃
时间:
2011-9-13 08:56
标题:
悬浮小地图代码
@script ExecuteInEditMode()
public var blip : Texture; //定?一?指?文件代表角色
public var radarBG : Texture; //地?背景?片,我直接用?景里我?建的render texture
public var centerObject : Transform; //??角色的物?的位置信息
public 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-32,mapCenter.y-32,64,64),radarBG);
// 上面的mapCenter.x-32是地?的x位置,mapCenter.y-32是y位置,64,64是地?的大小
DrawBlipsForEnemies();
}
function DrawBlipsForCows(){
var gos : GameObject[];
gos = GameObject.FindGameObjectsWithTag("Cow");
var distance = Mathf.Infinity;
var position = transform.position;
for (var go : GameObject in gos) {
drawBlip(go,blip);
}
}
function drawBlip(go,aTexture){
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 * Mathf.Deg2Rad);
bY=dist*Mathf.Sin(deltay * Mathf.Deg2Rad);
bX=bX*mapScale;
bY=bY*mapScale;
if(dist<=200){
GUI.DrawTexture(Rect(mapCenter.x+bX,mapCenter.y+bY,2,2),aTexture);
}
}
function DrawBlipsForEnemies(){
var gos : GameObject[];
gos = GameObject.FindGameObjectsWithTag("Enemy");
var distance = Mathf.Infinity;
var position = transform.position;
for (var go : GameObject in gos) {
drawBlip(go,blip);
}
}
作者:
Asen
时间:
2011-9-14 08:40
作者:
tc
时间:
2012-2-17 23:19
其实楼主所说的这些,俺支很少用!
作者:
C.R.CAN
时间:
2012-2-18 23:24
很经典,很实用,学习了!
作者:
tc
时间:
2012-3-21 23:32
灌水。。。
作者:
菜刀吻电线
时间:
2012-4-21 23:25
我也来支持下
作者:
C.R.CAN
时间:
2012-7-5 23:18
不错 非常经典 实用
作者:
菜刀吻电线
时间:
2012-10-10 23:25
很有心,部分已收录自用,谢谢
作者:
菜刀吻电线
时间:
2012-12-8 11:49
楼主收集的可真全哦
作者:
tc
时间:
2013-1-27 23:24
路过、路过、快到鸟,列位请继续...ing
欢迎光临 纳金网 (http://go.narkii.com/club/)
Powered by Discuz! X2.5