Hi I'd like to firstly say thanks for your hard work for this wonderful collection of video tutorials.
I'm new to the unity community and has been having troubles with getting this targetting script to work. I've been converting all of your C+ to Javascript to help me better understand what's happening and engaging my mind more than just a simple copy and paste.
What's happening in my game is that when I target, it shows 1 of my mob's name, then it doesn't for the rest. But the moment I remove the mob with the visible name (through interactive playthrough), I'm able to get a different mob's name to appear. Through some debugging I've found that the "name" does not change, it stays at the child of same monster thoughout, but through more debugging I've found that the "name" would change to the next monster, but when told to find the child, if goes and finds the child of the first monster, hence an endless cycle of making the first mob's name visible. I hope you can help me figure this out (and I hope this is the right place to comment).
The coding I used for that section is:
public var selectedTarget: GameObject;
function SelectTarget(){
var animationScript = gameObject.GetComponent(AnimationScript);
animationScript.target = selectedTarget.gameObject;
var enemyName: GameObject;
// helped me discover that enemyName does indeed change to selectedTarget
// but the child does not follow with it
// enemyName = selectedTarget;
// enemyName.GetComponent(MeshRenderer).enabled = true;
enemyName = selectedTarget.Find("Name");
enemyName.GetComponent(MeshRenderer).enabled = true;
}
I've uploaded it if you want to see what I meant with the names not showing up (Left Shift for target switching, and LMB/MMB/RMB for attacking.
http://thedistantvoice.com/WebPlayer/NEW_Aug20/WebPlayer.html






