Instantiate
Node description and basic instructions
Last updated
Node description and basic instructions
Last updated
Clones the object original and returns the clone.
This function makes a copy of an object in a similar way to the Duplicate command in the editor. If you are cloning a GameObject you can specify its position and rotation (these default to the original GameObject's position and rotation otherwise). If you are cloning a Component the GameObject it is attached to is also cloned, again with an optional position and rotation.
When you clone a GameObject or Component, all child objects and components are also cloned with their properties set like those of the original object.
When this method clones a child object, it also clones the child's own children. To prevent stack overflow, Unity limits this nested cloning. If you exceed more than half your stack size, Unity throws an InsufficientExecutionStackException.
By default the parent of the new object is null; it is not a "sibling" of the original. If a parent is specified and no position and rotation are specified, the original object's position and rotation are used for the cloned object's local position and rotation. If the position and rotation are specified, they are used as the object's position and rotation in world space.
The active status of a GameObject at the time of cloning is maintained, so if the original is inactive the clone is created in an inactive state too.
These methods do not create a prefab connection to the new instantiated object. Creating objects with a prefab connection can be achieved using Instantiate Prefab.
To create it, right-click on free space in AI Tree inspector and select Create Node/Tasks/Object/Object.
This task node has a number of fields, that are highlighted in picture below.
Node Name
Name of node
Ignore About Self
Whether node ignores abort self or not
Object To Instantiate
Target you want to destroy
Position
Position of the cloned object
Rotation
Rotation of the cloned object
Parent
Parent of cloned object