extended InstantiateGameObject action

NodeCanvas Forums Custom Nodes & Tasks extended InstantiateGameObject action

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #11518
    bcristian
    Participant

    Hello

    I’ve extended the InstantiateGameObject action to include parent and rotation parameters.
    Instantiating directly under the parent is faster than instantiating under the world and immediately parenting (it’s somewhere in the Unity3d blog, cannot find the link now).
    Also helps by removing the need to add another action to do the parenting.

    I’ve replaced the original InstantiateGameObject.cs with:

    #11528
    Gavalakis
    Keymaster

    Hey,

    Nice one. I will update the action as well, but I think I will make the rotation a Vector3 instead of Quaternion so that it is easier to adjust with sanity 🙂
    To that end, I went ahead and added a new AutoCast conversion from Quaternion to Vector3 and vice verse, which means that the Vector3 parameter of this action (or any action) can be linked to a Quaternion Variable which will be auto converted to Vector3, like the rest of the AutoCasts work.

    Thanks!

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

    #11629
    bcristian
    Participant

    Modified it again, to include better info when parenting under a BB variable, and instantiating directly under the parent, instead of changing the hierarchy (a potentially expensive operation).

    #11634
    Gavalakis
    Keymaster

    Hey,

    The reason I did not use the Instantiate overload that automatically parents the instance is because it’s not available in Unity 5.3 🙂

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

    #11638
    bcristian
    Participant

    Hello
    Haven’t though about that.
    Simple to account for though:

    The UNITY_X_Y_OR_NEWER was added in 5.3.4

    I’ve read in the Unity dev blog that due to changes made in the internal transform hierarchy representation starting with 5.4 (if I’m not mistaken), the cost of re-parenting large hierarchies can be significant, and it also allocates and moves significant amounts of memory. They mentioned in particular the version of Instantiate that takes a parent vs instantiating and immediately setting the parent.

    #11671
    Gavalakis
    Keymaster

    Yeah I know of the UNITY_X_Y_OR_NEWER directive. I just didnt think that it is such a performance difference.
    Regardless, I’ve just modified the task such as you posted above.
    Thanks.

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

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