Start in on the script this is going to be one to define a kind of like light flickering or a lightning
bolt flashing type of the element inside the scene.
And before we do that though let's do one other thing to make the lightning bolt really stand down in
terms of the brightness effect of it.
Let's set up the scene so that we have a really a darker element.
You know how you can still see these objects is not really actual black shadow inside the scene.
If you go to the Edit option and down to our Rynders setting inside the Rynders settings we've changed
our fog.
You can also if you want change fog you can go back and forth between your xponent what we had on the
ambient light Staker ambient lights if we take ambient light.
This is a level light across this scene.
How like how the objects are lit.
So whether if you take it all the way to the White then there's no objects actually being affected by
the lights in this scene if you take it all the way the black the and all the shadows that are actual
shadows become really dark.
So we can take this one.
We might take it to just a little bit above we actually want to try to capture those dark shadows go
for something closer to that really make it feel that more intimidating for Were setting.
And then we also I to go to our dynamic light that we currently have in the sea.
And this just push control didn't make a copy of all right.
So the copy Let's rename this and we'll call this one.
I actually will see thunder clap since we'll be putting that sound to it.
So call this thunderclap going turn off.
Actually we'll leave the shadows on because we'll be turning them on and off.
The directional light no one ends up here.
Let's go ahead and change the color instead of being a bright white.
I actually take that and make it a little bit more of a dirk or try for a little bit more of a darker
blues somewhere around here.
For me the RGV values 0 30 88
0 38th Guine were just kind of creating that sense of night time.
It's a little bit darker out
and with the other light or thunderclap light what we're going to do is create a script for it.
And it's basically just going to turn the light on and off to look like a flash inside the sea.
And we may have to add a few more lights.
We'll see how it goes here in a little bit.
So to make a script inside of the scene we're in our projects I'm just going to roll these up here.
We have a folder called scripts.
This right click on that and do create the new C-Sharp script.
And let's call this one.
Thunder will do a capital T.
We'll see say thunder clap.
Oh capital-T and the catalyse there we just capitalize each of the first letters of the word.
You can push enter.
They create the script for us.
Now for you already comes with an idea it comes with a tootle you a text editor so that you can write
in the code for it.
It's called mon's develop when you double click on the script it will open up for you automatically
.
And what you should be looking at is something similar to this.
We'll see thunderclaps then we'll have the class with it label here.
Now just to make this easy this are first grouped together so we don't want to get into anything too
complicated.
We just want to write a couple of lines of code here.
What we want to do is turn the light on and off and then we're not going to really talk about how it
works per se we're just simply going to write some code.
I'll go briefly over what we're doing but we're going to create actually we'll just create this really
straight forward so we're now going to make any public variables we're just going to make a couple of
private ones.
So we're in the make a ball this a true or false statement.
And I'm just going to say can flicker and we'll say Ken Flickinger is true.
And be sure that when you're typing this that you pay attention to the capitalization.
For instance a day that's a capital you on.
And when they say they do a little curlicues this curlicues are right next to the letter P on the keyboard
.
You want push shift and then the curlicue and you'll create those if you create a square one.
Those aren't going to be right.
They'll give you a red line on it.
Right and right below here we'll do another one called void.
Actually sorry will do one that is going to be in I numerator.
So there's a big word right here.
I and the both are kept the lines as numerator right there and we'll call this the cap for the left
or the first two methods.
These are two functions that we're going to use for a method or a function that's just going to perform
a set of operations and we type it.
I'm going to say if and flic
we're going to do a check to see if we can flick through the light and if we can flicker set it to false
so we're going to say yes you can do it once and turn up.
Now we're putting it inside of a numerator so that we can actually do a weight statement.
We can flash the light and then we can wait for a little bit we can flash the light to get a light and
the light that we're currently connected to we're going to say enable that.
We're going to bring the light on
and then we're going to do something where we wait and in order to wait on the programming side we'll
do something.
This is yield return to be for a second and the second we're going to wait for going to be a random
bean.
It means we're just going to wait for a random amount every single time we do it.
So it feels a little more natural.
Those a little more like less less like someone trying to end that made it directly but just where it
could happen or might not have been with a little bit of time were going to enable light and turn it
up and then we're going to wait for a little bit more time which means we're going a year old and do
another return new.
Wait for seconds.
We'll do another random range here this time.
Let's wait for a little bit give you a little bit more of a time.
We want the light on for a really short so it looks like a flash but when it strikes again let's actually
have it wait a little bit longer.
So say it needs to wait for at.
Anywhere from point one seconds to five seconds
once it gets done waiting then will turn the ability for it to flicker back on when we get the update
.
In order to make the flicker work we can do something called Start code routine.
Make parentheses and do flicker.
Place it right there.
So in terms of code there's a lot of the things happening here a lot of language elements that if your
very first time the program.
Don't worry about it just simply copy exactly what you see.
You just want to place make sure you have the right capital letters make sure you're using the.
You will use the one on the end of it semi-colon on the end of it.
Right is the same one as the colon on the keyboard.
Right.
So once you have this it can push control to save
when they go back into unity and make sure that you don't see anything red at the bottom bar.
You may see something if it shows up as red.
That just means that there's a spelling error somewhere inside.
So you just want to go back to the video pause on the screen and just double check yourself.
Now with the thunderclap game object we made let's just drag the thunderclaps script over onto it.
We have thunderclaps klap script right here with this one on there can actually we should be able to
just push play.
We should see the light here turns on and on and on.
So it's actually just when it gets to work it starts to go
straight
.
Right.
That's going to be our basic setup right there.
That gives us our lighting and gives us a nice little flash that happens with it.
The last thing we want to do with it and we'll give it a try and see how it works here is that we to
do a play.
We want play in an audio file here as well.
So let's go then add the last to the Add component and just type in the source
.
All right.
So we're going to have the thunder clap the play in here but we're going to do it through code.
When I close the rollout here and then the next video will walk through setting up the audio build up
play with