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;
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
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.
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.