The SetParent
method allows you to set the parent of a GameObject
. This method is useful for organizing objects within a scene hierarchy, enabling you to change the parent-child relationships dynamically. The method takes two parameters:
value
: TheGameObject
that will become the new parent.keepWorldPosition
: Abool
indicating whether theGameObject
should maintain its current world position after the parent change. If set totrue
, the object's world position remains unchanged; iffalse
, the object's position will be relative to the new parent.