using UnityEngine; namespace Unity.VisualScripting { #if MODULE_PHYSICS_2D_EXISTS [UnitCategory("Events/Physics 2D")] public abstract class CollisionEvent2DUnit : GameObjectEventUnit { /// /// The collider we hit. /// [DoNotSerialize] public ValueOutput collider { get; private set; } /// /// The contact points generated by the physics engine. /// [DoNotSerialize] public ValueOutput contacts { get; private set; } /// /// The relative linear velocity of the two colliding objects. /// [DoNotSerialize] public ValueOutput relativeVelocity { get; private set; } /// /// Whether the collision was enabled or not. /// [DoNotSerialize] public ValueOutput enabled { get; private set; } /// /// The complete collision data object. /// [DoNotSerialize] public ValueOutput data { get; private set; } protected override void Definition() { base.Definition(); collider = ValueOutput(nameof(collider)); contacts = ValueOutput(nameof(contacts)); relativeVelocity = ValueOutput(nameof(relativeVelocity)); enabled = ValueOutput(nameof(enabled)); data = ValueOutput(nameof(data)); } protected override void AssignArguments(Flow flow, Collision2D collisionData) { flow.SetValue(collider, collisionData.collider); flow.SetValue(contacts, collisionData.contacts); flow.SetValue(relativeVelocity, collisionData.relativeVelocity); flow.SetValue(enabled, collisionData.enabled); flow.SetValue(data, collisionData); } } #endif }