OK we've now talked about getting things into the and some of the beginnings of VR and we've also talked
about blueprints and scripting in here.
Now I want to combine the two and I want to take these scripts and use them in VR instead.
OK so what we're going to do is migrate these scripts to the VR Test scene where I've migrated this
whole level to.
And we'll see if we can get them to work in there and sometimes in VR you have to think in a different
manner.
It won't just be walking through this thing because you're actually warping all over the place so they'll
have two different things that we do to interact and I've showed you with buttons and with grabbing
things how you can interact.
So that's a good way that we can trigger these events.
So let's migrate this let's check the blueprint and make sure that that's got everything we need yes.
So there's our lights turning on right trigger boxes triggering all these scripts so we need to be able
to copy these into other objects.
And the other thing we want is this trigger the trigger box blueprint and this one this trigger box
has this script in it which is cool.
Something we did in the last section.
So we want those two things brought in and migrated to our other scene.
So here they are right here.
If you right click on it and go to acet actions migrate
OK migrate all that to our new project or import the content folder.
OK we'll just overwrite everything in the other scene.
Grab this one I said actions migrate.
OK.
Now when we go into that one there should be these trigger boxes and they should have the scripting
attached
to open project go to our view or import open in here we can open level.
I always go to first person example and then here you can see our trigger boxes are here.
So this we actually want to delete and we actually don't want these trigger boxes in our scene at all.
We want to do is grab the scripts off of them.
So here we are what's triggering these right now is on component overlapped.
That won't work with the car.
So actually let's not delete it there but let's just only grab these scripts
copy Control-C
and then on this button let's do it blue print open blue print editor and instead of making that quick
the level which isn't super useful let's posts some of these scripts into here.
Paste some of these scripts into here.
OK.
There we go.
Now which parts of this do we want to use one of these should we be turning the lights on and one of
them should be turning the lights off so let's just take this event pick up compile save.
Now let's go test that out and see what's going on play.
OK there were a couple more adjustments I had to do before this would work.
First of all I had to go into the blueprint of this light which is called Can light blueprint can light
and in here I turned it off.
OK so I selected the light component.
There's two components here.
There's the static mesh which is that little pock.
And then there's the spotlight attached to it.
I turned up its intensity a lot.
I'll turn it up even more so we can see if it's definitely on or off.
And then well let's change the light color to see it there.
OK.
And I said it to be off originally.
So that's in the rendering visible OK.
So turn it off as the level starts compile and save.
So right now you can see it's not on.
And then in here with our new scripting attach and this isn't attached to anything but our event is
event Pick-Up So when we go and pick up that cylinder and as you know we're not actually going to pick
it up it's just going to stay there but it will trigger this event nonetheless.
So we changed the scripting so that it doesn't pick up but what it does is it puts our lights on and
off script.
So take that array of lights and new visibility is checked so that means it should turn on setting visibility
visibility.
Yes.
OK.
So when we grab that it's not going to attach your hand but instead it will turn on all these lights
over here.
So let's try that out and keep our fingers crossed that it works.
OK here we are inside here.
Let me get my hands right OK.
If you go over here there's no pink light being emitted in those lights are on still they look on because
we haven't changed the material.
That would be a different script altogether for a different part of the script at least.
But there is no red light being emitted.
So if I go over here and turn on the switch or grab the switch you can see my hand changes it's ready
to be grabbed and you can see now there's a be being cast.
There we go.
We now have red lights.
We're now in the red light district.
OK there you go.
So those lights turned on those bright red lights turned on.
And our button worked.
So that's cool.
Not super useful yet.
You'd have to adjust it more in order to make it useful.
But that's how it would work.
Now we could add more scripting to that obviously and put my head set down.
We can add more scripting to that to make it more useful but that's how you turn on the lights.
Let's see if we can get another button to change our materials like we had in our other scene our first
person examples seen.
Let's take the same blueprint she called button
and let's duplicate it and call it material button or mat button once we have our map button we can
drag it into our scene.
Let's put it on the wall that we're changing about that
set it right there.
Now and this one this is a different script than our other one.
Let's go to our trigger boxes.
Look at it.
Find the material on.
Think it's this one right here.
Let's grab all this.
Copy it at the blue blueprint of this button.
Should be Matt button.
Yes.
Paste it into here.
Link it up.
Now we need to make sure it's referencing all the right objects and materials and everything like that.
This works not front of variable name materials and Matt buttons.
OK.
When I posted this in here we had a lot of problems and that's because it's a completely different kind
of object.
We're in a totally different scene.
So what happened is I pasted this into here and linked it up to the event pigout But the counter variable
that we set up in the last section and the materials array were not set up yet in here because that
was set up in the trigger box one.
So in this button one there was no such variables.
So everything got kind of unlinked.
So what I had to do is go back here create a new variable one called counter to match that name exactly
set it to integer and then set up another variable called materials set it to a material type of data
inside of there and set it to an array by hitting that button.
OK.
And then I recompiled and it now knows that all this stuff is in here.
And then I had to kind of relink it to the array box and the counter to there and everything works you
can see they're still not working this length because that's trying to grab the length of the material
array which wasn't in here but now it is.
So I can just release it right there.
That should cover everything.
OK so these are some of the problems that you'll run into as you're trying to grab scripts and bring
them from one place to another.
The more you understand about scripting and what it does the more all of this will make sense to you
as far as when it gives you an error you'll be able to figure out oh I know why that is because I in
my other script had all these variables that it's referencing.
And in this new script I don't have those.
OK once you've got this blueprint up and running and compiling properly.
Go in here.
And we will need to check the materials.
One thing I need to show you too is that we need to make materials visible.
It's a public variable at this point.
So quick the eyeball next to it compile save.
And that means when we have this button selected in here we can now see all the materials that were
going to be using
and you can see it's just in the default here we could change that.
That it's better instead of category default we could change category material a sign.
And what that's doing is it's showing us as a public variable the array of materials that we're going
to be putting on this wall.
So if I look here I already added some in here a mere CUV material.
Rich let's spend something better than that.
Would it find something in here.
Nolte's is there make it the same as the floor.
OK.
Anyway so that's our array of objects that it's going to be drawing from in the script to apply to this
wall.
The only other thing I had to do was remember in the other scene we set up this this was a special wall
that had a blueprint on it and we call that wall material change BP.
So I tried to run this script and I noticed that right here if you go into the script that button was
grabbing an actor from this class this blueprint class this script called wall material change BP.
And since we're in a different scene than the original where the script was created this was actually
just a static mess sitting here and it was not called.
It was not a blueprint of wall material change.
So but when I migrated it it actually grabbed that.
So I went into wall material change BP I deleted the static mesh that was there and drag this in.
And put it in place.
OK so now it is referencing an object that's actually in the scene it has to reference the actual wall
or else it's not going to work.
So make sure that happens as well.
And now everything should be all set up that we can come in here and test it out.
So let's try it.
Let's turn on our red lights first.
Uniform
now the moment of truth for our
kids.
There we go.
Leave it like that for now.
There's our material.
And you can put you can make that array how you want different materials to shuffle through.
And there it is that buttons working out so we can use little buttons like this to bring up different
things and interact with our sleep.
That's pretty cool.
Instead of trigger boxes where you walk through them.
Now we have buttons that you grab.
And of course there's other ways to do this too.
This is one easy way that I've found to make interactive things going on in your scene.