- Home /
Rotate world space UI element on Z axis towards gameobject.
Hey. So I want to rotate a world space image towards a GameObject on the Z axis. I have looked into LookAt(lol) and the other ones. But it didn't work. Anybody who knows how to do it? Thanks in advance!
Answer by prithiv · May 08, 2019 at 05:00 PM
Simple, Add an empty gameobject as a child to the main game object and position it (0,0,0); And add the Rotating object as a child to the Empty Game object and move the position accordingly. Now rotate the empty game object in Z axis. or use transform.Rotate(x,y,z); The Rotating object will rotate around and follow the main gameobject. See the Image attached below.
Yeah but i have a list of enemies and then picking a random of them. So i want the ui element(which needs to be child of player) rotate to the given enemy.