Tuesday, 9 December 2014

TriggerEnd


The end screen script is definitely where I learnt the most. I was having issues with how the end the game and using GUI texts, but I started using 'RayCast' and two planes as buttons. The RayCast sends a beam between the mouse click and the object and detects whether something is there or not. By placing two planes in front of the player and making them only appear when the trigger is reached, the player can then click and choose whether to restart or quit the game. This is much easier than messing around with GUI texts which have to be completely handled in the script and can cause issues if you want text that is changeable. By using 'hit.collider' and 'RayCast' I was able to make buttons rather than just having the game do something automatically. I had a small problem at the end where the timer wouldn't stop when the player reached the trigger point, but solved that by putting the timer in an 'if' statement and setting a 'GameOver' variable.



When the player reaches the trigger zone two buttons show up, Restart and Exit, and the player can click either, to either play the game again or quit the application. I downloaded a free font to make the buttons and outlined them in white so they could be seen on any colour. The timer also stops when the trigger is reached which sounds obvious but took me a while to work out as I had to use the FindObjectsOfType which was something new that I learnt to like this script with the TimerScript. This coding has definitely been a learning curve for me and was not what I expected to be doing going into the project, however I have learnt a lot of useful things and wouldn't mind doing it again and learning more.

No comments:

Post a Comment