switching targets ... setting only 1 target active

PC using mostly js. im not a coder

first question… how do you make the label show up over the transforms position, (name text over there head), after i clicked the button to do so. so that its not showing all the time.

basicly when making the label(rect(10,10,30,10) i want the position numbers to be the transforms position numbers.

using a text mesh as a child of the target works and it follows it even if its moving, but it shows all the time, i need a way to have it off unless i click on that object.

second question… switching targets…

i have it set to make the target active before i can attack it or cast a spell. works fine except if there are more than 1 target in te area with the same “Enemy” tag it seems to go to the closest one.

also i will have some spells. AoE = Area of Effect.

so am i better off just having all the scripts use getID so that it will know which target i want.

and then use an array for the AoE spells letting it hit all targets stored in the array ??

Thanks

I’m having a lot of trouble understanding just what you are trying to say or what you’re looking to accomplish, but it sounds like maybe the 3rd Person Shooter sample might provide some good examples for you?

i did them… 3rd person… platformer. lerpz.
most of what i do have now is from those tuts.

what i am making is swords. axes. etc

i dont need the guns. and automatic attacking.

ok cube is the enemy. i want to select it ( click on it) and it not do anything, untill a press the attack button or walk off a distance. or select somthing else.

now for the spell casting. as it stands i have a instantiated halo that flys forward when i press space bar, and keeps going straight.
i want it to go to the enemy target even if the target is moving and hit it. the halo is a rigidbody.

spell.rigidbody.transform(transform.forward * 1500)

what do i add to make it now go to the target.
i tried cutting up the 2 scripts for rocket homeing and got it to start out in the enemy directon, but not go to it because its still moving around.

also it would not let me add the enemy Transform to the rigidbody prefab in the inspector. i even added it to it in the game and made a new prefab with it attached.
when i deleted it from game(not the project folder) and clicked on the prefab to see the inspector. it was not there again.

ok i got the tracking spell thing figured out but still need some ideas on the other things.

anyone ?

OK, I’m not really sure exactly what is going on in the game, but I think you want to be able to click on an object in the scene to select it, then keep it selected for subsequent actions (like targetting a spell or whatever). You can use raycasting to detect which object is under the mouse when it is clicked (check out this thread for some explanation of raycasting from the camera, along with some code). When you have determined the object that was clicked on, store a reference to it in a variable and use that variable as the target object for subsequent actions.

I don’t know if that really helped all that much, but perhaps you can give a more detail about specific problems you are having

i edited the topic header to show i allready solved it myself. but thanks for responding.

but now im onto dealing with showing the text name above the char or mob, but only when there are set actvie by being clicked on and not any other time,

i used the camera script someone had to fix it to the player or mob, but it still shows when facing a different direction even when on other side of the game map and i cant turn it on and off.

i can turn on and off the GUI.Label, but i cant seem to find a way to stick it to the player or mob so that it fallows them if there walking about.

i used the transform.position.x and postion.y for the
first 2 numbers but that didnt seem to work right either.

edited with differnet question.
also i dont want to use buttons or toggles. only onkey or onbutton . clicking on the target

no ideas ?
also when i transform.lookat the target to face them, my minimap camera jumps a 1/4 turn and i have it locked. whats up with that ?