- Home /
Cinematic rotation of HDRI sky
I'm trying to refrence the rotation in the HDRI sky to have a rotating loop of the sky (adding a nice effect) except I'm having trouble getting the reference to the component with a script. https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@5.3/manual/HDRI-Sky.html
public class SkyRotator : MonoBehaviour
{
public GameObject sky;
private void Awake()
{
sky = GameObject.GetComponent<HDRISky>();
}
}
I figured if I had the reference I can just create a larp or loop over two values to rotate. Am I approaching this correctly or is the HDRI sky map a whole different beast of it's own?
Answer by unity_cxn5qouiXK-pvw · Nov 08, 2019 at 09:30 AM
You need to get the HDRISky class from Volume class, and then Lerp the rotation value.
Something like this:
[SerializeField]
Volume volume;
HDRISky sky;
[SerializeField]
float skyRotationAmountPerFrame = 0.1f;
void Awake()
{
volume.profile.TryGet(out sky)
}
void Update()
{
sky.rotation.value = Mathf.Lerp(sky.rotation.value, sky.rotation.value + 10, skyRotationAmountPerFrame * Time.deltaTime);
if (sky.rotation.value == sky.rotation.max)
{
sky.rotation.value = 0;
}
}
Your answer
Follow this Question
Related Questions
How to use a HDR Skybox for U5 ambient lighting, but *not* background image? 0 Answers
Flip over an object (smooth transition) 3 Answers
rotate skybox 0 Answers
[ReWorded] When my trees are rendered, the leaves are transparent... 0 Answers
No skybox slot in lighting menu and staging in the scene doesn't work in HDRP Unity 2018.3 0 Answers