Hello guys, i have my 2d image following 3d object on screen, ,however i need that image to stay on the screen even when i cant see the 3d object ingame, its kinda navigating player to turn around until he can see the object, but now i cant see the red marker when i turn around, and i need to keep it on the screen, any hints? thank you
Here is image so you can exactly know what i mean,… we can see red marker which follows 3d object position, but when you turn around you no longer see marker, and i need it to stay on screen. I need to stop it somehow when its trying to get beyond screen size
Hi @smokys! How are you? Nice question! I decided to create something like this for a 3D game after another 2D game forum question. Unfortunately, I didn’t finish it because of some problems that I was unable to solve at that moment.
Thats what i was thinking to do but was not sure how to use those co-rds, and i thought its Math floor so i was completely wrong, but not sure how to use clamp… maybe something like setLocalPosition(Math.clamp(-1, 1), Math.clamp(-1, 1), 0) ??
Well I also rotate the camera, maybe thats why its not working completely, try Albertos and let me know if that works for you, i im good anyway hope you too
Nope. I made a little progress, i tried to change anchor and pivot of the image and its now not going off the screen but the positioning is bad. i will try to play around little more with that
Not it is quite good but this is weird, not sure if it soupposed to be like that but now im right behind it but marker is top and should but down as the object is behind us
Well now i dont even have that issue , now its the same, i tried every single preset but only Bottom left anchor i closest to right solution, but its not working though… top-left not is still off screen ( i mean the whole top and left side )
I still didnt figured out how to detect whether object is behind me, @yaustar could you please try it in your project u mentioned above? like put the object with UI far more behind the camera to see if its also your problem…
Becausse when you are close to the object and its behind camera then there is no problem, but the issue comes out when the marker is way more behind camera
you can use dot product of two 3d vectors … one of them being the camera.forward direction, and the other being normalized camera position - object position. If the result is less than 0, those vector are facing away from either other and that means the object is behind the camera.