A game about forced loneliness, made by TACStudios
1using UnityEngine;
2
3namespace Unity.VisualScripting
4{
5#if MODULE_PHYSICS_2D_EXISTS
6 [UnitCategory("Events/Physics 2D")]
7 public abstract class CollisionEvent2DUnit : GameObjectEventUnit<Collision2D>
8 {
9 /// <summary>
10 /// The collider we hit.
11 /// </summary>
12 [DoNotSerialize]
13 public ValueOutput collider { get; private set; }
14
15 /// <summary>
16 /// The contact points generated by the physics engine.
17 /// </summary>
18 [DoNotSerialize]
19 public ValueOutput contacts { get; private set; }
20
21 /// <summary>
22 /// The relative linear velocity of the two colliding objects.
23 /// </summary>
24 [DoNotSerialize]
25 public ValueOutput relativeVelocity { get; private set; }
26
27 /// <summary>
28 /// Whether the collision was enabled or not.
29 /// </summary>
30 [DoNotSerialize]
31 public ValueOutput enabled { get; private set; }
32
33 /// <summary>
34 /// The complete collision data object.
35 /// </summary>
36 [DoNotSerialize]
37 public ValueOutput data { get; private set; }
38
39 protected override void Definition()
40 {
41 base.Definition();
42 collider = ValueOutput<Collider2D>(nameof(collider));
43 contacts = ValueOutput<ContactPoint2D[]>(nameof(contacts));
44 relativeVelocity = ValueOutput<Vector2>(nameof(relativeVelocity));
45 enabled = ValueOutput<bool>(nameof(enabled));
46 data = ValueOutput<Collision2D>(nameof(data));
47 }
48
49 protected override void AssignArguments(Flow flow, Collision2D collisionData)
50 {
51 flow.SetValue(collider, collisionData.collider);
52 flow.SetValue(contacts, collisionData.contacts);
53 flow.SetValue(relativeVelocity, collisionData.relativeVelocity);
54 flow.SetValue(enabled, collisionData.enabled);
55 flow.SetValue(data, collisionData);
56 }
57 }
58#endif
59}