Skip to content

DISReceiveComponent

huggins edited this page Apr 10, 2025 · 4 revisions

DIS Receive Component

The DISReceiveComponent handles basic receiving DIS functionality.
It should be attached to actors where receiving DIS is desired.

By default the DISReceiveComponent offers packet handling for the associated DIS entity,
basic dead reckoning, basic ground clamping, and maintains a living list of appropriate
DIS variables (such as Entity ID).

public class DISReceiveComponent 
  : MonoBehaviour

Includes

Back to Top


Members

Access Type Name Description
Public bool ApplyToOwner To automatically apply entity states to the owner actor.
Public FEntityID CurrentEntityID A unique identifier to this entity in the sim.
Public EntityTypeEditor CurrentEntityType Specifies the kind of entity, the country of design, the domain, the specific identification of the entity, and any extra information necessary for describing the entity
Public float DeadReckoningSmoothingPeriodSeconds Number of seconds to smooth between dead reckoned information and packet information if dead reckoning is enabled
Private float DeltaTimeSinceLastPDU The time in seconds since the last PDU was received
Public float DISCullingDistance The distance in Unity units from the camera that culling should begin happening
Private Coroutine DISHeartbeatCoroutine A reference to the coroutine that checks whether or not the DIS entity has timed out.
Public DISGameManager disGameManagerScript A reference to the DISGameManager script
Public EDISCullingMode DISCullingMode Determines what all DIS info should be culled
Public float DISTimeoutSeconds The time to live for the entity. Gets reset every time a new Entity State PDU is received by the sim
Private Vector3Double EntityECEFLocationDifference The difference between the entity's current and previous ECEF locations
Public EForceID EntityForceID The Force ID of the associated entity. Specifies the team or side the DIS entity is on
Public string EntityMarking A friendly name for the DIS entity
Private Vector3 EntityRotationDifference The difference between the entity's current and previous rotations
Private GeoReferenceSystem georeferenceScript A reference to the GeoreferenceSystem script.
Public LayerMask GroundClampingCollisionLayer The layer mask to use for ground clamping
Public DateTime LatestEntityStatePDUTimestamp The timestamp that the most recent Entity State PDU was received at by the DISComponent
Public EntityStatePdu MostRecentDeadReckoningPDU The most recent Dead Reckoned Entity State PDU that has been calculated
Public EntityStatePdu MostRecentEntityStatePDU The most recent Entity State PDU that has been received
Private int NumberEntityStatePDUsReceived The number of entity state pdus that have been received for this entity
Public bool PerformDeadReckoning Whether or not dead reckoning should be performed for this entity
Public bool PerformDeadReckoningSmoothing Whether or not dead reckoning should be locally smoothed for this entity
Public EGroundClampingMode PerformGroundClamping Determines how this entity should be ground clamped
Public bool SpawnedFromNetwork Whether or not the associated entity was spawned by the network or not

Back to Top


Events

Event Type Event Name Description
UnityEvent<EntityStatePdu> OnDeadReckoningUpdate Passes out an Entity State PDU with updated dead reckoning variables as a parameter
UnityEvent<DesignatorPdu> OnDesignatorPDUProcessed Called after a Designator PDU is processed
UnityEvent<DetonationPdu> OnDetonationPDUProcessed Called after a Detonation PDU is processed
UnityEvent<ElectronicEmissionsPdu> OnElectronicEmissionsPDUProcessed Called after an Electronic Emissions PDU is processed
UnityEvent<EntityStatePdu> OnEntityStatePDUProcessed Called after an Entity State PDU is processed
UnityEvent<EntityStateUpdatePdu> OnEntityStateUpdatePDUProcessed Called after an Entity State Update PDU is processed
UnityEvent<FirePdu> OnFirePDUProcessed Called after a Fire PDU is processed
UnityEvent<Vector3, Quaternion> OnGroundClampingUpdate Called after Ground Clamping is performed by the component.
UnityEvent<RemoveEntityPdu> OnRemoveEntityPDUProcessed Called after a RemoveEntity PDU is processed
UnityEvent<SignalPdu> OnSignalPDUProcessed Called after a Signal PDU is processed
UnityEvent<StartResumePdu> OnStartResumePDUProcessed Called after a Start/Resume PDU is processed
UnityEvent<StopFreezePdu> OnStopFreezePDUProcessed Called after a Stop/Freeze PDU is processed

