x


When object clicked, make HUD apper

Hey all, i am trying to make it so when you click on a tank in my game a HUD or selection square appears around it, i tried using a GUI Texture but because my tank has a rigid body the GUI texture just falls and doesn't stop. I have my own GUI texture which i want to apply so i cannot use script made textures.

If anyone is confused its like most games where you require a mouse, when you click on one of your tanks or an enemy tank it will select it an show a box around it, and then you know that this tank is selected.

Please help thanks to anyone that does!

more ▼

asked Dec 04 '11 at 11:18 AM

slayer29179 gravatar image

slayer29179
361 12 19 23

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

I'm not sure what your problem seems to be, if you have a guitexture object, it shouldn't go anywhere unless you put a rigidbody component on it. Even then you can also turn off gravity on it.

The way I would go about it: Instantiate a plane with the material you want under the tank's hierarchy so your "selection" box moves with the tank.

Of course the problem with this is that if tanks are different distances to the camera, the planes will appear bigger or smaller, or it may not be a problem at all depending on if you want that feature.

On this plane, you can also have a script making it face the camera.

transform.LookAt(Camera.mainCamera.transform);
transform.Rotate(new Vector3(90,0,0));

Place code in a FixedUpdate function.

more ▼

answered Dec 04 '11 at 12:12 PM

Rabwin gravatar image

Rabwin
389 11 15 27

it worked :D and my main problem was that it falls, i still don't understand why it did, but i used the plane method you said and it works perfect no problems thank you!

Dec 04 '11 at 12:32 PM slayer29179
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3694
x130
x10

asked: Dec 04 '11 at 11:18 AM

Seen: 577 times

Last Updated: Dec 04 '11 at 12:32 PM