

サポート終了通知: 2026 年 5 月 20 日に、 AWS は のサポートを終了します AWS SimSpace Weaver。2026 年 5 月 20 日以降、 SimSpace Weaver コンソールまたは SimSpace Weaver リソースにアクセスできなくなります。詳細については、[AWS SimSpace Weaver 「サポート終了](https://docs.aws.amazon.com/simspaceweaver/latest/userguide/simspaceweaver-end-of-support.html)」を参照してください。

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# エンティティの位置を保存する
<a name="working-with_app-sdk_ent_store-position"></a>

整数データ構造を使用してエンティティの位置を保存 (ステートファブリックへの書き込み) できます。以下の例では、以下の関数を使用します。

```
Result<void> StoreEntityIndexKey(
    Transaction& txn, 
    const Entity& entity, 
    TypeId keyTypeId, 
    std::int8_t* src, 
    std::size_t length)
```

**注記**  
以下の例に示すように、`Api::BuiltinTypeId::Vector3F32` から `Api::StoreEntityIndexKey()` を指定する必要があります。

**Example 配列を使用して位置を表す例**  

```
Result<void> SetEntityPositionByFloatArray(
    Api::Entity& entity, 
    Transaction& transaction)
{
    std::array<float, 3> position = { /* x */ 25, /* y */ 21, /* z */ 0 };
    
    auto* src = reinterpret_cast<std::int8_t*>(position.data());
    std::size_t length = sizeof(position);
    
    WEAVERRUNTIME_TRY(Api::StoreEntityIndexKey(
        transaction,
        entity,
        Api::BuiltinTypeIdToTypeId(Api::BuiltinTypeId::Vector3F32),
        src,
        length));
}
```

**Example struct を使用して位置を表す例**  

```
struct Position 
{
   float x;
   float y;
   float z;
};

Result<void> SetEntityPositionByStruct(
    Api::Entity& entity, 
    Transaction& transaction)
{
    Position position = { /* x */ 25, /* y */ 21, /* z */ 0 };
    
    auto* src = reinterpret_cast<std::int8_t*>(&position);
    std::size_t length = sizeof(position);
    
    WEAVERRUNTIME_TRY(Api::StoreEntityIndexKey(
        transaction,
        entity,
        Api::BuiltinTypeIdToTypeId(Api::BuiltinTypeId::Vector3F32),
        src,
        length));
}
```