This project has been replaced by FX 3D Radar HERE
Thanks for sharing this!
Actually it’s REALLY simple to be done with on hover and with toon outline, takes 5minutes…
anyways, good job, thanks ![]()
thanks!
I’m glad to release this to the forum. As I am new to both Unity and JS, I hope this can help others that are also starting out.
So please use the script freely in any way you want, and check back for updates.
v1.3 brings a new name to the script: Targeting_IFF (Identification Friend or Foe). Along with what I hope to be some better code management in the script.
New version 1_4: July-24-2010
A. GUI selection list buttons for selecting targets.
B. Button: Clear Selected Target.
v1.5 brings a better GUI target selection list and the ability to open and close the GUI target selection list.
GUIStyles have also been added, so you can now choose the color and or texture for your targets to be represented with-in the GUI list.
Thank you very much for this.
In my project I found one problem though:
When the playercamera turns 180 degrees away from the Target, I see there also the GUItexture.
Am I the only one with this problem? I am on windows
I searched on google for a solution and tried renderer.isVisible in several ways. But, with no result.
This is the same problem I get with the ObjectLabel script from the wiki.
I see what your taking about i cant believe i didn’t see this before. I’ll look into why it’s doing this. I probably just need to check if the object is in view and set to draw. If not then don’t draw.
v1_54
New GUI Target ID Text
Fixed the target selection box problem. Where the selection box would render even if the target was behind the camera.
Fixed a problem where if the target were to be cleared while the selection list GUI window is open, this would close out the GUI and stop responding.
Fixed a problem with Mouse Select not working after selecting a target with the keyboard.
thanks!
I didn’t check the new version, but in the old one when I destroy all targets and try to select next target, null exception error occures.
Perhaps adding something like
if (EnemyList.length != 0){
// do the targeting
}
would solve the problem.
Thanks alot for this code!
Using it and learning from it.
Cheers!
Oooo man that dark screen is way to dark ![]()
celinscak
Good catch I’ll check that out. Thanks for the feed back.
any way to add little arrows when the target is outside the screen? pointing to where the target is located:left, right, up, down… so i can track it and move towards it
creat326
Thats something i want to add. It’s something i’m still learning how to do.
I’ve been trying since yesterday with no much luck so far. I get funny results (the arrow not pointing to the right places)
It would be a great addition to go into the wiki scripts area.
I love the script! I’ve added scaling so that the GUITexture scales according to the distance between you and the target. I also changed from using target.transform.position as the texture’s location to the bounds.center position. It’s a more accurate “centering” for models in my game, and makes the effect a little cleaner (again, in my game). If you don’t mind, I’ll post the changes for you guys to check out
These are only the changes, not the entire script.
// New variables
var rectEnemy : Rect;
var rectFriendly : Rect;
var minScale : float = 0.2;
var maxScale : float = 1.0;
private var mainCam : Camera;
function Awake(){
ClearTarget();
mainCam = Camera.main; // BMC NEW
}
function TargetSelectionBox(){
var relPos : Vector3;
var relDis : float;
var camPos : Vector3 = mainCam.transform.position;
if(Target){
var targetCenter : CharacterController = Target.GetComponentInChildren(CharacterController) as CharacterController;
var targetPos : Vector3 = targetCenter.bounds.center;
relPos = targetPos - camPos;
relDis = Vector3.Distance(targetPos, camPos);
var ratio : float = 100 / relDis;
ratio = Mathf.Clamp(ratio, minScale, maxScale);
rectEnemy = Rect(0, -crosshairEnemy.texture.height*ratio, crosshairEnemy.texture.width*ratio, crosshairEnemy.texture.height*ratio);
crosshairEnemy.pixelInset = rectEnemy;
rectFriendly = Rect(0, -crosshairFriendly.texture.height*ratio, crosshairFriendly.texture.width*ratio, crosshairFriendly.texture.height*ratio);
crosshairFriendly.pixelInset = rectFriendly;
if (Vector3.Dot(mainCam.transform.TransformDirection(Vector3.forward), relPos) > 0){
if(Target.tag == "Enemy"){
crosshairEnemy.enabled = true;
crosshairFriendly.enabled = false;
crosshairEnemy.transform.position=mainCam.main.WorldToViewportPoint(targetPos);
}
else if(Target.tag == "Friendly"){
crosshairEnemy.enabled = false;
crosshairFriendly.enabled = true;
crosshairFriendly.transform.position=mainCam.main.WorldToViewportPoint(Target.transform.position);
}
}
else{
crosshairEnemy.enabled = false;
crosshairFriendly.enabled = false;
Debug.Log("disabled");
}
}
}
I having some problems with your script my GUITEXTURE never goes over the target… do I just need to setup the buttons or something?