DoorButton.ts
script.DoorCutScene.ts
script, which executes the cutscene in the world:
DoorCutScene.ts
is attached. This event triggers the camera dolly and cutscene animation.DoorCutScene.ts
sends an event back to this script, which re-enables the magic green button for replay. start() {
this.connectCodeBlockEvent(this.entity, hz.CodeBlockEvents.OnPlayerEnterTrigger, (player: hz.Player) => {
if (this.props.doorCutscene !== undefined && this.props.doorCutscene !== null) {
this.sendLocalEvent(this.props.doorCutscene, CutsceneEvents.OnStartCutscene, {player, doorButton: this.entity});
this.entity.as(hz.TriggerGizmo).enabled.set(false);
} else {
console.warn("DoorButton pressed, but no doorCutscene was set in the props.")
};
});
this.connectNetworkEvent(this.entity, CutsceneEvents.OnCutsceneComplete, () => {
this.entity.as(hz.TriggerGizmo).enabled.set(true);
});
};
DoorCutScene.ts
, the start()
method contains the sequencing of actions: start() {
this.connectLocalEvent(this.entity, CutsceneEvents.OnStartCutscene, ({player, doorButton}) => {
this.doorButton = doorButton;
// Play the camera animations. You can add / edit / remove for your own camera animations here.
this.playCameraAnimation(player);
// Play environmental animations. You can add / edit / remove for your own environmental animations here.
this.playEnvironmentalAnimation();
this.connectNetworkEvent(player, PlayerCameraEvents.OnCameraResetPressed, () => {
this.quitCameraAnimationForPlayer(player);
});
});
};
Note: Each of the steps of the sequence (camera or environmental animation) is wrapped in a timeout, which ensures that the specific action has a defined duration.
static propsDefinition = {
door: {type: hz.PropTypes.Entity},
cameraStart: {type: hz.PropTypes.Entity},
cameraEnd: {type: hz.PropTypes.Entity},
moveDuration: {type: hz.PropTypes.Number, default: 5},
robot: {type: hz.PropTypes.Entity},
};
Property | Description | Usage |
---|---|---|
door | Reference to the entity that is the door | playEnvironmentAnimation |
cameraStart | Reference to the entity that is used as the point of reference for beginning the camera animation | playCameraAnimation |
cameraEnd | Reference to the entity that is used as the point of reference for end point of the camera animation | playCameraAnimation |
moveDuration | Time in seconds that the action sequence should last | playCameraAnimation and playEnvironmentAnimation |
robot | Reference to the entity that is the NPC to animate | playEnvironmentAnimation |
Tip: Review and modify this function to create camera animations of your own. Make sure that you create the empty reference objects to define the beginning and ending of the camera movement. With a bit of work, you can chain together multiple sequences of camera animation.
DoorCutScene.ts
script:moveDuration: {type: hz.PropTypes.Number, default: 5},
cameraStart: {type: hz.PropTypes.Entity},
cameraEnd: {type: hz.PropTypes.Entity},
static readonly MoveToStartDuration: number = 0.4;
private static readonly MoveToStartEasing: Easing = Easing.Linear;
private static readonly DollyEasing: Easing = Easing.EaseOut;
Tip: To create a pan effect, set the rotation of the starting object and the ending object to point in the same direction.
door: {type: hz.PropTypes.Entity},
moveDuration: {type: hz.PropTypes.Number, default: 5},
robot: {type: hz.PropTypes.Entity},
Tip: You can modify the robot animation to use different emotes. Change the value of the parameter forsetAnimationParameterTrigger()
to experiment. For more information on available emotes, see NPC Scripts.
Tip: You can build even more complex sequences in this location, inserting different NPCs at this location. For more information, see NPCs.