> For the complete documentation index, see [llms.txt](https://docs.decentraland.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.decentraland.org/creator/content-creator-ko/sdk7/interactivity/avatars/modifier-areas.md).

# 아바타 수정 영역

씬의 특정 지역 안에 있는 플레이어에 대해 아바타를 숨기거나, 이름표를 숨기거나, 패스포트를 비활성화합니다

아바타는 씬 사이를 이동할 때 Decentraland 전반에서 일관된 동작과 외형을 유지합니다. 하지만 다음을 추가하면 `AvatarModifierArea` 씬의 특정 영역에 배치하여 플레이어 아바타가 해당 영역에 들어왔을 때의 동작을 바꿀 수 있습니다.

{% hint style="danger" %}
**❗경고**\
씬에서 사용하는 `AvatarModifierAreas` 의 수는 몇 개로 제한하세요. 너무 많이 사용하면 성능에 상당한 영향을 줄 수 있습니다.
{% endhint %}

### 아바타 수정 영역 배치하기

다음 항목이 포함된 엔티티를 추가하세요: `AvatarModifierArea` 이 엔터티에 컴포넌트를 추가하고 위치를 지정하려면 `Transform` 컴포넌트를 사용합니다.

```ts
const entity = engine.addEntity()

AvatarModifierArea.create(entity, {
	area: Vector3.create(4, 3, 4),
	modifiers: [AvatarModifierType.AMT_HIDE_AVATARS],
	excludeIds: []
})

Transform.create(entity, {
	position: Vector3.create(8, 0, 8),
})
```

다음을 제공해야 합니다. `AvatarModifierArea` 컴포넌트를 생성할 때:

* `area`: 수정 영역의 크기
* `modifiers`: 해당 영역에 구현할 수정자를 나열하는 배열입니다. 이 속성은 다음의 값을 사용합니다. `AvatarModifierType` 열거형입니다.

지원되는 수정자는 다음과 같습니다.

* `AvatarModifierType.AMT_HIDE_AVATARS`
* `AvatarModifierType.AMT_DISABLE_PASSPORTS`
* `AvatarModifierType.AMT_HIDE_NAMETAGS`

다음의 모든 효과 `AvatarModifierArea` 자신의 영역 내에서만 적용됩니다. 플레이어는 영역 밖으로 걸어 나가면 원래 상태로 돌아옵니다.

하나의 `AvatarModifierArea` 는 영역 안에 있는 플레이어에게만 영향을 줍니다. 영역에 들어가도 영역 밖에 있는 다른 플레이어가 어떻게 보이는지는 달라지지 않습니다.

AvatarModifierArea의 `AvatarModifierArea` 의 효과는 플레이어마다 로컬에서 계산됩니다. 일부 플레이어에게만 씬에 표시되고 다른 플레이어에게는 표시되지 않는 `AvatarModifierArea` 를 만들 수 있습니다. 예를 들어, 씬의 플레이어 한 명에게만 다른 플레이어를 모두 숨기는 수정 영역이 있는 "마르코 폴로" 게임을 만들 수 있습니다. 로컬 씬 버전에 이 수정 영역이 없는 다른 플레이어들은 서로를 정상적으로 볼 수 있습니다.

영역이 아바타를 숨기는 경우, 로컬 씬 버전에 해당 영역이 없는 플레이어는 숨겨진 것으로 인식하는 아바타를 포함해 모든 아바타를 정상적으로 봅니다. 영역이 있는 플레이어는 영역에 들어가면 자신과 다른 모든 아바타가 영역의 영향을 받는 것으로 인식합니다.

{% hint style="warning" %}
**📔 참고**: 아바타 수정 영역은 다음의 영향을 받습니다. *위치* 및 *회전* 은 호스트 엔터티의 Transform 컴포넌트에서 영향을 받지만, *스케일*.
{% endhint %}

{% hint style="warning" %}
**📔 참고**:  `AvatarModifierArea`컴포넌트는 다음을 통해 가져와야 합니다.

> `import { AvatarModifierArea } from "@dcl/sdk/ecs"`

자세한 내용은 [가져오기](https://docs.decentraland.org/creator/content-creator-ko/sdk7/getting-started/coding-scenes.md#imports) 에서 쉽게 처리하는 방법을 확인하세요.
{% endhint %}

### 아바타 숨기기

플레이어가 `AvatarModifierArea` 중 `AvatarModifierType.AMT_HIDE_AVATARS` 수정자가 적용된 영역에 들어가면 해당 플레이어의 아바타가 렌더링되지 않습니다. 이는 3인칭 시점에서 자신을 볼 때와 다른 플레이어가 영역에 들어올 때 모두 적용됩니다.

```ts
const entity = engine.addEntity()

AvatarModifierArea.create(entity, {
	area: Vector3.create(4, 3, 4),
	modifiers: [AvatarModifierType.AMT_HIDE_AVATARS],
	excludeIds: []
})

Transform.create(entity, {
	position: Vector3.create(8, 0, 8),
})
```

이를 통해 기본 Decentraland 아바타를 씬에 표시하려는 원하는 커스텀 아바타로 바꿀 수 있습니다. 자세한 내용은 [플레이어의 아바타 교체하기](https://docs.decentraland.org/creator/content-creator-ko/sdk7/interactivity/avatars/npc-avatars.md#replace-the-players-avatar)를 참조하세요. 다른 플레이어에게도 커스텀 아바타를 표시하려면 플레이어 위치 동기화를 직접 처리해야 합니다.

### 패스포트 팝업 비활성화

플레이어가 `AvatarModifierArea` 중 `AvatarModifierType.AMT_DISABLE_PASSPORTS` 수정자가 적용된 영역에 들어가면 해당 플레이어를 클릭해도 플레이어 소개, 인벤토리 등을 보여주는 패스포트 UI가 더 이상 열리지 않습니다.

```ts
const entity = engine.addEntity()

AvatarModifierArea.create(entity, {
	area: Vector3.create(4, 3, 4),
	modifiers: [AvatarModifierType.AMT_DISABLE_PASSPORTS],
	excludeIds: []
})

Transform.create(entity, {
	position: Vector3.create(8, 0, 8),
})
```

이는 멀티플레이어 슈팅 게임처럼 실수로 이 UI를 열면 게임 흐름이 방해받을 수 있는 게임에서 특히 유용합니다.

### 이름표 숨기기

플레이어가 `AvatarModifierArea` 중 `AvatarModifierType.AMT_HIDE_NAMETAGS` 수정자가 적용된 영역에 들어가면 플레이어의 이름표는 숨겨지고 아바타 자체는 계속 표시됩니다.

```ts
const entity = engine.addEntity()

AvatarModifierArea.create(entity, {
	area: Vector3.create(4, 3, 4),
	modifiers: [AvatarModifierType.AMT_HIDE_NAMETAGS],
	excludeIds: []
})

Transform.create(entity, {
	position: Vector3.create(8, 0, 8),
})
```

이는 아바타 자체를 숨기지 않고 플레이어 이름표만 감추고 싶은 무대, 프레젠테이션 또는 스크립트로 연출된 장면에서 유용합니다. 예를 들어 공연 중 아바타는 표시하되 떠 있는 이름이 관객의 주의를 분산시키지 않도록 화면을 깔끔하게 유지할 수 있습니다.

`AMT_HIDE_NAMETAGS` 는 [`AvatarNametag`](https://docs.decentraland.org/creator/content-creator-ko/sdk7/interactivity/avatars/avatar-nametags.md) 컴포넌트로 추가한 커스텀 플레이트도 숨깁니다.

{% hint style="info" %}
**💡 팁**: `AMT_HIDE_AVATARS` 는 이미 아바타와 함께 이름표를 숨기므로 `AMT_HIDE_NAMETAGS` 를 추가할 필요가 없습니다 `AMT_HIDE_AVATARS`. 이 수정자는 `AMT_HIDE_NAMETAGS` 아바타를 표시하면서 이름표만 숨기려는 경우에 사용하세요.
{% endhint %}

같은 영역에서 `AMT_HIDE_NAMETAGS` 를 `AMT_DISABLE_PASSPORTS` 와 같은 다른 수정자와 결합할 수 있습니다.

```ts
const entity = engine.addEntity()

AvatarModifierArea.create(entity, {
	area: Vector3.create(4, 3, 4),
	modifiers: [AvatarModifierType.AMT_HIDE_NAMETAGS, AvatarModifierType.AMT_DISABLE_PASSPORTS],
	excludeIds: []
})

Transform.create(entity, {
	position: Vector3.create(8, 0, 8),
})
```

{% hint style="info" %}
**💡 팁**: 이름표는 플레이어의 머리나 몸통이 영역 안에 있을 때만 숨겨집니다. 영역이 너무 낮아 플레이어가 2단 점프로 영역 위로 올라가면 이름표가 잠시 다시 나타납니다. 예상되는 이동 범위를 덮을 수 있을 만큼 영역을 높게 설정하세요.
{% endhint %}

### 아바타 제외하기

수정자 영역의 `excludeIds` 속성에 있는 배열에 플레이어 ID를 추가하면 해당 플레이어들이 수정자 영역의 영향을 받지 않도록 제외할 수 있습니다.

이 예제는 특정 ID를 가진 플레이어의 아바타를 제외하고 영역 내의 모든 아바타를 숨깁니다. 예를 들어 라이브 이벤트에서 무대 위의 이벤트 진행자만 표시하고 무대에 뛰어오르는 다른 플레이어는 모두 숨기는 데 사용할 수 있습니다.

```ts
const entity = engine.addEntity()

AvatarModifierArea.create(entity, {
	area: Vector3.create(4, 3, 4),
	modifiers: [AvatarModifierType.AMT_HIDE_AVATARS],
	excludeIds: ['0xx1...', '0xx2...'],
})

Transform.create(entity, {
	position: Vector3.create(8, 0, 8),
})
```

{% hint style="warning" %}
**📔 참고**: 플레이어 ID는 모두 소문자로 작성해야 합니다. 필요한 경우 `.toLowerCase()` 를 사용하세요.
{% endhint %}

수정자 영역은 각 플레이어의 인스턴스에서 로컬로 실행됩니다. 제외 ID 목록은 플레이어마다 다를 수 있습니다. 아래 예시에서는 각 플레이어가 아바타를 숨기는 수정자에서 자신의 ID를 제외하므로, 각자 자신의 아바타만 볼 수 있습니다.

```ts
import { getPlayer } from '@dcl/sdk/src/players'

export function main() {
	let userData = getPlayer()
	if (!userData) return

	const entity = engine.addEntity()

	AvatarModifierArea.create(entity, {
		area: Vector3.create(16, 5, 16),
		modifiers: [AvatarModifierType.AMT_HIDE_AVATARS],
		excludeIds: [userData.userId],
	})

	Transform.create(entity, {
		position: Vector3.create(8, 0, 8),
	})
}
```

{% hint style="danger" %}
**❗경고**\
제외 ID 목록이 주기적으로 바뀌는 경우(예: 플레이어가 영역에 들어오거나 나가는 상황에 따라 변경되는 경우), 목록의 순서를 유지해야 합니다. 배열에 `.sort()` 를 적용해 전달할 때마다 목록의 순서가 같도록 하세요. 이렇게 하면 목록에서 바뀐 항목만 계산됩니다. 그렇지 않으면 씬 성능에 큰 영향을 줄 수 있습니다.

```ts
AvatarModifierArea.create(entity, {
	area: Vector3.create(16, 5, 16),
	modifiers: [AvatarModifierType.AMT_HIDE_AVATARS],
	excludeIds: myAvatarList.sort(),
})
```

{% endhint %}

### 겹치는 영역과 런타임 변경

각 아바타에는 효과별로 켜기/끄기 플래그가 하나씩 있으며, 서 있는 영역의 개수를 기록하지 않습니다. 모든 영역이 동일한 플래그를 설정하며 마지막으로 설정한 값이 적용됩니다. 이로 인해 다음과 같은 문제가 생길 수 있습니다.

* **한 영역에서 나가면 다른 영역 안에 계속 있어도 아바타가 다시 표시됩니다.** 아바타를 숨기는 작은 영역에서 벗어나면 씬 전체에 적용되는 숨김 영역이 그 위치를 덮고 있어도 아바타가 다시 보입니다.
* **의 `excludeIds` 에 플레이어가 포함된 영역은 진입 시 해당 플레이어의 상태를 "표시"로 설정합니다**. 이는 해당 영역에 지정된 각 효과에 적용되며, 플레이어가 함께 들어가 있는 모든 아바타 숨김 영역의 설정을 덮어씁니다.

아바타 하나당 한 번에 하나의 영역만 적용하는 것이 좋습니다. 영역이 겹친다면 모든 효과의 설정이 서로 일치하도록 하세요.

**수정자를 그 자리에서 제거해도 적용된 효과는 취소되지 않습니다.** 영역의 필드를 변경하면 클라이언트가 현재 지정된 수정자를 다시 적용합니다. 목록에서 제거한 수정자의 효과를 복원하는 기능은 없으므로, `modifiers`를 비우거나 `AMT_HIDE_AVATARS` 를 `AMT_HIDE_NAMETAGS`로 바꾸면 아바타가 계속 숨겨진 상태로 남습니다. 수정자를 그 자리에서 추가하는 것은 정상적으로 작동합니다.

영역의 수정자 구성을 바꾸려면 엔티티를 삭제하고 같은 프레임에 대체 엔티티를 생성하세요.

```ts
import { AvatarModifierArea, AvatarModifierType, engine, Entity, Transform } from '@dcl/sdk/ecs'
import { Vector3 } from '@dcl/sdk/math'

// 수정자를 그 자리에서 편집하지 말고 영역을 교체하세요
function setModifiers(oldArea: Entity, modifiers: AvatarModifierType[]): Entity {
	engine.removeEntity(oldArea) // 이 영역 안의 모든 아바타도 다시 표시됩니다

	const area = engine.addEntity()
	Transform.create(area, { position: Vector3.create(8, 1, 8) })
	AvatarModifierArea.create(area, {
		area: Vector3.create(16, 5, 16),
		modifiers,
		excludeIds: [],
	})
	return area
}
```

### 수정자 영역 디버깅

코드만으로는 수정자 영역이 씬의 어느 부분을 덮는지 정확히 파악하기 어려울 수 있습니다. 시각적 피드백을 활용하면 영역이 올바른 위치에 있는지 확인하는 데 도움이 됩니다.

의 위치를 확인하려면 `AvatarModifierArea` 또는 `CameraModeArea`를 포함하는 엔티티에 `MeshRenderer` 다음과 같은 컴포넌트를 사용하고 `box` 모양으로 설정한 다음, 스케일을 modifier 영역의 `area` 과 같은 크기로 설정합니다.

{% hint style="warning" %}
**📔 참고**: modifier 영역은 transform의 `scale` 속성의 영향을 받지 않으며, 크기는 `area` 속성을 기준으로 합니다.
{% endhint %}

```ts
const entity = engine.addEntity()
const areaSize = Vector3.create(8, 3, 8)

AvatarModifierArea.create(entity, {
	area: areaSize,
	modifiers: [AvatarModifierType.AMT_HIDE_AVATARS],
  	excludeIds: []
})

Transform.create(entity, {
	position: Vector3.create(8, 0, 8),
	scale: areaSize,
})

MeshRenderer.setBox(entity)
Material.setPbrMaterial(entity, {
	albedoColor: Color4.create(0.5, 0.5, 0.5, 0.5),
})
```

modifier 영역의 효과를 활성화하려면 플레이어의 머리나 몸통이 영역 안에 들어가야 합니다. 플레이어의 발만 영역 안에 있으면 효과가 적용되지 않습니다. 점프만으로 플레이어가 쉽게 영역을 벗어날 수 없도록 하세요.

{% hint style="warning" %}
**📔 참고**: 영역 전체가 씬의 경계 안에 들어가야 합니다.
{% endhint %}

{% hint style="info" %}
**💡 팁**: 작동 예시는 [`9,99-modifier-areas`](https://github.com/decentraland/sdk7-test-scenes/tree/main/scenes/9,99-modifier-areas) 테스트 씬을 참조하세요. 이 씬은 `AvatarModifierArea` 와 런타임에 변경되는 `excludeIds`를 결합합니다. 또한 [`10,99-avatar-modifier-hide-nametags`](https://github.com/decentraland/sdk7-test-scenes/tree/main/scenes/10,99-avatar-modifier-hide-nametags)는 `AMT_HIDE_NAMETAGS` modifier만 따로 보여 줍니다.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.decentraland.org/creator/content-creator-ko/sdk7/interactivity/avatars/modifier-areas.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
