A game about forced loneliness, made by TACStudios
1using System;
2using UnityEngine;
3
4namespace Unity.VisualScripting
5{
6#if MODULE_PHYSICS_EXISTS
7 /// <summary>
8 /// Called when the controller hits a collider while performing a move.
9 /// </summary>
10 [UnitCategory("Events/Physics")]
11 [TypeIcon(typeof(CharacterController))]
12 public sealed class OnControllerColliderHit : GameObjectEventUnit<ControllerColliderHit>
13 {
14 public override Type MessageListenerType => typeof(UnityOnControllerColliderHitMessageListener);
15 protected override string hookName => EventHooks.OnControllerColliderHit;
16
17 /// <summary>
18 /// The collider that was hit by the controller.
19 /// </summary>
20 [DoNotSerialize]
21 public ValueOutput collider { get; private set; }
22
23 /// <summary>
24 /// The controller that hit the collider.
25 /// </summary>
26 [DoNotSerialize]
27 public ValueOutput controller { get; private set; }
28
29 /// <summary>
30 /// The direction the CharacterController was moving in when the collision occured.
31 /// </summary>
32 [DoNotSerialize]
33 public ValueOutput moveDirection { get; private set; }
34
35 /// <summary>
36 /// How far the character has travelled until it hit the collider.
37 /// </summary>
38 [DoNotSerialize]
39 public ValueOutput moveLength { get; private set; }
40
41 /// <summary>
42 /// The normal of the surface we collided with in world space.
43 /// </summary>
44 [DoNotSerialize]
45 public ValueOutput normal { get; private set; }
46
47 /// <summary>
48 /// The impact point in world space.
49 /// </summary>
50 [DoNotSerialize]
51 public ValueOutput point { get; private set; }
52
53 /// <summary>
54 /// The impact point in world space.
55 /// </summary>
56 [DoNotSerialize]
57 public ValueOutput data { get; private set; }
58
59 protected override void Definition()
60 {
61 base.Definition();
62
63 collider = ValueOutput<Collider>(nameof(collider));
64 controller = ValueOutput<CharacterController>(nameof(controller));
65 moveDirection = ValueOutput<Vector3>(nameof(moveDirection));
66 moveLength = ValueOutput<float>(nameof(moveLength));
67 normal = ValueOutput<Vector3>(nameof(normal));
68 point = ValueOutput<Vector3>(nameof(point));
69 data = ValueOutput<ControllerColliderHit>(nameof(data));
70 }
71
72 protected override void AssignArguments(Flow flow, ControllerColliderHit hitData)
73 {
74 flow.SetValue(collider, hitData.collider);
75 flow.SetValue(controller, hitData.controller);
76 flow.SetValue(moveDirection, hitData.moveDirection);
77 flow.SetValue(moveLength, hitData.moveLength);
78 flow.SetValue(normal, hitData.normal);
79 flow.SetValue(point, hitData.point);
80 flow.SetValue(data, hitData);
81 }
82 }
83#endif
84}