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\$
1
  • \$\begingroup\$ It's a bit hard to say what is wrong without seeing what your camera is recording exactly. Could you post images of what the arrow camera is rendering? Also as a side note, are you sure you want to use a separate render texture for something as simple as the arrow? Most people do recommend using render textures like this for UIs but personally I like just changing the material to skip depth testing and just render over everything. If you do it that way you can just have your main camera render the arrow and remove it from the UI. \$\endgroup\$ Commented Oct 2, 2020 at 3:51

1 Answer 1

0
\$\begingroup\$

You are using the _arrowRawImage.rectTransform.position, which 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\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .