Spring Submission - Coding and Fixing (cause I'm about to break...)
Coding is probably the scariest element for this game for our group, its like being taken out of civilization and put into the wild. which is to say that we're out of our element a little. despite that it's still getting easier than when we started.
While not the first piece of script i created one of the more helpful ones i quickly made which we used to attach to a variety of objects in our scenes in a Don't Destroy on load script.
Just the couple of lines was needed to help various items in our scenes persist through new levels loading in, as after setting up the UI we found that it disappeared upon a new scene loading in. This had to be applied (luckily it can just be drag and dropped) to any element we wanted to carry over.
The actual first bit of code i added in was a score manage to set up how the player would score points and the UI would display that value.
The original code was setting up a public number which was set to 0 when the game started, and then accessed the text component which i had positioned as the score, then a void to set up that the score would increase and on the update function it would increase by adding a value score on top of whatever the score already was.
The code was slightly altered after having the formal UI session, as it helped me assess why the actual score value of the UI was not carrying over, it was because i was telling the game to reset to zero after "starting" which basically meant loading a new level reset the score.
To fix that was actually more simple than i would have thought, i just needed to tell the game that the public value i set at the top was zero, and then not tell it to reset that score when it started and bingo persistent score.
A small bit of code i also added on the script for the enemies being destroyed was to set up the value of the enemies and to complete the link with the score manager so that it would give points upon killing enemies.
this meant setting a value for the enemies (which is one flat value since Razvan applied the same scripts to all the enemies) and then accessing the score manager and ad telling it to start adding upon their deaths. So that wraps up the scoring for the game.
The final post for the spring project will cover unused concepts for the game.
Comments
Post a Comment