Loading...
Loading...
Set up a Godot 4.x 3D scene: Node3D transforms, Camera3D, lighting (DirectionalLight3D/OmniLight3D), WorldEnvironment for sky/ambient/tonemap/post, MeshInstance3D materials, and GridMap for tile-based 3D levels. Use when building a 3D scene in a Godot project, placing cameras/lights, configuring environment and post-processing, or working with Node3D/.tscn 3D content and GridMap.
npx skill4agent add gamedev-skills/awesome-gamedev-agent-skills godot-3d-essentialsGridMapCamera3DWorldEnvironmentGridMapgodot-shadersgodot-physicsgodot-animationfps-shooterNode3DTransform3Dglobal_positionrotate_y(angle)look_at(target)Camera3Dcurrentmake_current()fovnearfarDirectionalLight3DOmniLight3DSpotLight3DWorldEnvironmentEnvironmentStandardMaterial3DShaderMaterialMeshInstance3DGridMapMeshLibraryextends Camera3D
@export var target: Node3D
@export var offset := Vector3(0, 4, 8)
@export var smooth := 6.0
func _physics_process(delta: float) -> void:
if target == null:
return
var desired := target.global_position + offset
global_position = global_position.lerp(desired, smooth * delta) # smooth follow
look_at(target.global_position, Vector3.UP) # face the targetfunc _ready() -> void:
var sun := DirectionalLight3D.new()
sun.rotation_degrees = Vector3(-45, -30, 0)
sun.shadow_enabled = true
add_child(sun)
var we := WorldEnvironment.new()
var env := Environment.new()
env.background_mode = Environment.BG_SKY
env.sky = Sky.new()
env.sky.sky_material = ProceduralSkyMaterial.new()
env.ambient_light_source = Environment.AMBIENT_SOURCE_SKY
env.tonemap_mode = Environment.TONE_MAPPER_FILMIC
env.glow_enabled = true
we.environment = env
add_child(we)func tint_mesh(mesh: MeshInstance3D, color: Color) -> void:
var mat := StandardMaterial3D.new()
mat.albedo_color = color
mat.metallic = 0.0
mat.roughness = 0.6
mat.emission_enabled = true
mat.emission = color * 0.3
mesh.material_override = mat # overrides the mesh's surface materials@onready var grid: GridMap = $GridMap # cell_size + mesh_library set in the editor
func build_floor(width: int, depth: int, item_id: int) -> void:
for x in width:
for z in depth:
# set_cell_item(Vector3i cell, int item, orientation = 0)
grid.set_cell_item(Vector3i(x, 0, z), item_id)DirectionalLight3DWorldEnvironmentCamera3Dcurrentcurrent = truemake_current()positionrotationglobal_positionglobal_transformlook_atscaleNode3Dfromuplook_atlook_at(target, up)upMeshLibraryMeshLibraryset_cell_item(cell, -1)tonemap_modeMeshLibraryReflectionProbeLightmapGIreferences/scene-and-environment.mdgodot-physicsgodot-shadersgodot-animationAnimationTreecamera-systemsperformance-optimizationfps-shooter