Water rising isn’t a very common script in the community but i thought i would share with you a good script that i have hand made for a flooding type of game mode you could say the script is very simple with a water rising method…
The script tutorial: First you need to add a script to a empty game object call it manager center it all down to 0! Copy the .js script and copy paste if you want to use this script and upload on the internet please put this script is courtesy of deathnadosharkgames & DEV
Script:
- //deathnadosharkgames
- var timer : float;
- var timertexture : GUISkin;
- var graceperiod : float;
- var speed : float;
- var water : GameObject;
- function Update () {
-
- timer -= Time.deltaTime;
-
- if(timer < 0) {
- timer = 0;
- }
-
- graceperiod -= Time.deltaTime;
-
- if(graceperiod <= 0)
- {
- water.transform.Translate(Vector3(0,speed,0));
- }
-
- }
- function OnGUI () {
- GUI.skin = timertexture;
- GUI.Box(new Rect(20,15,100,30), “” + timer.ToString (“0”));
- }
Then when copied put it on the manager script as you can see there are 5 variables on the water rise script its self i will go in the detail on what these individual variable’s mean.
Timer: This is a GUI that displays on the top left goes in seconds this should be the same time as the grace period variable witch we will get in to later.
Timer Texture: Is is GUI texture you want to be displayed on the GUI customize the button and font/sizes and colors to exactly get the GUI you want.
Grace period: Holds back the water till the amount of seconds you want to keep the water back example: Preparation hour?
Speed: is how many points in the y axis will
travel
Water: the game object you want to rise