Converting world rotation to screen rotation

I am trying to turn ui element toward the 3d-world object.
can anyone tell me what is wrong in my code?

                Vector3 posA =
GameObject.FindGameObjectWithTag("PlayerShip").transform.position;//Player Position
                Vector3 posB = target.transform.position;//Target Position
                Quaternion dir = Quaternion.LookRotation (posA - posB);//Get Direction
                dir = Quaternion.Euler(0f,0f,dir.eulerAngles.y);
                Aim3.GetComponent<RectTransform> ().rotation = dir;

@Garrom

Hi there, image would help…

What are you trying to map to canvas?

Who knows if your characters/tanks/spaceships/ants whatever are on top-down map, or sideview? I consider it bit hard to give answer when nearly no info is provided…

Anyway, as you are working with vectors, most like it’s just case of flipping target and player in direction vector part, or in your euler to quat making dir negative… for example… but as no more info is available I’m only guessing.

I making top-down space game. image should show the direction oriented towards the lock-down enemy.
but only if the targeted enemy is not visible on the screen
2905325--214004--Bez názvu2.png 2905325--214005--Bez názvu.png 2905325--214006--Bez názvu3.png
according to me it looks like a bad converted coordinates.

ps. I originally did not want to write too much because I’m Czech and translate something into English for me is really difficult.

@Garrom - Did you try the flipping of values I suggested?

Also, is your game aligned on vertical 2d plane or on xz “table” like orientation like it was 3D content.

I’m asking because I see sprites :).

My game use 3d models and 3d space but all moves are aligned to horizontal space (or XZ space). All sprites are rendered using Canvas object.
The big red pixel art arrow is image what i trying to rotate.