@@ -25,7 +25,7 @@ Entities are usually added from the editor's right-click menu:
2525
2626``` ts
2727// Spawn an Empty into the shared world root
28- const pivot = game .world .spawn ({
28+ const pivot = this . game .world .spawn ({
2929 name: " Pivot" ,
3030 type: Empty ,
3131 transform: { position: { x: 4 , y: 1 } },
@@ -37,9 +37,9 @@ const pivot = game.world.spawn({
3737``` ts
3838// “Crate” lives under prefabs/
3939// cloneInto returns the new instance
40- const crate = game .prefabs ._ .Crate .cloneInto (game .world , {
40+ const crate = this . game .prefabs ._ .Crate .cloneInto (this . game .world , {
4141 name: " Crate." + crypto .randomUUID (),
42- authority: game .network .self , // I control this crate
42+ authority: this . game .network .self , // I control this crate
4343});
4444crate .pos .set (2 , 0 );
4545```
@@ -64,15 +64,15 @@ crate.pos.set(2, 0);
6464` root._.<Name> ` gives you a quick reference to any ** direct child** under a root:
6565
6666``` ts
67- const cam = game .local ._ .Camera ; // generic Entity
67+ const cam = this . game .local ._ .Camera ; // generic Entity
6868```
6969
7070The proxy returns an ** untyped** ` Entity ` , so if you want type-specific methods
7171(e.g. ` Camera.zoom ` ), cast it:
7272
7373``` ts
7474// get the local camera with full IntelliSense
75- const cam = game .local ._ .Camera .cast (Camera );
75+ const cam = this . game .local ._ .Camera .cast (Camera );
7676
7777cam .zoom = 2 ; // Camera-only API
7878```
@@ -81,10 +81,18 @@ Dot-path chains work for grandchildren too:
8181
8282``` ts
8383// Prefab » Player » Health
84- const health = game .prefabs ._ .Player ._ .Health .cast (RichText );
84+ const health = this . game .prefabs ._ .Player ._ .Health .cast (RichText );
8585health .text = " HP: 100" ;
8686```
8787
88+ Names with spaces or symbols-
89+ If the entity's name isn't a valid JavaScript identifier (contains spaces, hyphens, etc.)
90+ use bracket access:
91+ ``` ts
92+ // Entity is literally named “My Entity”
93+ const ent = this .game .world ._ [" My Entity" ];
94+ ```
95+
8896> The lookup throws if the child name is wrong, so check your spelling against the scene graph panel.
8997
9098---
0 commit comments