Functions

Access Return Name Description
Public void ApplyToOwnerIfActivated(EntityStatePdu StatePDU) Applies the location and rotation to the given Entity State PDU to the owning actor
IEnumerator DelayedDestroy(float timeToDelay) Responsible for destroying a DIS entity that times out.
Public void DoDeadReckoning(float DeltaTime) Calculates the dead reckoned PDU with given time DeltaTime
Public virtual void GroundClamping() Clamps an entity to the ground
Public void HandleDesignatorPDU(DesignatorPdu DesignatorPDUIn) Handles receipt of a new designator PDU
Public void HandleDetonationPDU(DetonationPdu DetonationPDUIn) Handles receipt of a new detonation PDU
void HandleDISHeartbeat() Handles the coroutine responsible for timing out a DIS entity.
Public void HandleElectronicEmissionsPDU(ElectronicEmissionsPdu NewElectronicEmissionsPDU) Handles receipt of a new electronic emissions PDU
Public void HandleEntityStatePDU(EntityStatePdu NewEntityStatePDU) Handles receipt of a new entity state PDU
Public void HandleEntityStateUpdatePDU(EntityStatePdu NewEntityStateUpdatePDU) Handles receipt of a new entity state update PDU
Public void HandleFirePDU(FirePdu FirePDUIn) Handles receipt of a new fire PDU
double Lerp(double a, double b, float t) Returns a value that is a percentage of the way between two given values.
Public void HandleRemoveEntityPDU(RemoveEntityPdu RemoveEntityPDUIn) Handles receipt of a new remove entity PDU
Public void HandleSignalPDU(SignalPdu SignalPDUIn) Handles receipt of a new signal PDU
Public void HandleStartResumePDU(StartResumePdu StartResumePDUIn) Handles receipt of a new start resume PDU
Public void HandleStopFreezePDU(StopFreezePdu StopFreezePDUIn) Handles receipt of a new stop freeze PDU
float MapRangeClamped(float Value, float InRangeA, float InRangeB, float OutRangeA, float OutRangeB) Maps a given value between two numbers and clamps it to a given range.
Private void OnDestroy() This function is called when the MonoBehaviour will be destroyed.
Private EntityStatePdu SmoothDeadReckoning(EntityStatePdu DeadReckonPDUToSmooth) Smooths the dead reckoned PDUs over a set time frame
Private void Start() Start is called on the frame when a script is enabled just before any of the Update methods are called the first time.
Private void Update() Update is called every frame, if the MonoBehaviour is enabled.
void UpdateCommoneEntityStateInfo(EntityStatePdu NewEntityStatePDU) Updates information from an entity state PDU to this actor

Back to Top


Details

ApplyToOwner

public bool ApplyToOwner = false

To automatically apply entity states to the owner actor.

Back to Top


CurrentEntityID

public FEntityID EntityID

The Entity ID of the associated entity. Each Entity ID should be unique to an entity in the sim.

Back to Top


CurrentEntityType

public EntityIDEditor EntityType

The Entity Type of the associated entity. Specifies the kind of entity, the country of design, the domain, the specific identification of the entity, and any extra information necessary for describing the entity.

Back to Top


DeadReckoningSmoothingPeriodSeconds

public float DeadReckoningSmoothingPeriodSeconds = 0.5f

Number of seconds to smooth between dead reckoned information and packet information if dead reckoning is enabled.

Back to Top


DeltaTimeSinceLastPDU

private float DeltaTimeSinceLastPDU = 0.0f

The time in seconds since the last PDU was received.

Back to Top


DISCullingDistance

public float DISCullingDistance = 0.0f

The distance in Unity units from the camera that culling should begin happening.

Back to Top


DISCullingMode

public EDISCullingMode DISCullingMode = EDISCullingMode.None

