A game about forced loneliness, made by TACStudios
1using UnityEngine;
2
3namespace Unity.VisualScripting
4{
5#if MODULE_PHYSICS_EXISTS
6 [UnitCategory("Events/Physics")]
7 public abstract class CollisionEventUnit : GameObjectEventUnit<Collision>
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 total impulse applied to this contact pair to resolve the collision.
23 /// </summary>
24 [DoNotSerialize]
25 public ValueOutput impulse { get; private set; }
26
27 /// <summary>
28 /// The relative linear velocity of the two colliding objects.
29 /// </summary>
30 [DoNotSerialize]
31 public ValueOutput relativeVelocity { 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
43 collider = ValueOutput<Collider>(nameof(collider));
44 contacts = ValueOutput<ContactPoint[]>(nameof(contacts));
45 impulse = ValueOutput<Vector3>(nameof(impulse));
46 relativeVelocity = ValueOutput<Vector3>(nameof(relativeVelocity));
47 data = ValueOutput<Collision>(nameof(data));
48 }
49
50 protected override void AssignArguments(Flow flow, Collision collision)
51 {
52 flow.SetValue(collider, collision.collider);
53 flow.SetValue(contacts, collision.contacts);
54 flow.SetValue(impulse, collision.impulse);
55 flow.SetValue(relativeVelocity, collision.relativeVelocity);
56 flow.SetValue(data, collision);
57 }
58 }
59#endif
60}