Hello All,
I am new to unity and also starting to learn c# then I have this simple game that has a rocket(player) and some obstacles falling on it. Now when the rocket is hit by this the game should be game over then a game over panel appear (which I already have), the panel will have two options it is either to continue the game using coins ( which are collected through the game) or end game then the level restarts.
Now, on the end game button - the level restarts which I am using application.loadlevel script and it is fine now. Then the other option which is the continue with coins - I am able to create the code for deducting the number of coins from the total coins and also hide the panel but I dont have idea on how can I continue the game from where the rocket died.
Here are some of my codes:
For my Rocket this is the code the triggers the collider then set the rocket to inactive, i used to write the destroy code but it was not good, as they say if i want the continue option.
void OnCollisionEnter( Collision collision)
{
if ( collision.gameObject.tag != “PowerUp”)
{
if (!destroyed)
{
GameObject part = GameObject.Instantiate(explosion, transform.position, transform.rotation) as GameObject;
gameobject.setactive (true);
destroyed = true;
}
}
}
I am looking forward and thanks a lot for future advice.