Determines what all DIS info should be culled. Allows for updates to happen less frequently for entities that aren't currently important.
The distance that culling should happen is handled by the DISCullingDistance variable.

Back to Top


DISGameManagerScript

private Coroutine DISHeartbeatCoroutine

A reference to the DISGameManager script

Back to Top


DISHeartbeatCoroutine

public EDISCullingMode DISCullingMode = EDISCullingMode.None

A reference to the coroutine that checks whether or not the DIS entity has timed out.

Back to Top


DISTimeoutSeconds

public float DISTimeoutSeconds = 30.0f

The time to live for the entity. Gets reset every time a new Entity State PDU is received by the sim.

Range: [0, 3600]

Back to Top


EntityECEFLocationDifference

private Vector3Double EntityECEFLocationDifference

The difference between the entity's current and previous ECEF locations.

Back to Top


EntityForceID

public EForceID EntityForceID

The Force ID of the associated entity. Specifies the team or side the DIS entity is on.

Back to Top


EntityMarking

public string EntityMarking

The Entity Marking of the associated entity. Designates a friendly name for the DIS entity.
Max of 11 characters should be used. If more than 11 are used, it will be truncated.

Back to Top


EntityRotationDifference

private Vector3 EntityRotationDifference

The difference between the entity's current and previous rotations.

Back to Top


GeoreferenceScript

public GeoreferenceSystem georeferenceScript

A reference to the GeoreferenceSystem script.

Back to Top


GroundClampingCollisionLayer

public LayerMask GroundClampingCollisionLayer = 1

The collision channel to use for ground clamping.

Back to Top


LatestEntityStatePDUTimestamp

public DateTime LatestEntityStatePDUTimestamp

The timestamp that the most recent Entity State PDU was received at by the DISComponent.

Back to Top


MostRecentDeadReckoningPDU

public EntityStatePdu MostRecentDeadReckoningPDU

The most recent Dead Reckoned Entity State PDU that has been calculated.

Back to Top


MostRecentEntityStatePDU

public EntityStatePdu MostRecentEntityStatePDU

The most recent Entity State PDU that has been received.

Back to Top


NumberEntityStatePDUsReceived

private int NumberEntityStatePDUsReceived = 0

The number of entity state pdus that have been received for this entity.

Back to Top


PerformDeadReckoning

public bool PerformDeadReckoning = true

Whether or not dead reckoning should be performed for this entity.

Back to Top


PerformDeadReckoningSmoothing

public bool PerformDeadReckoningSmoothing = true

Whether or not dead reckoning should be locally smoothed for this entity.

Back to Top


PerformGroundClamping

public EGroundClampingMode PerformGroundClamping = EGroundClampingMode.GroundClampWithDISOptions

Determines how this entity should be ground clamped.

Back to Top


SpawnedFromNetwork

public bool SpawnedFromNetwork = false

Whether or not the associated entity was spawned by the network or not.

Back to Top


OnDeadReckoningUpdate

public UnityEvent<EntityStatePdu> OnDeadReckoningUpdate

Called after a dead reckoning update is performed by the component.

Parameter Description
EntityStatePdu The new dead reckoned Entity State PDU to be passed to the listeners.

Back to Top


OnDesignatorPDUProcessed

public UnityEvent<DesignatorPdu> OnDesignatorPDUProcessed

Called after a Designator PDU is processed.

Parameter Description
DesignatorPDU The Designator PDU to be passed to the listeners.

Back to Top


OnDetonationPDUProcessed

public UnityEvent<DetonationPdu> OnDetonationPDUProcessed

Called after a Detonation PDU is processed.

Parameter Description
DetonationPDU The Detonation PDU to be passed to the listeners.

Back to Top


OnElectronicEmissionsPDUProcessed

public UnityEvent<ElectronicEmissionsPdu> OnElectronicEmissionsPDUProcessed

Called after an Electronic Emissions PDU is processed.

Parameter Description
ElectronicEmissionsPDU The Electronic Emissions PDU to be passed to the listeners.

Back to Top


OnEntityStatePDUProcessed

