- Home /
Do a Fade Effect like Fortnite Compass
How i can do this fade effect
On this?
this is my script that change the parameters when i move my camera:
using UnityEngine.UI;
using UnityEngine;
public class Compass : MonoBehaviour
{
public RawImage CompassImage;
public Transform Player;
public Text CompassDirectionText;
public void Update()
{
//Get a handle on the Image's uvRect
CompassImage.uvRect = new Rect(Player.localEulerAngles.y / 360, 0, 1, 1);
// Get a copy of your forward vector
Vector3 forward = Player.transform.forward;
// Zero out the y component of your forward vector to only get the direction in the X,Z plane
forward.y = 0;
//Clamp our angles to only 5 degree increments
float headingAngle = Quaternion.LookRotation(forward).eulerAngles.y;
headingAngle = 1 * (Mathf.RoundToInt(headingAngle / 1));
//Convert float to int for switch
int displayangle;
displayangle = Mathf.RoundToInt(headingAngle);
//Set the text of Compass Degree Text to the clamped value, but change it to the letter if it is a True direction
switch (displayangle)
{
default:
CompassDirectionText.text = headingAngle.ToString ();
break;
case 360:
CompassDirectionText.text = "0";
break;
}
}
}
screenshot-1.png
(42.3 kB)
1.png
(41.2 kB)
Comment