- Home /
Scripted rotation is inverted- GUI HUD.
Hello, thank you for taking the time to have a look at my issue.
So I am trying to create a HUD which surrounds my player and has a Ping which always points to the nearest object. I did have this working, however I must have changed... something because now the rotation seems like it is mirrored from the desired direction( see GIF below)
and the code that I am using is:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RadarTest : MonoBehaviour
{
// The target marker.
public Transform target;
public GameObject ping;
// Angular speed in radians per sec.
public float speed = 1.0f;
void Update()
{
Vector3 dir = (target.position - transform.position).normalized;
float angle = Mathf.Atan2(dir.x, dir.y) * Mathf.Rad2Deg;
Debug.Log(angle);
ping.transform.eulerAngles = new Vector3(0, 0, angle);
}
}
Thank you again.
issue-hud-pings.gif
(367.4 kB)
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Can I do a "rotatory" UI like this? 1 Answer
Load/Change scene with UI Button 1 Answer
All UI's appear as black 0 Answers
Setting GUI color alpha math issue. 2 Answers