Diese Seite ist noch nicht auf Deutsch übersetzt und wird daher auf Englisch angezeigt.
Wechsel von einer anderen EngineComing from Godot
A map from Godot 4's scenes, nodes, resources, signals, input map, physics and export to this layer, with the page that covers each one.
The biggest change is where a game lives. In Godot you assemble scenes in the editor and attach GDScript to nodes; here a game is Go code inside an NSGo component, and its scenes, prefabs and settings are YAML text files that you write by hand or save from the editor. Godot's habit of keeping scenes and resources as text (.tscn, .tres) carries over: every file you write is text you can read and diff in review.
At a glance
| Godot | Here | Guide |
|---|---|---|
_physics_process(delta), physics ticks per second |
game.Loop.Update(dt) with a fixed dt, Loop.Rate |
Loop |
_process(delta) |
game.Loop.Draw(alpha) and the core.Canvas it redraws |
Loop |
.tscn scene, PackedScene |
YAML scene document (sceneformat) built into layers |
Editor & Scene Format |
get_tree().change_scene_to_file() |
scene.Manager.Switch with a transition |
scene |
Node2D tree, CanvasLayer |
scene.Scene layers in world or screen space |
scene |
Node3D tree, groups |
scene3d.Node tree, FindByTag |
scene3d |
| Instantiating a scene as a template | entities.Prefab, or a scene object's prefab field |
Entities |
Resource, .tres, ResourceLoader |
YAML resource files in a resource.Library; images and sounds under resources/; data through assets.Manager with WithFS |
resource, assets |
Signals, connect, emit |
flow.Bus with Subscribe and Publish; core.Signal for UI state |
flow |
[connection] in a .tscn |
A scene file's connections, run by sceneformat.Connect and Signals.Emit, or deferred, as CONNECT_DEFERRED does, with Signals.Enqueue and Flush; SpawnConnected binds them to entities |
Editor & Scene Format |
Timer node, await on a signal |
flow.Timers, flow.Seq and flow.Wait |
flow |
Tween |
tween.Tween, tween.Timeline |
tween |
Input Map, Input.is_action_just_pressed |
input.Actions, JustPressed |
input |
CharacterBody2D.move_and_slide() |
World.MoveAndSlide / MoveAndSlideWith against bodies, shapes, tiles and static rigid bodies (physics.MoveAndSlide for tiles alone; platformer.Controller.StepWorld for platformers) |
physics, platformer |
RigidBody2D, joints |
physics.RigidWorld, RigidBody, joints |
2D Rigid Bodies |
CharacterBody3D, RigidBody3D |
physics3d.CharacterController, physics3d.World |
physics3d |
| Export presets, export templates | nsgo.yaml and go tool nsgo build |
Building and Shipping |
Scenes
A Godot scene is a saved node tree you instance or switch to. Here the two jobs are split:
- What a scene contains is a YAML document with
version: 1: a camera, tilemaps and ordered layers of placed objects, each with a transform, a sprite and free-formcomponentsandproperties(the role of exported variables).sceneformat.Parsereads it and refuses unknown fields;sceneformat.Buildturns it into layers ready to draw. See Editor & Scene Format. - Which scene runs is
scene.Manager, which holds a stack ofscene.Controllervalues.Switchreplaces the current scene with aFade,CrossfadeorWipetransition,Pushlays a pause menu over it andPopreturns. See scene.
Controller.Enter receives a child *core.Scope of its own. Loops, timers, sounds and signals made on it are disposed when the scene exits, which covers what _ready, _exit_tree and queue_free do for a scene's own objects.
An autoload has no special form: make the value once in the root component and pass it to the scenes that need it.
Nodes
There is no single node class that everything inherits from. Pick the piece that fits:
- 2D drawing: a
scene.Sceneholds layers; a layer inSpaceWorlddraws under the scene's camera (likeNode2Dunder aCamera2D) and a layer inSpaceScreendraws in view space (like aCanvasLayer). Layers hold tilemaps, sprite batches andscene.Drawablevalues with their ownDraw,Updateand hit-test hooks. See scene, sprite and tilemap. - 3D hierarchy:
scene3d.Nodehas a parent, children, a local transform, tags (Godot's groups, found withFindByTag), named sockets for attachments and typed values set withSetAttachment. See scene3d. - Game objects with behaviour: instead of a script per node, keep data in components on an
entities.Worldand write systems that run in a declared order each fixed step.Prefabstamps the same components onto new entities, as instancing a small scene does. See Entities. - HUD and menus: Godot's
Controlnodes become ordinary NSGo views layered over the canvas, or gameui widgets drawn inside it.
2D coordinates match Godot's: X right, Y down, rotation clockwise in radians. 3D matches too: right-handed, Y up, -Z forward, one unit a metre (see math3d and 3D Models from Blender).
Resources
Godot's .tres resources map to resource files: one YAML document each, with a type and version header, for materials, curves, gradients, animation clips, UI themes, sound bus layouts and physics materials. A resource.Library loads them from an fs.FS by path and keeps one value per path, as ResourceLoader caches a loaded resource.
Images and sounds the game loads at runtime go in resources/ and are opened by "asset:<path>" URIs, such as core.Src("asset:hero.png"), on every target. Data that assets.Manager reads itself, such as atlas JSON, raw bytes and your own parsed files, comes from the file system you give it: embed it with //go:embed and pass assets.NewManager(cx, assets.WithFS(fsys)), or pass WithReadAsset for custom storage. Without either, the manager reads an assets/ directory relative to the working directory, which works only for desktop runs from the project root. assets.Manager loads atlases, sounds, images, bytes and your own parsed files in named groups off the engine goroutine, reports progress as signals for a loading screen and releases a group when its scene ends. See assets.
Files are read in the form the tool that made them writes, with no import step between them and the game, except where game assets builds them: it packs atlases, encodes KTX2 textures, converts sounds, bakes fonts into bitmap fonts and packs glTF models into GLB files, and the .import files map to its import settings sidecars, YAML files such as hero.png.import.yaml beside each image, sound, font or model that hold its compression, filter, sprite sheet slicing, loop points, font size and characters, or model scale (Command Line). Files the game reads as they are include TexturePacker and Aseprite atlases (sprite), Tiled maps (tilemap) and glTF models (3D Models from Blender). For your own Resource subclasses, write a YAML or JSON file and decode it into a Go struct, refusing unknown fields as the scene format does.
Saved games take the place of ConfigFile and FileAccess writes: save keeps versioned JSON slots with migrations and a backup.
Signals
Godot's signals do two jobs here, each with its own tool:
- Gameplay events between systems go through a typed
flow.Bus. A struct type is the signal;flow.Subscribeconnects,flow.Publishemits at once,flow.EnqueuewithBus.Flushemits later (Godot's deferred connection) andflow.SubscribeOnceis a one-shot connection. Nothing is keyed by a string, so a misspelt event does not compile. See flow. - State a view shows, such as a score in the HUD, is a
core.Signal. A view that reads it re-renders when it changes, without a handler wired by hand.
Waiting with await becomes a step sequence: flow.Seq(flow.Wait(d), flow.Do(fn)) run by a flow.Runner each fixed step, with no goroutines. The Timer node becomes flow.Timers.After and Every. Area callbacks such as body_entered are covered under physics below.
Input map
Godot's Input Map becomes an input.Actions value: bind names to inputs, call Step once at the start of each fixed update and ask about that step.
| Godot | Here |
|---|---|
| Adding an action in Project Settings | actions.Bind("jump", input.TouchRegion(rect), input.MouseButton(core.MouseButtonLeft)) |
Input.is_action_pressed("jump") |
actions.Pressed("jump") |
Input.is_action_just_pressed("jump") |
actions.JustPressed("jump") |
Input.is_action_just_released("jump") |
actions.JustReleased("jump") |
Input.get_axis("left", "right") |
actions.BindAxis("move_x", "left", "right"), then actions.Axis("move_x") |
TouchScreenButton |
input.TouchRegion, or a VirtualPad of on-screen sticks and buttons |
| Saving remapped controls | actions.Save and actions.Load in core.Storage |
Bindings today are touch regions, mouse buttons and device motion. Key and gamepad bindings are tracked in #3; until they land, a key bound with NSGo's cx.OnKey can call actions.Trigger("pause"), which registers the action for one step. See input.
Physics
The 2D physics package works in the same screen space as the drawing and steps on the loop's fixed dt.
CharacterBody2D:World.MoveAndSlide(body, dt)andWorld.MoveAndSlideWith(body, dt, opts)sweep aBody's shape against static and kinematic bodies (includingBody.OneWayplatforms), solid and one-way tiles, and staticRigidBodycolliders, sliding along non-axis-aligned normals and returningCollisionsplusOnFloor,OnWallandOnCeilingwith configurableUpX/UpY,FloorMaxAngleandMotionFloating(top-down) mode — matching Godot'smove_and_slide(),is_on_floor(),get_slide_collision(),up_directionandmotion_mode.physics.MoveAndSlide(body, grid, dt)remains available for tile-only movement, andCharacterBody.MoveWorld/platformer.Controller.StepWorldadd slopes and moving platforms. See physics and platformer.Area2D: aphysics.Triggeradded withWorld.AddTriggercallsOnEnter,OnStayandOnExitfromWorld.StepTriggers, asbody_enteredandbody_exiteddo.RayCast2Dandintersect_ray:World.RaycastFirstandWorld.Raycast;World.QueryOverlapandQueryPointcover shape and point queries.- Collision layers and masks: the
LayerandMaskfields (LayerMask) on bodies and triggers. RigidBody2Dand joints:physics.RigidWorldwithRigidBodyboxes and circles;RevoluteJointis aPinJoint2D,SpringJointaDampedSpringJoint2DandDistanceJointa fixed rod. See 2D Rigid Bodies.- 3D:
physics3d.CharacterControllerwalks a capsule over slopes and stairs asCharacterBody3Ddoes, andphysics3d.Worldsteps rigid boxes, spheres and capsules. See physics3d.
2D shapes are boxes and circles; there are no concave polygon colliders in 2D. In 3D, bodies are boxes, spheres and capsules, and static level geometry can collide as a triangle mesh or a heightfield: ConcavePolygonShape3D maps to physics3d.TriMeshCollider added with World.AddTriMesh, and HeightMapShape3D to physics3d.HeightfieldCollider added with World.AddHeightfield.
Export
Export presets become nsgo.yaml at the project root: the app's name, identifier, version, icons and the targets to build. There are no export templates to download, because Go cross-compiles; only iOS and signed macOS builds need a Mac with Xcode.
| Godot | Here |
|---|---|
| Running the project from the editor | go tool nsgo dev, with -target web, ios_simulator or android |
export_presets.cfg |
nsgo.yaml (build.targets, icon, id, version) |
godot --export-release |
go tool nsgo build |
| Export for a store | go tool nsgo build -channel store |
go tool nsgo check -target all vets the game for every target before a release. See Building and Shipping, and Getting Started for a first project.