Resizing
Last updated
Was this helpful?
Last updated
Was this helpful?
We have an example BPMC_M2Example_ResizingComponent
, which demonstrates how to resize the character in a way that translates to the animated crowd
Players in LOD0 or the crowd will be able to visually change size
Players in the rendering LOD 0 will smoothly change size to their target size
Players in the crowd will instead snap to their target size.
The ScaleFactor
variable is a background replicated variable, so is synced to all players, even those far away.
This resizing implementation is not intended for, and should not be used at high frequency in large scale events.
Since the scale factor in this example is replicated on the background, it runs on every client. For small scale events this is no problem, but when scaling to 18k+, any such property needs to be handled with care, especially when writing logic in BPs. If thousands of OnReps are triggered on the same frame, there will likely be a small hitch, even if each isn't doing all that much.
The example map has a BP_ResizingZone
, which demonstrates how the resizing functionality can be triggered
It resizes users to the the target ScaleMultiplier
when entering the zone, and reverts the change when leaving.
There are a few more complex implementation details here, explained in the asset's event graph (e.g. why we don't just use the "overlap" event to trigger scaling up/down)
In our example BPMC_M2Example_ResizingComponent
, we update a client auth, background replicated ScaleFactor
float.
We apply that scale factor in the OnRep, applying it either immediately, or smoothly on tick.
Each flow ultimately calls `ApplyScaleMultiplier to update the character's scale:
For LOD0 actors, scale is set using SetActorScale3D
on the render target actor
NOTE: Since the render target actor can change when switching LOD level, we need to also remember to apply the scale multiplier, otherwise characters entering LOD0 will use whatever the last pooled scale was.
For crowd actors, there is a SetCrowdScale
function, that applies the scale factor.
For the local character, we also modify their spring arm, so the camera zooms in/out appropriately