3Dオブジェクト(平面)に基づいて基本的なHUDレーダーシステムを作成しました。スクリプトは敵を検出し、画面上で敵を追跡しますが、問題は、HUDが画面領域から外れることがあることです。
これが私のコードです:
#pragma strict
// ******Public dimentions ******
public var AircraftObject : Transform;
// ******Private dimentions ******
//Fetch CpuScript class to get some varibles
private var mainClass : CpuScript;
private var isRenderer : boolean;
private var aircraftArea : float;
//Other perfabs
private var Spd : GameObject;
private var Alt : GameObject;
private var Trg : GameObject;
//Calculating varibles
private var Distance : int;
private var Speed : int;
function Awake()
{
//Finding all objects
findObjects();
//Set PlayerScript into the mainClass
mainClass = gameObject.GetComponent(CpuScript);
}
function FixedUpdate()
{
isRenderer = mainClass.isProximity;
aircraftArea = mainClass.mainObjectArea;
transform.position.x = aircraftArea / 6;
//Set GUI's
guiControl();
getValue();
}
function guiControl()
{
Spd.GetComponent.<TextMesh>().text = Speed + " Knot";
Alt.GetComponent.<TextMesh>().text = "Enemy detected";
Trg.GetComponent.<TextMesh>().text = Distance + " Ft";
}
function getValue()
{
Distance = Vector3.Distance(AircraftObject.transform.position, mainClass.AircraftDistance) * 4;
Speed = Random.Range(100, 300);
}
function findObjects()
{
Spd = GameObject.Find("Speed");
Alt = GameObject.Find("Alt");
Trg = GameObject.Find("AimTarget");
}