- Home /
Floating GUITexture jumpy and buggy
Hi Folks,
I'm using this script here: http://wiki.unity3d.com/index.php?title=ObjectLabel
only modified to: [RequireComponent (typeof (GUITexture))] - mine requires: GUITexture instead of GUIText
However when i apply the script to an object on my Enemies it jumps and bugs out all over the screen when either the enemy moves or the player moves. Been trying to fix it for hours now but I can't seem to work it out, any ideas?
Cheers.
That script is made for the camera. The reason why your labels are jumpy is because enemy position is different from camera's position. GUI elements require a camera's transform to stay in one place, or at least show properly.
Here's what i'll do:
Just add your code to camera.
Change target : Transform into a target : Transform[].
Add enemies to target array before runtime.
Let me know if this works for you.
What makes you think the script should be applied to a camera game object?
Thanks for your comment, i will try this. However my enemies spawn during runtime and re-spawn after death so this is not possible, also i am using a click to target system as well, so i will need to work out how to achieve this if it works.
Good point, camera is already a transform variable in code. $$anonymous$$y mistake.
You can do what Immanuel says, which is applying the script to empty transform.
Answer by Immanuel-Scholz · Jun 10, 2013 at 10:27 PM
You should apply the script component to a fresh and empty new game object or an game object only containing an GUITexture component. And not to the enemy game object himself.
The script changes the position of the game object it is attached to, so if you add it to an enemy, the script will actually move the enemy himself! (Which in turn causes your script to move the text. But the text is the same game object as your enemy, so the enemy gets moved again, and the text and the enemy and so on... causing the flickering ;)
Sorry, maybe i didn't explain, i have an empty gameobject with a GUiTexture applied and script. This object is a child of the enemy game object. But i will try it again tonight. James.
This object is a child of the enemy game object
Then don't make it a child of the game object then ;).
The script sets the "`transform.position`" which is in world space. As the Enemy moves, this will also move the GuiTexture, which is then recalculated and set again, probably also causing flickering.
oh my... it's working, thank you for your help and the well needed after help. I feel like such an idiot now. Thank you again Immanuel, I'll mark it as the answer. James.
Your answer
![](https://koobas.hobune.stream/wayback/20220613103919im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Mecanim Issue 0 Answers
Strange GUITexture Bug?? 0 Answers
Floating Health Bars 1 Answer
Reduce Draw call for Multiple GUI Textures with same Texture 1 Answer