public UnityEvent<EntityStatePdu> OnEntityStatePDUProcessed

Called after an Entity State PDU is processed.

Parameter Description
EntityStatePDU The Entity State PDU to be passed to the listeners.

Back to Top


OnEntityStateUpdatePDUProcessed

public UnityEvent<EntityStateUpdatePdu> OnEntityStateUpdatePDUProcessed

Called after an Entity State Update PDU is processed.

Parameter Description
EntityStateUpdatePDU The Entity State Update PDU to be passed to the listeners.

Back to Top


OnFirePDUProcessed

public UnityEvent<FirePdu> OnFirePDUProcessed

Called after a Fire PDU is processed.

Parameter Description
FirePDU The Fire PDU to be passed to the listeners.

Back to Top


OnGroundClampingUpdate

public UnityEvent<Vector3, Quaternion> OnGroundClampingUpdate

Called after Ground Clamping is performed by the component. Passes ground clamp position and rotation as parameters.

NOTE: Gets called after receiving Entity State PDUs or finishing Dead Reckoning Updates if Ground Clamping is enabled on the DISComponent. Respective Entity State and Dead Reckoning events are called first. Implementing Ground Clamping location updates on top of these event may cause jitter in actor location.

Parameter Description
Vector3 The location the entity should be ground clamped to.
Quaternion The roation the entity should have after ground clamping.

Back to Top


OnRemoveEntityPDUProcessed

public UnityEvent<RemoveEntityPdu> OnRemoveEntityPDUProcessed

Called after a Remove Entity PDU is processed.

Parameter Description
RemoveEntityPDU The Remove Entity PDU to be passed to the listeners.

Back to Top


OnSignalPDUProcessed

public UnityEvent<SignalPdu> OnSignalPDUProcessed

Called after a Signal PDU is processed.

Parameter Description
SignalPDU The Signal PDU to be passed to the listeners.

Back to Top


OnStartResumePDUProcessed

public UnityEvent<StartResumePdu> OnStartResumePDUProcessed

Called after a Start/Resume PDU is processed.

Parameter Description
StartResumePDU The Start Resume PDU to be passed to the listeners.

Back to Top


OnStopFreezePDUProcessed

public UnityEvent<StopFreezePdu> OnStopFreezePDUProcessed

Called after a Stop/Freeze PDU is processed.

Parameter Description
StopFreezePDU The Stop Freeze PDU to be passed to the listeners.

Back to Top


ApplyToOwnerIfActivated

void ApplyToOwnerIfActivated
(
  EntityStatePdu StatePDU
)

Applies the location and rotation to the given Entity State PDU to the owning actor

Parameter Description
StatePDU The Entity State PDU that contains the location and rotation to apply to the owning actor.

Back to Top


DelayedDestroy

IEnumerator DelayedDestroy
(
  float timeToDelay
)

Responsible for destroying a DIS entity that times out.

Parameter Description
timeToDelay The amount of time to delay destroying the game object for.
Returns
The yield instruction to return to the coroutine awaiting this function.

Back to Top


DoDeadReckoning

public void DoDeadReckoning
(
  float DeltaTime
)

Calculates the dead reckoned PDU with given time DeltaTime.

Parameter Description
DeltaTime The time since the last tick

Back to Top


GroundClamping

public virtual void GroundClamping()

Clamps an entity to the ground. Should call OnGroundClampingUpdate event when finished.

Back to Top


Lerp

double Lerp(double a, double b, float t)

Returns a value that is a percentage of the way between two given values.

Parameter Description
a Start value. Will be returned if t = 0.
b End value. Will be returned if t = 1.
t Value used to interpolate between a and b.
Returns
The lerped value.

Back to Top


HandleDesignatorPDU

public void HandleDesignatorPDU
(
  DesignatorPdu NewDesignatorPDU
)

Handles receipt of a new designator PDU.

Parameter Description
NewDesignatorPDU The designator PDU being handled

Back to Top


HandleDetonationPDU

public void HandleDetonationPDU
(
  DetonationPdu NewDetonationPDU
)

