I'm trying to incorporate a function where a player must reach an area within a particular time limit. I've got my timer script set up so when it reaches zero, a 'gameover' scene is loaded:
Now I'm trying to figure out how i can add a function so when the 'player' collides with the 'portal' with say, 20 seconds left to spare, a scene indicating that they'd won a 'gold medal' would load up. If they instead happened to finish with 10 seconds left to spare, then a different scene would load up indicating that they had won a 'silver medal' etc. Overall, I'm aiming to produce three different end-of-level scenes (Gold, Silver, Bronze).
I have a script attached to the 'portal' gameobject which currently identifies if the 'player' collides with it, to then apply a Application.LoadLevel function. Of course, with this new function I am trying to implement, I'm assuming i would need to pass some kind of if statement through? This is the script after various attempts of getting the newly proposed function to work:
The commented out section is what I am assuming is the way I would get the function to work, but the problem i have is that I already have an if statement applied to the OnCollisionEnter script to identify the collection detection. :/
So I'm writing to ask for your advice and help as to how I could pass this proposed function within the script that I have. Any guidance would be greatly appreciated!
You can use if-statements enclosed into other ones. I would modify your script as follows, assuming that you win a gold medal for 20+ secs, a silver one for 10+ secs, and a bronze one for finishing the level with less than 10 secs.
answered Apr 02 '12 at 05:31 PM