Skip to content

Commit d876e21

Browse files
authored
Pointer lock component in camera (#234)
Signed-off-by: Nicolas Earnshaw <[email protected]>
1 parent c3a007d commit d876e21

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

content/creator/sdk7/interactivity/user-data.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -380,19 +380,19 @@ Players can switch between two cursor modes: _locked cursor_ mode to control the
380380

381381
Players unlock the cursor by clicking the _Right mouse button_ or pressing the _Esc_ key, and lock the cursor back by clicking anywhere in the screen.
382382

383-
Check the `PointerLock` component of the scene's root entity to find out what the current cursor mode is.
383+
Check the `PointerLock` component of the scene's [camera entity]({{< ref "/content/creator/sdk7/architecture/entities-components.md#reserved-entities" >}}) to find out what the current cursor mode is.
384384

385385
```ts
386386
executeTask(async () => {
387-
const isLocked = PointerLock.get(engine.RootEntity).isPointerLocked
387+
const isLocked = PointerLock.get(engine.CameraEntity).isPointerLocked
388388
console.log(isLocked)
389389
})
390390
```
391391

392-
The `PointerLock` component of the `engine.RootEntity` is read-only, you can't force the player to lock or unlock the cursor.
392+
The `PointerLock` component of the `engine.CameraEntity` is read-only, you can't force the player to lock or unlock the cursor.
393393

394394
{{< hint warning >}}
395-
**📔 Note**: Avoid referring to the `engine.RootEntity` on the initial scene loading, because that can result in errors if the entity is not initialized yet. To avoid this problem, encapsulate the behavior in an async [`executeTask` block]({{< ref "/content/creator/sdk7/programming-patterns/async-functions.md#the-executetask-function" >}}).
395+
**📔 Note**: Avoid referring to the `engine.CameraEntity` on the initial scene loading, because that can result in errors if the entity is not initialized yet. To avoid this problem, encapsulate the behavior in an async [`executeTask` block]({{< ref "/content/creator/sdk7/programming-patterns/async-functions.md#the-executetask-function" >}}).
396396

397397
If you refer to this entity in a system, it will always be available, because the first execution of the system is called once the scene is already properly initialized.
398398
{{< /hint >}}

0 commit comments

Comments
 (0)