The Quantum entity view component is the representation of the entity inside Unity. Instances will be created by the EntityViewUpdater. Quantum entity with the View component will references a Quantum EntityView asset which will in turn be instantiated as EntityView.Prefab and the resulting game object includes this script. More...
Classes | |
class | EntityUnityEvent |
Wrapping UnityEvent(QuantumGame) into a class. Is used by the QuantumEntityView to make create and destroy publish Unity events. More... | |
struct | UpdatePositionParameter |
The struct is used to gather all transform and interpolation data to apply new transform data to the entity view. ApplyTransform(ref UpdatePositionParameter). More... | |
Public Member Functions | |
bool | HasViewFlag (QuantumEntityViewFlags flag) |
Test if a view flag is set. More... | |
virtual void | OnActivate (Frame frame) |
A callback to override to add custom logic the activation of this entity view. More... | |
virtual void | OnDeactivate () |
A callback to override to add custom logic to the deactivation of this entity view. More... | |
virtual void | OnGameChanged () |
A callback to override to add custom logic when the associate game has changed on the connected QuantumEntityViewUpdater. More... | |
virtual void | OnInitialize () |
A callback to override to add custom logic to the initialization of this entity view. More... | |
virtual void | OnLateUpdateView () |
A callback to override to add custom logic to the late update method. More... | |
virtual void | OnUpdateView () |
A callback to override to add custom logic to the update method. More... | |
void | SetViewFlag (QuantumEntityViewFlags flag, bool isEnabled) |
Set the QuantumEntityViewFlags to further configure the entity view. More... | |
bool | TryGetTransform2DData (QuantumEntityViewTimeReference timeRef, ref UpdatePositionParameter param, out int frameNumber, out Transform2D transform, out Transform2DVertical transformVertical, out bool hasVertical, bool isSpawning) |
There are two sources how to get the transform 3D data from an entity. Using the Quantum predicted frames or a snapshot interpolation. Toggle the setting on InterpolationMode. More... | |
bool | TryGetTransform3DData (QuantumEntityViewTimeReference timeRef, ref UpdatePositionParameter param, out int frameNumber, out Transform3D transform, bool isSpawning) |
There are two sources how to get the transform 3D data from an entity. Using the Quantum predicted frames or a snapshot interpolation. Toggle the setting on InterpolationMode. More... | |
void | UpdateFromTransform2D (QuantumGame game, Boolean useClockAliasingInterpolation, Boolean useErrorCorrectionInterpolation, bool isSpawning) |
Apply new transform 2D data and interpolation. More... | |
void | UpdateFromTransform3D (QuantumGame game, Boolean useClockAliasingInterpolation, Boolean useErrorCorrectionInterpolation, bool isSpawning) |
Apply new transform 3D data and interpolation. More... | |
Public Attributes | |
AssetGuid | AssetGuid |
Will set to the AssetObject.Guid that the underlying EntityView asset has. Or receives a new Guid when binding this view script to a scene entity. More... | |
QuantumEntityViewBindBehaviour | BindBehaviour |
Set the entity view bind behaviour. If set to QuantumEntityViewBindBehaviour.NonVerified then the view is created during a predicted frame. Entity views created at that time can be subject to changes and even be destroyed because of misprediction. Entity views created during QuantumEntityViewBindBehaviour.Verified will be more stable but are always created at a later time, when the input has been confirmed by the server. More... | |
EntityRef | EntityRef |
References the Quantum entity that this view script is liked to. More... | |
Single | ErrorCorrectionRateMax = 10f |
Single | ErrorCorrectionRateMin = 3.3f |
Single | ErrorPositionBlendEnd = 1f |
Single | ErrorPositionBlendStart = 0.25f |
Single | ErrorPositionMinCorrection = 0.025f |
Single | ErrorPositionTeleportDistance = 2f |
Single | ErrorRotationBlendEnd = 0.5f |
Single | ErrorRotationBlendStart = 0.1f |
Single | ErrorRotationTeleportDistance = 0.5f |
QuantumEntityViewInterpolationMode | InterpolationMode |
Set the QuantumEntityViewInterpolationMode allowing the view timing to be switched between prediction and snapshot-interpolation. Requires the QuantumEntityViewFlags.SnapshotInterpolationEnabled flag to be set to have an effect. AUTO selects the mode dynamically based on the prediction-culled state of the entity. More... | |
bool | ManualDiposal => ManualDisposal |
Obsolete property, use ManualDisposal More... | |
bool | ManualDisposal |
If enabled the QuantumEntityViewUpdater will not destroy (or disable, in case of map entities) this instance, and you are responsible for removing it from the game world yourself. \nYou will still receive the OnEntityDestroyed callback. More... | |
EntityUnityEvent | OnEntityDestroyed |
Is called before the entity view is destroyed. More... | |
EntityUnityEvent | OnEntityInstantiated |
Is called after the entity view has been instantiated. More... | |
IQuantumViewComponent[] | ViewComponents => _viewComponents |
Access the entity view components registered to this entity view. All view components found on this game object during creation are used. More... | |
QuantumEntityViewFlags | ViewFlags |
Set the QuantumEntityViewFlags to further configure the entity view. More... | |
Protected Member Functions | |
virtual void | ApplyTransform (ref UpdatePositionParameter param) |
The method to override to apply the final position and rotation interpolation to the view transform. More... | |
Properties | |
QuantumEntityViewUpdater | EntityViewUpdater [get] |
A reference to the entity view updater that controls this entity view. More... | |
QuantumGame | Game [get] |
A reference to the current game that this entity view belongs to QuantumEntityViewUpdater.ObservedGame. More... | |
bool | GameObjectNameIsEntityRef [get, set] |
If set to true, the game object will be renamed to the EntityRef number. More... | |
Transform | Transform [get] |
Access the transform of the entity view. In play mode the transform object will be cached to improve the performance. More... | |
Dictionary< Type, IQuantumViewContext > | ViewContexts [get] |
All contexts found on the EntityViewUpdater game object accessible by their type. More... | |
The Quantum entity view component is the representation of the entity inside Unity. Instances will be created by the EntityViewUpdater. Quantum entity with the View component will references a Quantum EntityView asset which will in turn be instantiated as EntityView.Prefab and the resulting game object includes this script.
|
inline |
Set the QuantumEntityViewFlags to further configure the entity view.
flag | The flag enum value |
isEnabled | Set or unset the flag. |
bool Quantum.QuantumEntityView.HasViewFlag | ( | QuantumEntityViewFlags | flag | ) |
Test if a view flag is set.
flag |
|
inlinevirtual |
A callback to override to add custom logic to the initialization of this entity view.
|
inlinevirtual |
A callback to override to add custom logic the activation of this entity view.
frame | Frame |
|
inlinevirtual |
A callback to override to add custom logic to the deactivation of this entity view.
|
inlinevirtual |
A callback to override to add custom logic to the update method.
|
inlinevirtual |
A callback to override to add custom logic to the late update method.
|
inlinevirtual |
A callback to override to add custom logic when the associate game has changed on the connected QuantumEntityViewUpdater.
|
inline |
There are two sources how to get the transform 3D data from an entity. Using the Quantum predicted frames or a snapshot interpolation. Toggle the setting on InterpolationMode.
timeRef | Time reference context |
param | Transform parameter to be filled out |
frameNumber | Resulting frame number |
transform | Resulting transform |
isSpawning | Is the entity spawning |
|
inline |
Apply new transform 3D data and interpolation.
game | Game |
useClockAliasingInterpolation | Use clock aliasing interpolation |
useErrorCorrectionInterpolation | Use error correction interpolation |
isSpawning | Is the entity just spawning |
|
inline |
There are two sources how to get the transform 3D data from an entity. Using the Quantum predicted frames or a snapshot interpolation. Toggle the setting on InterpolationMode.
timeRef | Time reference context |
param | Transform parameter to be filled out |
frameNumber | Resulting frame number |
transform | Resulting transform |
transformVertical | Transform vertical component |
hasVertical | Has a transform vertical 2D component |
isSpawning | Is the entity spawning |
True if data could be retrieved
|
inline |
Apply new transform 2D data and interpolation.
game | Game |
useClockAliasingInterpolation | Use clock aliasing interpolation |
useErrorCorrectionInterpolation | Use error correction interpolation |
isSpawning | Is the entity just spawning |
|
inlineprotectedvirtual |
The method to override to apply the final position and rotation interpolation to the view transform.
param |
AssetGuid Quantum.QuantumEntityView.AssetGuid |
Will set to the AssetObject.Guid that the underlying EntityView asset has. Or receives a new Guid when binding this view script to a scene entity.
EntityRef Quantum.QuantumEntityView.EntityRef |
References the Quantum entity that this view script is liked to.
QuantumEntityViewBindBehaviour Quantum.QuantumEntityView.BindBehaviour |
Set the entity view bind behaviour. If set to QuantumEntityViewBindBehaviour.NonVerified then the view is created during a predicted frame. Entity views created at that time can be subject to changes and even be destroyed because of misprediction. Entity views created during QuantumEntityViewBindBehaviour.Verified will be more stable but are always created at a later time, when the input has been confirmed by the server.
bool Quantum.QuantumEntityView.ManualDisposal |
If enabled the QuantumEntityViewUpdater will not destroy (or disable, in case of map entities) this instance, and you are responsible for removing it from the game world yourself.
\nYou will still receive the OnEntityDestroyed callback.
bool Quantum.QuantumEntityView.ManualDiposal => ManualDisposal |
Obsolete property, use ManualDisposal
QuantumEntityViewFlags Quantum.QuantumEntityView.ViewFlags |
Set the QuantumEntityViewFlags to further configure the entity view.
QuantumEntityViewInterpolationMode Quantum.QuantumEntityView.InterpolationMode |
Set the QuantumEntityViewInterpolationMode allowing the view timing to be switched between prediction and snapshot-interpolation. Requires the QuantumEntityViewFlags.SnapshotInterpolationEnabled flag to be set to have an effect. AUTO selects the mode dynamically based on the prediction-culled state of the entity.
Single Quantum.QuantumEntityView.ErrorCorrectionRateMin = 3.3f |
A factor with dimension of 1/s (Hz) that works as a lower limit for how much of the accumulated prediction error is corrected every frame. This factor affects both the position and the rotation correction. Suggested values are greater than zero and smaller than ErrorCorrectionRateMax.
E.g.: ErrorCorrectionRateMin = 3, rendering delta time = (1/60)s: at least 5% (3 * 1/60) of the accumulated error will be corrected on this rendered frame.
This threshold might not be respected if the resultant correction magnitude is below the ErrorPositionMinCorrection or above the ErrorPositionTeleportDistance, for the position error, or above the ErrorRotationTeleportDistance, for the rotation error.
Single Quantum.QuantumEntityView.ErrorCorrectionRateMax = 10f |
A factor with dimension of 1/s (Hz) that works as a upper limit for how much of the accumulated prediction error is corrected every frame. This factor affects both the position and the rotation correction. Suggested values are greater than ErrorCorrectionRateMin and smaller than half of a target rendering rate.
E.g.: ErrorCorrectionRateMax = 15, rendering delta time = (1/60)s: at maximum 25% (15 * 1/60) of the accumulated error will be corrected on this rendered frame.
This threshold might not be respected if the resultant correction magnitude is below the ErrorPositionMinCorrection or above the ErrorPositionTeleportDistance, for the position error, or above the ErrorRotationTeleportDistance, for the rotation error.
Single Quantum.QuantumEntityView.ErrorPositionBlendStart = 0.25f |
The reference for the magnitude of the accumulated position error, in meters, at which the position error will be corrected at the ErrorCorrectionRateMin. Suggested values are greater than ErrorPositionMinCorrection and smaller than ErrorPositionBlendEnd.
In other words, if the magnitude of the accumulated error is equal to or smaller than this threshold, it will be corrected at the ErrorCorrectionRateMin. If, instead, the magnitude is between this threshold and ErrorPositionBlendEnd, the error is corrected at a rate between ErrorCorrectionRateMin and ErrorCorrectionRateMax, proportionally. If it is equal to or greater than ErrorPositionBlendEnd, it will be corrected at the ErrorCorrectionRateMax.
Note: as the factor is expressed in distance units (meters), it might need to be scaled proportionally to the overall scale of objects in the scene and speeds at which they move, which are factors that affect the expected magnitude of prediction errors.
Single Quantum.QuantumEntityView.ErrorPositionBlendEnd = 1f |
The reference for the magnitude of the accumulated position error, in meters, at which the position error will be corrected at the ErrorCorrectionRateMax. Suggested values are greater than ErrorPositionBlendStart and smaller than ErrorPositionTeleportDistance.
In other words, if the magnitude of the accumulated error is equal to or greater than this threshold, it will be corrected at the ErrorCorrectionRateMax. If, instead, the magnitude is between ErrorPositionBlendStart and this threshold, the error is corrected at a rate between ErrorCorrectionRateMin and ErrorCorrectionRateMax, proportionally. If it is equal to or smaller than ErrorPositionBlendStart, it will be corrected at the ErrorCorrectionRateMin.
Note: as the factor is expressed in distance units (meters), it might need to be scaled proportionally to the overall scale of objects in the scene and speeds at which they move, which are factors that affect the expected magnitude of prediction errors.
Single Quantum.QuantumEntityView.ErrorRotationBlendStart = 0.1f |
The reference for the magnitude of the accumulated rotation error, in radians, at which the rotation error will be corrected at the ErrorCorrectionRateMin. Suggested values are smaller than ErrorRotationBlendEnd.
In other words, if the magnitude of the accumulated error is equal to or smaller than this threshold, it will be corrected at the ErrorCorrectionRateMin. If, instead, the magnitude is between this threshold and ErrorRotationBlendEnd, the error is corrected at a rate between ErrorCorrectionRateMin and ErrorCorrectionRateMax, proportionally. If it is equal to or greater than ErrorRotationBlendEnd, it will be corrected at the ErrorCorrectionRateMax.
Single Quantum.QuantumEntityView.ErrorRotationBlendEnd = 0.5f |
The reference for the magnitude of the accumulated rotation error, in radians, at which the rotation error will be corrected at the ErrorCorrectionRateMax. Suggested values are greater than ErrorRotationBlendStart and smaller than ErrorRotationTeleportDistance.
In other words, if the magnitude of the accumulated error is equal to or greater than this threshold, it will be corrected at the ErrorCorrectionRateMax. If, instead, the magnitude is between ErrorRotationBlendStart and this threshold, the error is corrected at a rate between ErrorCorrectionRateMin and ErrorCorrectionRateMax, proportionally. If it is equal to or smaller than ErrorRotationBlendStart, it will be corrected at the ErrorCorrectionRateMin.
Single Quantum.QuantumEntityView.ErrorPositionMinCorrection = 0.025f |
The value, in meters, that represents the minimum magnitude of the accumulated position error that will be corrected in a single frame, until it is fully corrected.
This setting has priority over the resultant correction rate, i.e. the restriction will be respected even if it makes the effective correction rate be different than the one computed according to the min/max rates and start/end blend values. Suggested values are greater than zero and smaller than ErrorPositionBlendStart.
Note: as the factor is expressed in distance units (meters), it might need to be scaled proportionally to the overall scale of objects in the scene and speeds at which they move, which are factors that affect the expected magnitude of prediction errors.
Single Quantum.QuantumEntityView.ErrorPositionTeleportDistance = 2f |
The value, in meters, that represents the magnitude of the accumulated position error above which the error will be instantaneously corrected, effectively teleporting the rendered object to its correct position. Suggested values are greater than ErrorPositionBlendEnd.
This setting has priority over the resultant correction rate, i.e. the restriction will be respected even if it makes the effective correction rate be different than the one computed according to the min/max rates and start/end blend values.
Note: as the factor is expressed in distance units (meters), it might need to be scaled proportionally to the overall scale of objects in the scene and speeds at which they move, which are factors that affect the expected magnitude of prediction errors.
Single Quantum.QuantumEntityView.ErrorRotationTeleportDistance = 0.5f |
The value, in radians, that represents the magnitude of the accumulated rotation error above which the error will be instantaneously corrected, effectively teleporting the rendered object to its correct orientation. Suggested values are greater than ErrorRotationBlendEnd.
This setting has priority over the resultant correction rate, i.e. the restriction will be respected even if it makes the effective correction rate be different than the one computed according to the min/max rates and start/end blend values.
EntityUnityEvent Quantum.QuantumEntityView.OnEntityInstantiated |
Is called after the entity view has been instantiated.
EntityUnityEvent Quantum.QuantumEntityView.OnEntityDestroyed |
Is called before the entity view is destroyed.
IQuantumViewComponent [] Quantum.QuantumEntityView.ViewComponents => _viewComponents |
Access the entity view components registered to this entity view. All view components found on this game object during creation are used.
|
getset |
If set to true, the game object will be renamed to the EntityRef number.
|
get |
A reference to the entity view updater that controls this entity view.
|
get |
A reference to the current game that this entity view belongs to QuantumEntityViewUpdater.ObservedGame.
|
get |
All contexts found on the EntityViewUpdater game object accessible by their type.
|
get |
Access the transform of the entity view. In play mode the transform object will be cached to improve the performance.