- Home /
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!
Answer by Rabwin · Dec 04, 2011 at 12:12 PM
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.
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!