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 britghness 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 "Scales" property, if he goes into a zone without much light, it will be darker, and vice versa using the "Lightmap" property. 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 others 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:
But, wathever you have one or more 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 croped 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 wil create a greyscale 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 grey 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 lighness 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 farest. 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 farest, 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 prevent use to save our scale maps and lightmap into our scene in the .tscn format (text based), so you should the .scn format (binary) as a workaround until it'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 addtional depth to your scene.
It must be sepate 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.