So, i have a script that makes the guiTexture follow an enemy on screen. When i turn my back to the enemy, the guitexture comes back around! I want the guiTexture to disappear when the enemy is not onscreen. Any help? And by the way, here’s the script:
var target : Transform;
var texture : GUITexture;
var changeDistance = 5.0;
var offset = Vector2.zero;
var getHit = false;
var getHitScript : GameObject;
private var origwidth = 0;
function Start (){
origwidth = texture.pixelInset.width;
function Update () {
// define a few updated variables...
var gh = getHitScript.GetComponent("GetHit");
var screenPos : Vector2 = camera.main.WorldToScreenPoint (target.position);
texture.pixelInset.x = screenPos.x + offset.x;
texture.pixelInset.y = screenPos.y + offset.y;
// Control the crosshair's position on the screen:
if (getHit){
texture.pixelInset.width = origwidth *(gh.totalHealth/100.0);
texture.color.r = 50.0/gh.totalHealth;
texture.color.g = gh.totalHealth/50.0;
}
}
oh, by the way, you can ignore all the getHit stuff, that’s for another script-
Thanks in advance!
-Stopsecret Design