Working with AI

Authoring scenes with AI

Have a language model write whole .tgscene levels, then import them into the editor.

A .tgscene file is short, regular text, which makes it ideal to generate. The loop is:

  1. Give the model the format and your asset UUIDs (the prompt library has a ready-made system prompt).
  2. Describe the level.
  3. Save its answer as Something.tgscene and import it, or let an agent call tgImport.importFiles.
  4. Open it, look, and ask for changes.

What the model must know

  • The structure: configs:, update:, input:, render:, entities:. Entity lines are indented with tabs; component lines with two tabs. Full reference.
  • The system lists: a first-person 3D scene needs at least
tgscene
update:
	-MoveByVelocity
	-DistanceToPlayerSquare
	-ScriptRun
	-WorldMatrix
input:
	-FreeLookCamera
render:
	-ViewMatrix
	-ShadowRendering
	-SortedSubmissionRendering
	-SkyboxRendering
  • One player camera: -PerspectiveCamera:60, -Position, -Rotation:0, -Rotation2D:0,0, -PlayerTag, -PlayerInputTag.
  • One sun: -DirectionalLight:x,y,z + -LightColor:1.
  • Geometry: -Primitive:Cube,sx,sy,sz (also Sphere, Cylinder, Capsule, Wedge, Quad), with -Position, -Rotation:0, -Scale:1.
  • Materials: -Material:EAF81A2663BA92E,<textureUuid>[,r,g,b[,a]]. EAF81A2663BA92E is the built-in lit, textured shader. The texture UUID must exist in your project. Give the model your list (Project panel: right-click a texture, then Copy UUID), or use the four from the tutorial pack.
  • Entity names must be unique, and can't contain : , # or start with -.

Example request

Checking the result

  • If the file was refused on import, read the refused reason.
  • If something is missing in the Hierarchy, its line had a typo. The Console logs each unknown component name or wrong value count, once.
  • If a surface is white, its texture UUID doesn't exist in this project (or the texture is still decoding: File > Reload Current Scene).

Editing an existing scene

To give the model your current level, have an agent save it (tgDebug.sceneSave()). For small changes, it's often easier to let a browser agent edit the live scene with tgDebug instead of rewriting the file.