- Home /
Animated SkyBox (Simple Solution pls)
I've recently started Unity, and I've gotten myself familiar with C# and the UI. I've created a game menu and a terrain, but all I need is a skybox. I know how to create a skybox, but a skybox created via that method is stagnant and dull - the clouds don't move, there's no day and night cycle, nothing. You can even tell it's just an image being represented as the sky. How can I make an animated skybox? Please give details and steps as I'm still fairly new. :D
Any quick and easy solution to making anything that isn't quick and easy involves the asset store x]
Answer by Chris333 · Jan 24, 2015 at 06:02 PM
Hi,
only a idea but you could try to render the sky in a second camera and let these camera rotate.
Answer by Digital-Phantom · Jan 24, 2015 at 06:44 PM
Ok here's a quick and simple solution to get a similar effect to the one your after.
Make an empty game object call it what you want (I called mine 'Effects Controller') Center it in your scene 0,0,0, then raise it on the Y axis by about 200 units.
Create a sphere (call it Sun)and make this a child of your Effects Controller. Center this sphere 0,0,0 then move it away from the controller. It doesn't matter if you move the Z or X axis as long as it is further away that any part of your map/scene.
Now add a directional light to your sphere/sun. Rotate the directional light until its facing the center of your scene then adjust the angle so it faces downwards a little. (you can play around with this until you get the shadow effects that you like)
Now open the Add Component panel for your sphere and choose Effects - Lens Flare. Open up the asset store and download the free unity lens flare package. Have a look at the different flares until you find one you like or that suits your scene best.
Now the fun bit. Add this script to your 'Effects Controller' object (not the sun/sphere)
pragma strict
var spinx : int = 0; var spiny : float = 0.1f; var spinz : int = 0; function Update () { transform.Rotate(spinx,spiny,spinz); }
This will make the controller spin and therefor make your sun appear to rotate/move around the sky. Its quite fast as it is but that was easier for testing, just lower the float number for a more realistic movement speed.
Hope this helps.
edit -
Try and use a skybox that doesn't already have a sun in it. You will end up with 2 suns in the sky, unless you want that effect.
Add a material to your sphere. Just a simple material, color it white and make it self illuminating. Not sure if this makes any difference. I did and it all looks good so try it.
You can use this method to do something similar with clouds. Instead of your sphere just make a plane and add a cloud texture to it. Better still make a couple as well as your sphere and place them at other points around your scene. (making multiple controllers will allow you to have different clouds, moving at different speeds)
Lastly you can also do this for a night time effect. Just give your sphere a moon texture (google it, there are lots) make the sphere bigger to the size you need. Adjust the brightness of your directional light and you are good to go.
Have fun experimenting.
Answer by astracat111 · Sep 18, 2019 at 04:33 AM
The absolute best way to make an animated anything is with writing a shader, and since it's so complex definitely take a look at the asset store. It's well worth it.
You have to think about performance, so just using scripts isn't always a solution, however since the sky box is just one material in the sky it might not hurt to have a C# script in this case...
Your answer
Follow this Question
Related Questions
how exactly to I add a "sky" to my terrain? 1 Answer
Dynamic Skybox 2 Answers
Skybox problem, it's like cubed, clamp not working 1 Answer
Why don't shader LODs work on skybox? 0 Answers
How make dynamic skybox with animated particles system 0 Answers