- Home /
Guitexture as a child of a gameObject?
Hey, my game is one, where the enemy's will need hearts to float above their heads, so that the player knows how many more hits they need to do to kill them. My question is: Is it possible to make a guitexture a child of an enemy prefab and that way it will move with that enemy when it does? Also another question: Is it possible to access this guitexture with code then? So if the guitexture is called "healthBar", will i be able to type in: var guihealthBar: GameObject; and then drag it on from the inspector?
Answer by Eric5h5 · Jan 04, 2013 at 09:06 PM
A GUITexture cannot ever be a child of a GameObject since they use two completely different coordinate systems. (Viewport space vs. world space.) Use this.
thanks for that I've seen that page before, but all the code confused me. Do you mean i should use this(Where cam = cameraToUse,): thisTransform.position = cam.WorldToViewportPoint(target.position + offset);
Because the rest of that page seems unhelpful. Thanks