Category | Type | Summary |
---|---|---|
Major | Changed the module names as follows: - Changed the prefix for module names from @early_access_api to horizon .- Changed the module name for the core APIs from v1 to core . | |
Major | - Reduced the amount of boilerplate code required to create components in scripts. - Added a prestart method to the Component class. | |
Entity and Asset properties | Major | - Enabled nullability for properties that receive Entity or Asset types. |
Entity.as | Standard | - Updated the Entity.as method to return a nullable type. |
PhysicalEntity | Standard | - The PhysicalEntity.applyForceAtPosition method now uses the impulse PhysicsForceMode instead of force. |
Class IDs | Standard | - Changed all internal class IDs to the bigint type. |
SpawnTargetState | Standard | - Removed the export of the SpawnTargetState enum. |
Standard | - In the LocalEvent constructor, the name parameter is now optional, and is assigned a unique ID if the parameter isn’t specified. | |
Renamed APIs | - sendNetworkEntityEvent to sendNetworkEvent - sendEntityEvent to sendLocalEvent - connectEntityEvent to connectLocalEvent - connectBroadcastEvent to connectLocalBroadcastEvent - sendBroadcastEvent to sendLocalBroadcastEvent | |
Interfaces | Renamed APIs | - IEntityStyle to EntityStyle |
Classes | Removed APIs | - HorizonEvent to LocalEvent |
Entity class | Removed APIs | - setVisibleToAllPlayers to setVisibilityForPlayers - setVisibleToPlayers to resetVisibilityForPlayers |
@early_access_api
prefix changed to horizon
.v1
to core
.import * as hz from “@early_access_api/v1”;
import * as hz from “horizon/core”;
import * as hz from “@early_access_api/navmesh”;
import * as hz from “horizon/navmesh”;
type TestProps = {
num: number;
numDefaulted: number
};
class TestClass extends Component<TestProps> {
static propsDefinition = {
num: {type: 'number'},
numDefaulted: {type: 'number', default: 0},
};
start(): void {
const n: number \| undefined = this.props.num;
const numDefaulted: number \| undefined = this.props.numDefaulted;
}
}
class TestClass extends Component<typeof TestClass> {
static propsDefinition = {
num: {type: 'number'},
numDefaulted: {type: 'number', default: 10},
entity: {type: PropTypes.Entity}
};
start(): void {
const n: number = this.props.num;
const entity: Entity \| undefined = this.props.entity;
}
}
Component
class by extending Component
, you can do the following:class Foo<T> extends Component<typeof Foo & T> {
...
}
class Bar extends Foo<typeof Bar>
static propsDefinition = {
...Foo.propsDefinition,
// new props
}
Component
class now has a prestart
method, which you can use to set up components before start
is called on any components in the world. For example, you might want to do this when setting up event listeners.Entity
or Asset
types now have nullability enabled. As a result, you must check if they are null before using them in your code. Previously this was often accomplished by calling Entity.exists()
. Now you can check for null values by doing the following: start(): void {
const exampleEntity: Entity \| undefined = this.props.entityProp;
const exampleAsset: Asset \| undefined = this.props.assetProp;
if (exampleEntity != null) {
// Use as before
}
}
Entity.as
method now returns a nullable type.PhysicalEntity.applyForceAtPosition
method now uses the impulse PhysicsForceMode
instead of force.bigint
type, which allows scripts to serialize entities across the network.SpawnTargetState
enum has been removed.LocalEvent
constructor, the name
parameter is now optional, and is assigned a unique ID if the parameter isn’t specified.RaycastHit
response type. You now must check .targetType
before accessing .target
.const hit = this._raycaster.raycast(
this._raycaster.position.get(),
this._raycaster.forward.get(),
{
layerType: hz.LayerType.Objects,
maxDistance: this.props.maxGrabDistance
});
if (hit && hit.targetType == hz.RaycastTargetType.Entity) {
const entity = hit.target;
entity.color.set(hz.Color.green)
// do something
}
Section | Old | New |
---|---|---|
Component class | sendNetworkEntityEvent | sendNetworkEvent |
sendEntityEvent | sendLocalEvent | |
connectEntityEvent | connectLocalEvent | |
connectBroadcastEvent | connectLocalBroadcastEvent | |
sendBroadcastEvent | sendLocalBroadcastEvent | |
connectNetworkEntityEvent | connectNetworkEvent | |
Interfaces | IEntityStyle | EntityStyle |
Section | Removed | Alternative | Notes |
---|---|---|---|
Classes | LocalEvent | We now support local and network TypeScript events. The use of HorizonEvent and NetworkEvent together caused confusion. | |
Entity class | setVisibleToAllPlayers | setVisibilityForPlayers | The new API is more inline with expected user behavior. |
Entity class | setVisibleToPlayers | resetVisibilityForPlayers | The new API is more inline with expected user behavior. |