Reply To: Setup an Instantiated "child" UnityObject

Forums 💬 FlowCanvas ⚙️ Support Setup an Instantiated "child" UnityObject Reply To: Setup an Instantiated "child" UnityObject

#21761
Gavalakis
Keymaster

    Hello guys,

    Thank you @5tarkaster. I am glad you enjoy FlowCanvas 🙂

    If you take a look at the Instantiate node in your image, you will notice that it has an “X” and is highlighted in red. This means that there was an error in it’s execution, and most probably you got this error logged in your console:
    InvalidCastException: Cannot cast from source type to destination type..

    What is happening here, is that UnityEngine.Object.Instantiate, returns a UnityEngine.Object, which is then connected to the SendEvent node “Target”, which takes a GraphOwner type. This should normally work by automatically casting the object, but it’s a bug I have to fix as it seems :/
    A solution around that, would be to use the generic “Instantiate (T)” node. This should be the first node that shows up in the node browser when you search for “instantiate”. Using the generic “Instantiate (T)” in your example, will work without any problems, but it’s also generally better to use the generic nodes/methods where available as well.

    [attachment file=”Instantiate(T).gif”]

    Creating custom nodes like you did, is always another solution of course 🙂