Coding Tutorial – Part 6

Coding Tutorial – Part 6


Coding Tutorial – Part 6
Time Shifts Plan for Time Shifts We plan to use two methods during time shifts: The process will be directed by these two buttons:
‘1350’ and ‘1750’. The first method will simply change the year
shown under the ‘CITY’ title, making the actual one active,
while the other inactive We will also use this technique
for exchanging the terrains In year 1750 ‘TERRAIN – BAROQUE’ will get active, while ‘TERRAIN – GOTHIC’ inactive, While in 1350 the same will happen,
but in a reversed way The C# script responsible for it is called ‘Time Switcher’ So what it does is the following: In case we use ‘Time1to2’, it will make ‘Time1’ and Terrain1 inactive (‘false’) while ‘Time 2’ and ‘Terrain2’ active (‘true’) In case we use ‘Time2to1’, it will use the
‘SetActive’ command in a reversed way The other method we plan to use will have effect on the buildings of different time phases, namely on the ‘ONLY-BAROQUE’ and ‘ONLY-GOTHIC’ groups It will help raise some of the buildings up from the terrain, while others down the ground We will use ‘Empty GameObjects’ for defining the positions for this lifting effect, different one for both groups,
up and down positions for both time periods Mixing these two methods: simple exchange and lifting effect the time shift will be quite impressive Time Switcher Let’s create an ‘Empty GameObject’ for a start … and name it ‘TIME SWITCHER’ Let’s select it and add the ‘TimeSwitcher’ C# script to it Then let’s define the different objects set by the script by dragging them to their places ‘Time 1’ will be ‘Text 1750’,
while ‘Time 2’ is for ‘Text 1350’ Then add ‘TERRAIN-BAROQUE’ to ‘Terrain 1’ row and ‘TERRAIN-GOTHIC’ to ‘Terrain 2’ row Finally ‘ONLY GOTHIC’ will be set as ‘Period 2’ Coding the Buttons To realise the lifting method we add the ‘Mounter’ script to ‘ONLY-BAROQUE’ first ‘Speed Factor’ should be 0.01 instead of 1 ‘Current Mount’ (starting position) will be
‘UP – BAROQUE’ Finally ‘Camera Comp’ will be ‘Main Camera’ Let’s do the same with the ‘ONLY-GOTHIC’
group of the models Having added the ‘Mounter’ script to it,
‘Speed Factor’ is 0.01 again ‘Current Mount’ should be ‘DOWN – GOTHIC’ position and the ‘Camera Comp’ is ‘Main Camera’ Now let’s select button ‘1350’ … and add three new lines in the On Click ()
section of its ‘Button’ script Add ‘ONLY-BAROQUE’ to the first line select the ‘Mounter’ script as function and choose the ‘SetMount’ command Finally define ‘DOWN – BAROQUE’ as the target position for ‘ONLY-BAROQUE’ group The same way drag ‘ONLY-GOTHIC’ to the second row ‘Mounter.SetMount’=’UP-GOTHIC’ Finally let’s add the ‘TIME SWITCHER’ to
the third row of button interactions and select ‘TimeSwitcher.Time1to2’ Now let’s activate the same scripts for button ‘1750’ first row: ‘ONLY-BAROQUE’ – ‘Mounter.SetMount’ Add ‘UP-BAROQUE’ as the desired mount for the group Second row: ‘ONLY-GOTHIC’ – ‘Mounter.SetMount’=’DOWN – GOTHIC’ Finally ‘TIME SWITCHER’ game object for the third row ‘TimeSwitcher.Time2to1’ Test of Complete Navigation Enter ‘Play’ mode to check the final result Produced by Riga School of Art & Media
and EK Association – 2018

Leave a Reply

Your email address will not be published. Required fields are marked *