- Home /
Who i can rotate new UI Image element?
I'm creating a UI compass. I need to rotate the arrow after the Player. How can I get access to the rotation of the image? Tried this:
public RectTransform Arrow;
public GameObject Player;
void Update () {
Arrow.Rotate = new Vector3(Arrow.rotation.x, Arrow.rotation.y, Player.transform.rotation.z);
}
it's doesn't working
Answer by NapalmRain · Oct 03, 2014 at 10:35 AM
I myself have found a solution: Vector3 PlayerRot PlayerRot = Player.eulerAngles; Arrow.transform.rotation = Quaternion.Euler (0, 0, PlayerRot.y);
You helped me big time mate. Thanks for answering your own question!!
Answer by Idual · Sep 25, 2019 at 05:43 PM
Just to add. You might want to use localRotation in case your Canvas is rotated.
Your answer
![](https://koobas.hobune.stream/wayback/20220613164312im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Unity 4.6 Beta Controller Menu Button Movement 0 Answers
Can I access the new Rect Transform Component by code ? 2 Answers
How can I make the text prettier in the new GUI system? 1 Answer
screen space camera hud (4.6 beta) 2 Answers
[4.6 UI] Possible to reference parameter of OnClick persistent event? 0 Answers