Game.Events.Impact
Assembly: Assembly-CSharp (typical for game code; actual assembly may vary)
Namespace: Game.Events
Type: struct
Base: IComponentData, IQueryTypeParameter
Summary: Represents an impact event encoded as an ECS component. Used to communicate a collision/impact between entities to systems that process events (physics reactions, damage, sound, VFX, AI responses, etc.). Contains references to the event and target entities, linear and angular velocity deltas produced by the impact, a severity value to help consumers prioritize or scale effects, and a flag to indicate whether a "stopped" event should be checked/emitted. This is a plain blittable value type suitable for use with Unity's ECS.
Fields
-
public Entity m_Event
Reference to the entity that represents the event itself (often an event entity created to carry the Impact component). Consumers can inspect or remove this entity once processed. -
public Entity m_Target
The entity that was impacted (the target of the event). Systems typically use this to apply responses (damage, force, animations). -
public float3 m_VelocityDelta
Linear velocity change applied by the impact (Unity.Mathematics.float3). Usually in world-space units (meters/second). Consumers may use this to calculate knockback or play impact sounds based on magnitude. -
public float3 m_AngularVelocityDelta
Angular velocity change applied by the impact (Unity.Mathematics.float3). Expressed in radians/second (consistent with Unity's angular velocity conventions). Useful for spinning or rotational reactions. -
public float m_Severity
A scalar indicating the impact's severity. Interpretation is consumer-defined (commonly 0..1 normalized, but can be an absolute measure). Used to scale damage, sound volume, particle intensity, or to prioritize handling. -
public bool m_CheckStoppedEvent
If true, consumers may check for and emit a follow-up "stopped" or "come-to-rest" event (for example, to detect if an impacted vehicle or object has stopped after the collision). Controls additional processing logic.
Properties
- None. This is a plain data struct exposed via public fields for fast ECS access.
Constructors
public Impact()
No explicit constructor is defined in the source; the struct has the implicit default constructor. Create instances via object initializer syntax or by assigning fields directly. Example: new Impact { m_Event = e, m_Target = t, m_VelocityDelta = v, ... }.
Methods
- None. This is a pure data container and does not implement methods in the provided source.
Usage Example
// Example: creating an impact event and attaching it to an event entity in an ECS system.
using Unity.Entities;
using Unity.Mathematics;
using Game.Events;
void EmitImpact(EntityManager entityManager, Entity target, float3 velocityDelta, float3 angularDelta, float severity)
{
// create an event entity (optionally with a lifetime or marker)
Entity evt = entityManager.CreateEntity();
// attach the Impact component to signal the event
entityManager.AddComponentData(evt, new Impact
{
m_Event = evt,
m_Target = target,
m_VelocityDelta = velocityDelta,
m_AngularVelocityDelta = angularDelta,
m_Severity = severity,
m_CheckStoppedEvent = true
});
// Systems querying for Impact will pick this up and process it accordingly.
}
{{ This struct is intended to be lightweight and used for transient event propagation in ECS. Keep the data simple and avoid embedding managed or large data inside the component. Consumers should remove or destroy event entities after processing to avoid repeated handling. }}