Forums › 💬 FlowCanvas › ⚙️ Support › Reflected nodes that should act as events? › Reply To: Reflected nodes that should act as events?
This programming isn’t too tough. It might take a couple hours of work, but the end result will be what you want 🙂
I actually just did it… so maybe you can do the same:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
using UnityEngine; using ParadoxNotion.Design; namespace FlowCanvas.Nodes{ [Name("Simple Sensor")] [Description("Fires when a unit enters the sensor")] public class SensorNode : EventNode<SimpleSensor> { private FlowOutput entered; private FlowOutput exited; private IUnit lastUnit; private Vector3 lastPoint; private GameObject lastSensor; public override void OnGraphStarted(){ target.value.OnSensorEntered += SensorEntered; target.value.OnSensorExited += SensorExited; } public override void OnGraphStoped(){ target.value.OnSensorEntered -= SensorEntered; target.value.OnSensorExited -= SensorExited; } //Register the output flow port or any other port protected override void RegisterPorts(){ entered = AddFlowOutput("Entered"); exited = AddFlowOutput("Exited"); } void SensorEntered ( IUnit triggerer, Vector3 pos, GameObject sensor ) { lastUnit = triggerer; lastPoint = pos; lastSensor = sensor; entered.Call(new Flow()); } void SensorExited ( IUnit triggerer, Vector3 pos, GameObject sensor ) { lastUnit = triggerer; lastPoint = pos; lastSensor = sensor; exited.Call(new Flow()); } } } |
Mine has two events tho, but you can just delete one.
I believe you when you say you don’t have the skill now – but I don’t believe you when you say that visual programming is all you can manage…. it’s just all you have managed yet to this date. Tomorrow that can change if you are willing
