Question by
jessie_embiado · Dec 02, 2021 at 06:50 PM ·
uitransform.positionvuforiaaugmented reality
Vuforia AR: Access only two axis in transform,position
I am creating an Android AR app where a UI element is following a 3D object. It works fine and my only problem is I want to make the position ignore the Y axis in the target objects position so it wont move forward and backward.
This is the code that I got from searching on Youtube tutorials
public class WorldSpaceButton : MonoBehaviour { [SerializeField] private Transform targetTransform; private RectTransform rectTransform;
private void Awake()
{
rectTransform = GetComponent<RectTransform>();
}
void Update()
{
var screenPoint = Camera.main.WorldToScreenPoint(targetTransform.position);
rectTransform.position = screenPoint;
}
And here is where the slider is going forward/backward when moving the camera close/far to the image target.
Hope someone can help me in this problem. I'm stuck because I don't know what to do next. Thanks!
vlcsnap-2021-12-03-02h33m41s956.png
(202.7 kB)
vlcsnap-2021-12-03-02h33m58s185.png
(241.8 kB)
Comment