The last feature of Escoria you will certainly like to use is to define a walkable area for you main player character: a terrain. This terrain can also affect the character scale to simulate perspective, and the character brightness and color to simulate light in your main scene.
Technically, the "terrain" node contains all the information about the walkable areas of your scene. In this area, the player will be able to make the main character walk. If the character goes far away in the landscape, he will be smaller according to the perspective using the Scalesproperty, if he goes into a zone without much light, it will be darker, and vice versa using theLightmapproperty. The terrain will define theses areas precisely.
A terrain node should be added in your main scene, probably just after the background node, like in this example:
The "terrain" node consists of a node of type Navigation2D, with the script globals/terrain.gd attached to it. To define a walkable area, add one or more children nodes with pathfinder area information, a node of type NavigationPolygonInstance.
Then in the Navpoly property of the inspector, create a New NavigationPolygon. Use the pencil in the toolbar of the central panel to create a polygon. Click on the first point again to close it, it should be filled with green. You can edit it with the second tool next to the pencil.
So we have a simple walkable area now. You can add holes in your terrain by clicking again on the pencil tool and drawing inside your first polygon.
Maybe your walkable area is divided in several part, or maybe an action will change the walkable area (unlock some part for example): in those cases, create other NavigationPolygonInstance nodes. By scripting with the set_state function, you should be able to place an item in your scene with animations that control the "Enabled" property of each NavigationPoligonInstance node.
Here is an example of a finished polygon:
Whether you have one or many polygons, the character scale or light will not be modified by its position on the terrain yet. To achieve that, first, you will need to create two PNG images per polygon: one for light, one for scale. The pictures should have the same shape as the area, but can be smaller in pixel and cropped to the be used only in the needed zone to save some memory (we will upscale it later with the Bitmaps scale property)
For light, you will create a grayscale picture, a lightmap, where full light is defined by full white and the full shadow is defined by full black. You can use all the values of gray for nuances. You can also create an RGB pictures with full colors, so your shadows and light will be colored, but keep in mind the lightness values of your colors, unless you are doing a dancefloor scene!
For perspective, you will create a blue picture, a scale map, using only blue values on the blue channel: full blue is the closest, no blue is the farthest. The simplest way to do that in your image editor is to lock or disable other channels than blue and paint a black and white gradient as a starting point: black will be the farthest, white will be the nearest.
With your pictures done, click again on the terrain node in Godot, the terrain script show several parameters:
Keep in mind that the "scales" and "lightmap" bitmaps are contained within the node, and they don't reference an external file. If you change your bitmap files, you need to load the again in the node.
Here an example of a scales map:
Here an example of a lightmap:
⚠ For now a small bug in Godot prevents us from saving our maps into in a .tscn (text based) scene format, so you should use the .scn (binary) format as a workaround until that's fixed.
You can also add objects in your scene so the player can be in front or behind them depending on his position on the terrain, to give additional depth to your scene.
They must be separate sprites, usually placed with Sprite nodes, and they must have two properties to be correctly handled by Godot and Escoria:
To ensure your foreground sprites are always on top, you should place them after the player in the node tree, and give them an high value in their Z property.
If you have items on top of your foreground objects, give them an even higher Z value, and don't forget to also check on the "Use custom Z" property.
Il y a une erreur de communication avec le serveur Booktype. Nous ne savons pas actuellement où est le problème.
Vous devriez rafraîchir la page.