Events outside out graph

NodeCanvas Forums General Discussion Events outside out graph

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #9375
    Sanity
    Participant

    Hi, 🙂

    I Have a mono behavior component attached to an object that triggers an event when field changes. How can I have a graph subscribe to this event?

    I see there are action for sending event and condition to receive it, but those from what I understand are meant to function only within the NodeCanvas?

    Please advise me on how to achieve this 🙂 thanks

    #9378
    Gavalakis
    Keymaster

    Hello,

    Sorry for late reply.
    There is a Condition Check CSharp Event under Script Control. With this you can subscribe to an event and the condition will return true when it is raised.

    Alternatively you could manualy call SendEvent(string) from your mono behaviour if you have a reference of the BehaviourTreeOwner (FSMOwner) or the Graph itself, and then check that even as normal with the Check Event condition.

    Is that what you mean?

    Join us on Discord: https://discord.gg/97q2Rjh

    #9377
    Sanity
    Participant

    Yes that’s exactly what I was looking for, except now I see that the Check CSharp Event is limited to no args, and return of void, which will not work for what I have in mind.

    Let me describe my problem… I am making a weapon platform (something along the lines of tower defense game). To the weapon platform object I attach components that give it capabilities… such as sense object in front of it using raycasts, shoot weapon, and upgrade. I want these components to be very modular and black-boxed so that Later I can use them on moving units and other things and have them work just fine.
    When all components are attached I would use NodeCanvas to create logic that binds them together. In case of field of view sense I thought that event which sends an object(or list of objects) to node canvas whenever it senses something in would be a perfect way for it and nodecanvas to interact. Am I still making sense? 🙂

    Please advise me on how to do this, is there a better way to solve this problem in a node canvas?

    Thanks ahead of time 🙂

    #9376
    Gavalakis
    Keymaster

    Of course you are making sense and actualy this is a nice way to use nodecanvas, meaning that you have all your implementation in your scripts and then using Script Control tasks. At least that’s what I understood.

    So for your problem I would suggest these alternatives:

    Create a boolean method in your component like CanSeeEnemy. Maybe you already have that.
    Use the CheckFunction condition to call and check it.

    Now the problem will remain how to set the object or list of gameobjects that is able to see. There are 2 solutions I can come up with right now:

    1. Directly write to the blackboard from within your CanSeeEnemy method if it actually can see an enemy. Just get a reference to the blackboard component the BT is using and call SetDataValue.

    2. Save the objects that can be seen in a field or property within your script when calling CanSeeEnemy, and use GetField or GetProperty to save that data in the blackboard. But that could be longer way around than the above.

    Let me know if this is a valid solution for you 🙂

    Join us on Discord: https://discord.gg/97q2Rjh

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.