Checking For Component before writing to Blackboard

FlowCanvas Forums Support Checking For Component before writing to Blackboard

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #380
    cbrandick
    Participant

    Hi!

    I am new to FlowCanvas and am not sure if I am approaching this correctly. I have two types of units, let’s say Hero and Baddie, in an RTS game each with its own base class, “Hero” and “Baddie” respectively.

    I would like when the two unit types collide that they become “aware” of one another, but I don’t want two units of the same type to be do the same. Seeing as collision has no sense for the GameObject itself, I want to check the “other” GameObject in the collision to see if it has the proper component before doing anything else. Do I need to write a custom node that takes a GameObject in as an argument and then checks the gameobject for whether or not it has a specific component?

    I hope that makes sense.

    Thanks!
    Charles

    #381
    Gavalakis
    Keymaster

    Hello Charles!

    You could use the GetComponent reflected node and check if it’s null, which is done with the IsValid node in FlowCanvas.
    Just remember to add your types in the Preferred Types Editor (Window/NodeCanvas/PreferredTypes Editor), so that you can work with them easier.

    I have attached an example image for you here. I will make it possible in the next version that a unity engine object can also be linked directly at a boolean input which will return true/false based based on if it’s null, similar to how it’s done in code.
    I can tell you how to add this by the way now, if you want to. It’s easy.

    Let me know if this works for you, or you were looking at a different solution.
    Thanks

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

    Attachments:
    You must be logged in to view attached files.
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.