ABOUT
In this folder are levels, the structure of levels looks like this:
LEVEL.JSON <- the main data file of the level, it contains objects, light and other information of level.
{
"weather_color": "0a0a0a", // HEX color of sky background
"daylight": false, // turn on/off daylight state of the level
"fog": true, // volumetric fog, works only when daylight:false
"light": [], // array with light sources
"level_data": [] // array with level objects (static and usable)
}
LIGHT : [ ] <- array with light sources
{ "color": [ 238, 157, 49 ], <- array of the colors R G B "distance": 7.0, <- float number for the light size (light sphere diameter) "energy": 1, <- float number for the light source brightness "name": "point_light", <- by that name you can find this light by scripts "position": [ 11.36, 1.91, -2.91 ], <- array of floats for Vector3( ) of position "shadows": false, <- turns on/off shadows on level (works only when daylight:false) "type": "point" <- type of light }
Level loader have only "point" type of light, remeber it!
LEVEL_DATA : [ ] <- array with level data. There are few types of objects.
Let's start with simple one, static object. It hasn't "id": "id_type", so it's static. Like terrain model, boxes, walls, etc.
{
"model": "assets/...", <- path to *.obj model, starts from assets/
"texture": "pbandit.png", <- texture name in assets/textures/
"position": [ 0, 0, 0 ], <- position, float numbers
"rotation": [ 0, 180, 0 ], <- rotation, float numbers
"collider": null, <- generate colliders, can be null, "box", "mesh", "sphere"
"scale": 1, <- scale times, or can be array [1, 1, 1] of floats
"lit": false, <- lit/unlit material can be fake emission with no light
"name": "object_name", <- name for using in scripts through get_node()
"alpha": false, <- transparent texture if it has alpha
"billboard": false, <- billboard or not
"double_sided": false, <- on/off material back culling
}
Second type of level objects its usable or "dynamic" or whatever. The contains special key -> "id": "id_type"
List of all available id types:
"id" : "sprite3d"
Sprite object in 3D that can be billboard, best example - light sparkles under lamps in underground
"id" : "spawn_point"
Invisible object that spawn player at self coordinates and rotate it. Can be only one on level!
"id" : "animated3dsprite"
Sprite object but with animation, only used for fire.
"id" : "radiation"
3D area that has shape of cube and if player come inside - it start hurt the player
"id" : "hostile_eyezone"
3D area that allow enemies attack player inside.
"id" : "npc"
Friendly NPC
"id" : "npc_hostile"
Hostile AI Bot
"id" : "loot_money"
3D usable area in shape of cube that gives player only money on use
"id" : "loot"
3D usable area in shape of cube that allow player to open loot window and take items from it
"id" : "usable_area"
3D usable area in shape of cube that gives player event key after use
"id" : "transition_to_level"
3D usable area in shape of cube that change level on use
"id" : "transition"
3D usable area in shape of cube that allow player to move by waypoints and teleport to specific position in current level
"id" : "block"
3D invisible wall, that block player raycast so player can't use triggers behind this block
And now what kind of keys can be added to object of specific ID.
"id" : "sprite3d"
"texture": "filename.png"
Filename of texture in textures/
"3d_sound": { "volume_db": 0, "audio": "assets/...",
"max_distance": 5.0 }
<- 0 is 100% volume, -88 is 0% <- path from assets/ <- max distance float
"id" : "spawn_point"
Keep only id, position, rotation and name.
"id" : "animated3dsprite"
"sequence": "fire"
Main sequence of fire animation.
"id" : "radiation"
"size": [1.0, 1.0, 1.0]
Size of area in float
"id" : "hostile_eyezone"
"hostile_id": "any_string"
ID of eyezone for AI Bots
"size": [1.0, 1.0, 1.0]
Size of area in float
"id" : "npc"
"profile": "npc_profile_id"
ID of profile from creatures/characters.json
"id" : "npc_hostile"
"animations": [ "anim1", "anim2"... ]
Attack animation for AI. All anims list search in scripts/p_game.gd
"profile": "ai_profile_id"
ID from creatures/enemy.json
"zone_id": "eyezone_id"
ID of eyezone where they will be
"id" : "loot_money"
"value": 100
Money amount. Use Int value.
"model": "cube"
You need add it!
"invisible": true
Always keep it invisible
"id" : "loot"
"loot_id": "loot_id"
ID from gameplay/loot_containers.json
"model": "cube"
You need add it!
"invisible": true
Always keep it invisible
"id" : "usable_area"
"event_key": "key.id"
Add event key, then you can add logic for key in scripts/p_game.gd
"model": "cube"
You need add it!
"invisible": true
Always keep it invisible
"id" : "transition_to_level"
"condition": "key.id"
*optional* door will have lock icon and can't be used until player will have event key with this id
"level": "level_folder_id"
level ID for loading
"model": "cube"
You need add it!
"invisible": true
Always keep it invisible
"id" : "transition"
"target_position": [ 1.0, 1.0, 1.0 ]
Position of player destination when door will be used
"target_rotation": [ 0.0, 0.0, 0.0 ]
Rotation of player destination when door will be used
"invisible": true
Always keep it invisible
"waypoints": "waypoint_id"
ID from gameplay/waypoints.json
"id" : "block"
"collider": "box"
Always put box collider
"invisible": true
Always keep it invisible
Also "id" : "transition" has some special words inside "waypoints": "waypoint_id" key, that can help you to move player in different ways.
Here's list of this additional words:
$to_this_door
Move camera from it's position forward to the trigger position. This word must replace waypoint id.
<waypoint_id>_last_points
Go backward by waypoints and start first point from middle of path
<waypoint_id>_return
Go backward by waypoints from end of points and finish at transition object position
<waypoint_id>_back_only_waypoints
Go backward by waypoints from end of points and finish only at last point
So this is how level.json is works! Here's as example - intro level of the game:
Last updated