Skip to content

Instantly share code, notes, and snippets.

@sbritorodr
Last active November 24, 2022 18:33
Show Gist options
  • Select an option

  • Save sbritorodr/7f0e57fa991febd8f62bfb93f1eddc84 to your computer and use it in GitHub Desktop.

Select an option

Save sbritorodr/7f0e57fa991febd8f62bfb93f1eddc84 to your computer and use it in GitHub Desktop.
How to add water to your level

How to add Water to any level

@sbritorodr

In SM63R, water is essentialy an animated polygon with a surface "shader" which calculates interactive waves. The last part can lead to some issues and problems, if the polygon is created incorrectly.

IMPORTANT: Water polygon mandatory properties

  1. At least 4 or more points
  2. The surface must be completely horizontal. If not, the water is completely static and touching the surface crashes the game.
  3. The angle of both vertices should be 90º. If not, it flickers
  4. The poligon surface can be splitted into two segments, but each segment must be at the same height (instert two images provided by @jaschutte)

The bottom of the water polygon can be any shape you want. Example: (Insert img of tutorial_1_3 water with some annotations)

How to add the water polygon.

  1. Search water.tscn in the bottom left panel of godot. Drag and drop the file to your current level
  2. A red square should appear to your level and a water sprite should appear on the top left pannel of godot.
  3. Select the water sprite and inside inspector look for the "polygon" script variable.
  4. Click on PoolVector2Array. You will see all the vertices of the water polygon (by default is 4)
  5. Change each point manually. Use the Ruler Tool to help you place the vertices at the correct x/y coordinate.
  6. Check if all mandatory properties are as explained above.
  7. Change the Z index parameter if the water is on top of the terrain.

Some tips:

  • Make the water polygon bigger than the hole made in the terrain, this way you can hide the sides of the water polygon.
  • Do not scale up the polygon using the scale tool or changing the scale water property under inspector, because the water texture will be scaled as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment