Give Page Feedback | API

World Shifters - Overview

Whenever the Origin Cell of the World changes, all World Cells belonging to the World need to be re-oriented. This can be done by duplicating all World Cells (and their Asset Chunks), however that operation is very expensive, especially in regards to memory usage.

Usually, a better option is to simply shift all of the World's Asset Chunks. The World Shifter is the class responsible for carrying out this shift.

Default World Shifters

There is only one default World Shifter included with the Streamable Assets Manager, the Standard Hierarchy World Shifter, which is intended to be used with a Standard Hierarchy Organizer.

This shifter allows you to specify what exactly from the hierarchy is shifted.

Custom World Shifters

A Custom World Shifter can be created for custom Hierarchy Organizers or situations where you are not using a Hierarchy Organizer. It can also be used with the Standard Hierarchy Organizer if you are not satisfied with how the Standard Hierarchy World Shifter functions.

Shifter Events

All World Shifters have a few UnityEvents that can be subscribed to (either via the inspector or via scripting) in order to receive notification at different points in the shifting process. These include:

World Shifting - Fired just before a World Shift starts.

World Shifted - Fired just after a World Shift completes.

Transform Shifting - Fired just before a Transform is shifted during the World Shift.

Transform Shifted - Fired just after a Transform is shifted during the World Shift.

Single Frame Shifting

Normally the World Shift occurs over multiple frames in order to lower the impact on performance. However, every World Shifter contains a Perform Shift In Single Frame option that when enabled, forces the shift to be performed in a single frame.

While this will likely result in a drop in performance, it has the added benefit that the shift will be less likely to be noticed by the Player, since everything (including the Player) will be shifted in the same frame.

Using World Shifters With Multiple Worlds

World Shifters can and usually should be setup to work with multiple Worlds, however if you anticipate multiple Worlds needing to be shifted at the same time, you should use separate World Shifters for each. In order to support their use with multiple Worlds, the current World to be shifted is set prior to the World Shifter's ShiftWorld method being called, which you can query using the CurrentWorldToBeShifted property.

The amount of the current shift is also set for each call to ShiftWorld and can be queried using the CurrentShiftAmount property.

Moving Players

Choosing how to move Player objects when a World's origin cell is changed can be a difficult decision.

The Active Grid class includes built in support for moving players, however there is usually a slight delay between the change (and resulting shift/world duplication) and the Active Grid receiving notification that a shift/duplication has occurred. As such, the Players may not be moved in a timely fashion, which means the user might be more likely to notice that something fishy is going on.

Performing the moves in the World Shifter is generally a better idea, as the movement can be better timed to occur closer to when the World Shift actually occurs.

This is especially true when using a Custom World Shifter, as you can time the Player movement perfectly to occur when the objects immediately surrounding the Player are moved (though this will take some advanced coding to pull off).