I spent some time working on new assets including, pressure plates (with different animation states - on and off), large tubes, broken computers, iron surfaces and a door (with a unique animation and design).
I also worked on introducing lighting that affects the world environment. As I am working in a 2D environment, so by default the sprites won't be affected by lighting. To allow the sprites to be affected by the lighting I had to create a custom shader that I could apply onto all of my objects.
Once I had created a materials I just had to change a few settings within the component. I set the shader type to be "Sprites/Diffuse" and then from there I set 'Pixel snap' to be true/checked the box.
From here I added to the respawn script attached to the player as I wanted to add some UI to the game so that the player knew how many clones they had left. I designed a basic texture that would be used to represent the clones. I then created some text that I would reference later in the respawn script so it's contents can be adjusted while playing.
On line 12- I created a public reference to the UI text that would display how many clones you have left.
On lines 14 and 15 I created some public float (decimal values) that would be used to determine how many clones the player should have in total as well as how many they have left. Looking back at this there are no errors, but it would have made more sense to use the variable type 'int' (integer variable) as I am only going to be using whole numbers for these two variables.
Line 21- This line is used to set the variable 'ClonesLeft' to be itself minus 1.
Lines 29 and 30 are within the Start() function which will take place as soon as the level is run. These lines of code set the max amount of clones to be 3 and then sets the current amount of clones to be equal to the max clones. On line 29 I do something called 'hardcoding' a variable, this is when I set the value of a variable within the code and not within the inspector view. It means that if I want to change this value I have to edit the script which is more tedious than being able to edit it as a public variable.
Then the last part to making the UI functional is to update the value of the text every frame as seen on line 36 (it will update every frame as this code is written in the Update() function.
Comments