diff --git a/content/creator/scene-editor/smart-items/combine-with-code.md b/content/creator/scene-editor/smart-items/combine-with-code.md index c38b6a4a..b614cd1d 100644 --- a/content/creator/scene-editor/smart-items/combine-with-code.md +++ b/content/creator/scene-editor/smart-items/combine-with-code.md @@ -33,6 +33,10 @@ Add your custom code in the `index.ts` file under `/src`, inside the `main()` fu If you have a preview window open running your scene, whenever you change the code in your files and save, the scene reloads automatically with your changes. +{{< hint warning >}} +**📔 Note**: If you have VS Code installed but the **CODE** button doesn't open it, it may be that VS Code is not properly configured on your machine to open via the command line. In most cases, this is care of as part of the default installation, but in case it's not, see [these instructions from VS](https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line) to enable VS Code from the command line. +{{< /hint >}} + ## Reference an item When using the Scene Editor and adding entities by dragging them into the canvas, each entity has a unique name. Use the `engine.getEntityOrNullByName()` function to reference one of these entities from your code. Pass the entity's name as a string, as written on the scene's entity tree view in the Scene Editor. diff --git a/content/creator/scene-editor/smart-items/play-videos.md b/content/creator/scene-editor/smart-items/play-videos.md index 8dd90cf5..f7138b30 100644 --- a/content/creator/scene-editor/smart-items/play-videos.md +++ b/content/creator/scene-editor/smart-items/play-videos.md @@ -31,7 +31,11 @@ You can configure the volume of the video's sounds. Note that the audio from the You can also configure the video to either loop or play once. {{< hint warning >}} -**📔 Note**: Avoid playing more than one video at any given time in your scene, because it can severely impact performance for players. Always stop other videos before playing a second video. +**📔 Note**: If too many videos are playing at the same time in your scene, some will be paused by the engine. The priority is determined based on proximity to the player, direction of the camera and size of the screen. The maximum amount of simultaneous videos depends on the player's quality settings. + +- Low: 1 +- Medium: 5 +- High: 10 We also recommend starting to play the video when the player is near or performs an action to do that. Starting to play a video when your scene is loaded far in the horizon will unnecessarily affect performance while players visit neighboring scenes. {{< /hint >}} diff --git a/content/creator/sdk7/interactivity/npc-avatars.md b/content/creator/sdk7/interactivity/npc-avatars.md index ac6b6207..9dce7865 100644 --- a/content/creator/sdk7/interactivity/npc-avatars.md +++ b/content/creator/sdk7/interactivity/npc-avatars.md @@ -80,26 +80,26 @@ Transform.create(myAvatar, { ## Copy wearables from player -The following snippet creates an NPC avatar that uses the same wearables that the player currently has on. This could be used in a scene as a manequin, to show off a particular wearable or emote combined with the player's current outfit. +The following snippet changes the wearables and other characteristics of an NPC avatar to match those that the player currently has on. This could be used in a scene as a manequin, to show off a particular wearable or emote combined with the player's current outfit. ```ts import { getPlayer } from '@dcl/sdk/src/players' -export function main() { - let userData = getPlayer() - console.log(userData) - if (!userData || !userData.wearables) return +export function swapAvatar(avatar: Entity) { - const myAvatar = engine.addEntity() - AvatarShape.create(myAvatar, { - id: 'Manequin', - emotes: [], - wearables: userData.wearables, - }) + let userData = getPlayer() + console.log(userData) - Transform.create(myAvatar, { - position: Vector3.create(4, 0.25, 5), - }) + if (!userData || !userData.wearables) return + + const mutableAvatar = AvatarShape.getMutable(avatar) + + mutableAvatar.wearables = userData.wearables + mutableAvatar.bodyShape = userData.avatar?.bodyShapeUrn + mutableAvatar.eyeColor = userData.avatar?.eyesColor + mutableAvatar.skinColor = userData.avatar?.skinColor + mutableAvatar.hairColor = userData.avatar?.hairColor + } ``` diff --git a/content/creator/sdk7/media/video-playing.md b/content/creator/sdk7/media/video-playing.md index e0cef3b6..26a2cd72 100644 --- a/content/creator/sdk7/media/video-playing.md +++ b/content/creator/sdk7/media/video-playing.md @@ -25,11 +25,21 @@ In all cases, you'll need: - A [material]({{< ref "/content/creator/sdk7/3d-essentials/materials.md" >}}) with a A `VideoTexture` assigned to its texture - A `VideoPlayer` component to control the state of the video. -{{< hint warning >}} -**📔 Note**: Keep in mind that streaming video demands a significant effort from the player's machine. For this reason, we recommend never having more than one video stream displayed at a time per scene. Videos are also not played if the player is standing on a different scene. Also avoid streaming videos that are in very high resolution, don't use anything above _HD_. +## Performance considerations -It's also ideal to play videos on Basic (unlit) materials, to reduce the performance load. -{{< /hint >}} +Keep in mind that streaming video demands a significant effort from the player's machine. It's recommended to avoid playing more than one video at a time. + +If too many videos are playing at the same time in your scene, some will be paused by the engine. The priority is determined based on proximity to the player, direction of the camera and size of the screen. The maximum amount of simultaneous videos depends on the player's quality settings. + +- Low: 1 +- Medium: 5 +- High: 10 + +We also recommend starting to play the video when the player is near or performs an action to do that. Starting to play a video when your scene is loaded far in the horizon will unnecessarily affect performance while players visit neighboring scenes. + +Also avoid streaming videos that are in very high resolution, don't use anything above _HD_. + +It's also ideal to play videos on Basic (unlit) materials, to reduce the performance load, as is the case on all of the example snippets below. ## Show a video @@ -149,7 +159,7 @@ Material.setBasicMaterial(screen, { }) ``` -If you instead want to project a video onto a PBR material, keep in mind that the default properties make the video look rather opaque. You can enhance that by altering other properties of the material. Here are some recommended settings for the video to stand out more: +It's usually recommended to play videos on Basic unlit materials, as this is better for performance, but if you instead want to project a video onto a PBR material, keep in mind that the default properties make the video look rather opaque. You can enhance that by altering other properties of the material. Here are some recommended settings for the video to stand out more: ```ts Material.setPbrMaterial(screen, { diff --git a/content/player/_index.md b/content/player/_index.md index 4c0421e4..eba7b62d 100644 --- a/content/player/_index.md +++ b/content/player/_index.md @@ -75,7 +75,7 @@ url: /player
Find help about the various topics in each of these sections