using UnityEngine; namespace Unity.VisualScripting { #if MODULE_PHYSICS_EXISTS [UnitCategory("Events/Physics")] public abstract class CollisionEventUnit : 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 total impulse applied to this contact pair to resolve the collision. /// [DoNotSerialize] public ValueOutput impulse { get; private set; } /// /// The relative linear velocity of the two colliding objects. /// [DoNotSerialize] public ValueOutput relativeVelocity { 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)); impulse = ValueOutput(nameof(impulse)); relativeVelocity = ValueOutput(nameof(relativeVelocity)); data = ValueOutput(nameof(data)); } protected override void AssignArguments(Flow flow, Collision collision) { flow.SetValue(collider, collision.collider); flow.SetValue(contacts, collision.contacts); flow.SetValue(impulse, collision.impulse); flow.SetValue(relativeVelocity, collision.relativeVelocity); flow.SetValue(data, collision); } } #endif }