Hello I need help with a script, so basically you're an ice cube and you have to get to the finish line before you melt when you're done melting you kind of explode into water with this script Code (csharp): var restartLevel : String; var camera1 : Transform; var finished = false; var shrinkrate = 0.001; function Start () { } function Update () { if (transform.localScale.x > 0.5){ if (finished == false){ transform.localScale.x=transform.localScale.x-shrinkrate; transform.localScale.y=transform.localScale.y-shrinkrate; transform.localScale.z=transform.localScale.z-shrinkrate; camera1.localScale.x=camera1.localScale.x+shrinkrate; camera1.localScale.y=camera1.localScale.y+shrinkrate; camera1.localScale.z=camera1.localScale.z+shrinkrate; } } else { transform.SendMessageUpwards ("GameOver"); } } function finish (){ finished=true; } function damage (damage:int){ transform.localScale.x=transform.localScale.x-damage; transform.localScale.y=transform.localScale.y-damage; transform.localScale.z=transform.localScale.z-damage; camera1.localScale.x=camera1.localScale.x+damage; camera1.localScale.y=camera1.localScale.y+damage; camera1.localScale.z=camera1.localScale.z+damage; } Is there any way so when the icecube is melted it restarts the scene you're playing in? thanks!
Just go to here http://www.kongregate.com/games/iWoundPwn/obbycube and hit play and sit there and wait till the icecube melts.
Well it seems that you already have a system for detecting if you have finished melting: if (transform.localScale.x > 0.5) All you need to do is add else{ Application.LoadLevel(1)} so something like this: if (transform.localScale.x > 0.5){ if (finished == false){ transform.localScale.x=transform.localScale.x-shrinkrate; transform.localScale.y=transform.localScale.y-shrinkrate; transform.localScale.z=transform.localScale.z-shrinkrate; camera1.localScale.x=camera1.localScale.x+shrinkrate; camera1.localScale.y=camera1.localScale.y+shrinkrate; camera1.localScale.z=camera1.localScale.z+shrinkrate; } } else{ transform.SendMessageUpwards ("GameOver"); yield WaitForSeconds (5); //So that the "Game over" SMU has time to work Application.LoadLevel(1); //Replace 1 with the level you want loaded when you loose, levels are arrainged in the build setup (Ctrl + Shift + B) }