Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: storm33229 on December 01, 2012, 08:51:22 PM
-
Well actually I want it to be hearts instead of a bar. I already have a 2D hearts UI for my character, but I'd like to create one for my enemies too. I've created a 3D UI, and dynamically created some sprites and attached them to the panel, the trick is to position them appropriately on my characters which I have not yet figured out. They also have to rotate to face the 3d camera too, sort of like a billboard sprite. One example of what I am looking for can be seen in Windward...
-
Windward has a 2D HUD. Unit HUD is a prefab containing HUDText, unit's name (label), and a pair of sliced sprites showing health. This prefab also has a UIFollowTarget script on it. Both UIFollowTarget script is a part of HUDText package available for sale. If you do a search for it here, I've actually posted code for UIFollowTarget in the past.
-
Since I absolutely love NGUI, I am off to purchase that package right now! Sorry for getting back to you so late on this - I think I forgot to subscribe to replies... ::)
-
I am having some trouble getting this to work. I've attached the HUDText and UIFollowTarget components to the sliced sprite (heart) in my UI, but the sprite is not following the object appropriately.
-
...it usually helps if I follow the instructions and use a 2D camera instead of a 3D one... Anyway, it works now, thank you so much!
-
Windward has a 2D HUD. Unit HUD is a prefab containing HUDText, unit's name (label), and a pair of sliced sprites showing health. This prefab also has a UIFollowTarget script on it. Both UIFollowTarget script is a part of HUDText package available for sale. If you do a search for it here, I've actually posted code for UIFollowTarget in the past.
Is there any way to do it without the HUD text plugin?
-
I mentioned I posted the code for it before. You can still find it if you search for it, or you can just do math yourself. Knowing the 3D point, use the game camera to transform it to screen space (camera.WorldToScreenPoint). Now knowing the screen space, use the UI camera to transform that position to world space (camera.ScreenToWorldPoint). Now inverse transform this position to be relative to the panel you want it to be a child of (panelTransform.InverseTransformPoint). Last step is to set the widget's transform.localPosition to that value.
It's all math, all Unity, and not really an NGUI question, but there you go.