A while back I was following along with a live tutorial by brackeys on how to make a clone of Cut The Rope. I did this basically to learn a new thing in unity so that maybe I could use it in a future project. overall it works well but I never finished it so it's kind of pointless. If I were to use it in a project again id like to try to make it more stable with less wiggle.
Here is the code for the rope cutting that sends a Raycast out and if it hits something with the tag link then it destroys the collided object:
The code for the generation of the rope void: start contains the generaterope function which calls at the start. In the generaterope function, it sets the previous rigidbody to the rigidbody of the hook.
Next in a forloop, if i is less than links then it instantiates a link and then gets that link's hinge joint and connects it to the previous rigidbody. After this, if i is less than links minus one then the code sets the previous rigidbody to the links rigidbody if not then it connects the key to the rope end.
The code for the lock first calls for a level manager which can be set in unity it does this so the script can call functions from that script.
Next in an on trigger enter 2D if the object that the lock entered collision with is tagged key then it calls the key hit function.
In the key hit function, it calls load screen which loads a scene depending on a string. after this, it sets Time.timeScale to 0 pausing time.
Here is the code that holds all the menu and UI functions mainly for the win, next level, and death screen.
At the top, we declare all the variables needed for the code to function. in the update function if the key escape is pressed and the bool is paused is true it calls the close function if not it then calls the open function.
In the open function, it sets the pause menu UI game object to true sets ispaused to true then sets the Time.timeScale to 0 pausing time and in the close function it sets the pause menu UI game object to false sets ispaused to false then sets the Time.timeScale to 1 unpausing time.
After all of them, the next functions are the ones being called in-game by the replay, quit, next level, and menu buttons. quit simply closes the application. next-level, menu and retry load a scene depending on a string and load screen sets next level screen to true.