Thank you. While there are a bunch of videos in this subject, you managed to explain in it under 15 minutes. That is the sole reason I watched this one. Was not disappointed!
THANK YOU for this lol, I was slamming my head against a wall for hours trying to figure out how to convert world space to canvas space and this works *perfectly*
Thank you. I was looking for a way to move a UI element to specific places and I would not have discovered the WorldToScreenPoint function in time to finish the game for the Jam i am taking part in.
You can change the render settings of the 3d object/text so that it will be on top of everything else and always fully visible/readable. The screen space solution is still better in this case, but the other statement is a bit misleading.
Thank you for this video. Could we also make it so screen space UIs can be overlapped like gameobjects do? For example in Lineage 2 game, when NPC objects are being covered by buildings or trees or something, their name tags are also covered
Great tutorial. It works just as you showed, but if you're object is off the screen the icon slowly makes it's way into the centre of the screen until i move to see the object again. is there a way to kill this if the object is not on screen?
Shouldn't you be using RectTransform instead of Transform and anchoredPosition instead of position for UI elements so that they are platform and resolution independent?
Great tutorial! How would you make it scale by distance? So that it keeps its own relative size above the "Enemy" position, and gets smaller the further the enemy moves from the camera in world space, and returns to a scale of 1 when the enemy is right ontop of you.
For this you can use the world space (3D) canvas he shows first. The UI element would exist within the 3D scene and will scale depending on distance from the camera. I think maybe you could then use sorting layers to ensure the UI element is displayed on top of everything.
using UnityEngine; public class textHover : MonoBehaviour { [Header("Tweaks")] [SerializeField] public Transform lookat; [SerializeField] public Vector3 offset; [Header("Logic")] Camera cam;
// Use this for initialization void Start() { cam = Camera.main; } // Update is called once per frame void LateUpdate() { Vector3 pos = cam.WorldToScreenPoint(lookat.position + offset); if (transform.position != pos) { transform.position = pos; }
Thank you. While there are a bunch of videos in this subject, you managed to explain in it under 15 minutes. That is the sole reason I watched this one. Was not disappointed!
UI stuff always felt very clunky to work with for me. Your stuff makes me learn a lot.
simple but very good tutorial. Especially because you mentioned the redrawing "issue" of non-static canvases. That is rarely ever mentioned anywhere.
THANK YOU for this lol, I was slamming my head against a wall for hours trying to figure out how to convert world space to canvas space and this works *perfectly*
Thanks You Brother ! You Saved My Azz xD
Glad to hear!
Thank you so very much for this tutorial! It's simple and well explained. ^o^
Thanks for leaving a comment 😊
Thanks so mutch, I was looking for this. Everywhere wants only world space UI and not screen space.
Thank you. I was looking for a way to move a UI element to specific places and I would not have discovered the WorldToScreenPoint function in time to finish the game for the Jam i am taking part in.
You can change the render settings of the 3d object/text so that it will be on top of everything else and always fully visible/readable. The screen space solution is still better in this case, but the other statement is a bit misleading.
Simple and to the point. Great
Thank you for this video. Could we also make it so screen space UIs can be overlapped like gameobjects do? For example in Lineage 2 game, when NPC objects are being covered by buildings or trees or something, their name tags are also covered
Thanks dude! This helped a ton :D
Keep it up man !
Ajudou demais mano, simples e eficiente, te amo
This was great , it wasnt exactly what i was doing but it made me understand how it works and figure it out by myserlf
This is exactly what i need
Great tutorial. It works just as you showed, but if you're object is off the screen the icon slowly makes it's way into the centre of the screen until i move to see the object again. is there a way to kill this if the object is not on screen?
need solution for this too
Shouldn't you be using RectTransform instead of Transform and anchoredPosition instead of position for UI elements so that they are platform and resolution independent?
Video starts around 2:00
Very useful thanks
Hi there, it worked properly but only in FixedUpdate! In Update doesn't work as expected.
What would be good if you had a sprite image that moves to and locks on to that sprite image like in F16 flight sim game.
Nice. Thanks a lot
How would you write the script for a 2d game?
Great tutorial! How would you make it scale by distance? So that it keeps its own relative size above the "Enemy" position, and gets smaller the further the enemy moves from the camera in world space, and returns to a scale of 1 when the enemy is right ontop of you.
For this you can use the world space (3D) canvas he shows first. The UI element would exist within the 3D scene and will scale depending on distance from the camera. I think maybe you could then use sorting layers to ensure the UI element is displayed on top of everything.
script works but it's glitchy on my project. It's flickering and doubles while it's on a moving object
thank you!
ok tq bro
Doesn't work, object reference not set to an instance.
are you using cinemachine ?
Ah Yeah!! Dark Souls health bars
I like
super
Noice!
using UnityEngine;
public class textHover : MonoBehaviour
{
[Header("Tweaks")]
[SerializeField] public Transform lookat;
[SerializeField] public Vector3 offset;
[Header("Logic")]
Camera cam;
// Use this for initialization
void Start()
{
cam = Camera.main;
}
// Update is called once per frame
void LateUpdate()
{
Vector3 pos = cam.WorldToScreenPoint(lookat.position + offset);
if (transform.position != pos) { transform.position = pos; }
// transform.LookAt(cameraToLookAt.transform);
//transform.rotation = Quaternion.LookRotation(cameraToLookAt.transform.forward);
}
}
yyyessssss thank you so much! It solved the glitch for me!!!!
xp
Thanks man
You're welcome!