0
\$\begingroup\$

I want to have a guiding arrow on the left side of UI. The arrow is child of the player's camera and it's rendered from another camera into render texture. The render texture is displayed on the screen. The arrow is rotated via transform.LookAt(targetPosition) The problem I'm having is that although it does point in the right direction, form player's point of view it looks like the arrow is pointing somewhere else. enter image description here I want that arrow to point from the point where it's placed on the UI. It should look something like this: enter image description here I tried to do this:
Vector3 direction = targetPosition - _arrowRawImage.rectTransform.position; _transform.LookAt(direction); but it didn't work.

\$\endgroup\$
0
\$\begingroup\$

Nice UI,

You are using the _arrowRawImage.rectTransform.position, that is getting the Vector of the raw image and not the arrow itself. Try working with the position of the arrow transform.

Vector3 direction = (targetPosition - _arrowTransform.position);
_arrowTransform.LookAt(direction);
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.