Forum Discussion

Shards632's avatar
Shards632
MHCP Mentor
5 months ago

v227 typescript updates

- `World.findEntity()` and `World.findEntities()` are new ways to find Entities by _name_ rather than by tag
  - the `findEntity()` api expects to find _ONE_ exact match in the whole scene for the provided `name`.  If there are multiple matches, it returns _nothing_ (i.e. `undefined`).
  - the `findEntities()` api supports more complex name searching, such as
    - setting a `rootEntity` to start the search at some sub-tree of the hierarchy, and only search the children of that root entity rather than the _entire_ scene graph
    - setting a `matchOperation` that controls whether to do an `Exact`, `StartsWith`, `EndsWith`, `Contains`, or `Regex` match using the provided `name` argument provided.
      - regular expressions are an advanced topic, and sort of complex 'mini programs' for searching for a matching string
  - note that these are _expensive_ operations (like `World.getEntitiesWithTag()`), so best to run them on start or right after spawning an asset or something. **NOT** every frame.
- the `NPCError` type and the `NpcErrorCategory.AiNotAvailableError` were removed from the api.  The `NpcEvents.OnNpcError` event type still exists, tho.
- when creating an avatar image using `Social.getAvatarImageSource()`, you can now set `skuOverrides` in the `IAvatarImageOptions` to have the rendered avatar wearing particular clothes.
- minor documentation update in `horizon/social` api to show that there is no `this.world.social`, it's actually a global singleton only available to local scripts called `Social` (e.g. like `LocalCamera`)

Replies have been turned off for this discussion