Handles receipt of a new detonation PDU.

Parameter Description
NewDetonationPDU The detonation PDU being handled

Back to Top


HandleDISHeartbeat

void HandleDISHeartbeat()

Handles the coroutine responsible for timing out a DIS entity.

Back to Top


HandleElectronicEmissionsPDU

public void HandleElectronicEmissionsPDU
(
  ElectronicEmissionsPdu NewElectronicEmissionsPDU
)

Handles receipt of a new electronic emissions PDU.

Parameter Description
NewElectronicEmissionsPDU The electronic emissions PDU being handled

Back to Top


HandleEntityStatePDU

public void HandleEntityStatePDU
(
  EntityStatePdu NewEntityStatePDU
)

Handles receipt of a new entity state PDU.

Parameter Description
NewEntityStatePDU The entity state PDU being handled

Back to Top


HandleEntityStateUpdatePDU

public void HandleEntityStateUpdatePDU
(
  EntityStateUpdatePdu NewEntityStateUpdatePDU
)

Handles receipt of a new entity state update PDU.

Parameter Description
NewEntityStateUpdatePDU The entity state update PDU being handled

Back to Top


HandleFirePDU

public void HandleFirePDU
(
  FirePdu NewFirePDU
)

Handles receipt of a new fire PDU.

Parameter Description
NewFirePDU The fire PDU being handled

Back to Top


HandleRemoveEntityPDU

public void HandleRemoveEntityPDU
(
  RemoveEntityPdu NewRemoveEntityPDU
)

Handles receipt of a new remove entity PDU.

Parameter Description
NewRemoveEntityPDU The remove entity PDU being handled

Back to Top


HandleSignalPDU

public void HandleSignalPDU
(
  SignalPdu NewSignalPDUIn
)

Handles receipt of a new Signal PDUs.

Parameter Description
NewSignalPDUIn The Signal PDU being handled

Back to Top


HandleStartResumePDU

public void HandleStartResumePDU
(
  StartResumePdu NewStartResumePDU
)

Handles receipt of a new start resume PDU.

Parameter Description
NewStartResumePDU The start/resume PDU being handled

Back to Top


HandleStopFreezePDU

public void HandleStopFreezePDU
(
  StopFreezePdu NewStopFreezePDU
)

Handles receipt of a new stop freeze PDU.

Parameter Description
NewStopFreezePDU The stop/freeze PDU being handled

Back to Top


MapRangeClamped

float MapRangeClamped
(
  float Value,
  float InRangeA,
  float InRangeB,
  float OutRangeA,
  float OutRangeB
)

Maps a given value between two numbers and clamps it to a given range.

Parameter Description
Value The value to map and clamp.
InRangeA Minimum value of the input value range.
InRangeB Maximum value of the input value range.
OutRangeA Minimum value of the output value range.
OutRangeB Maximum value of the output value range.
Returns
The value that has been mapped and clamped.

Back to Top


OnDestroy

private void OnDestroy()

This function is called when the MonoBehaviour will be destroyed.

Back to Top


SmoothDeadReckoning

EntityStatePdu SmoothDeadReckoning
(
  EntityStatePdu DeadReckonPDUToSmooth
)

Smooths the dead reckoned PDUs over a set time frame.

Parameter Description
DeadReckonPDUToSmooth The dead reckoning pdu to use for this smoothing

|Returns| |A new entity state PDU to use with smoothed values|

Back to Top


Start

private void Start()

Start is called on the frame when a script is enabled just before any of the Update methods are called the first time.

https://docs.unity3d.com/ScriptReference/MonoBehaviour.Start.html

Back to Top


Update

void Update()

Update is called every frame, if the MonoBehaviour is enabled.

https://docs.unity3d.com/ScriptReference/MonoBehaviour.Update.html

Back to Top


UpdateCommonEntityStateInfo

void UpdateCommonEntityStateInfo
(
  EntityStatePdu NewEntityStatePDU
)

Updates information from an entity state PDU to this actor.

Parameter Description
NewEntityStatePDU The entity state PDU being handled

Back to Top


Clone this wiki locally