Answer the question
In order to leave comments, you need to log in
How to assign a Child to another Parent?
Unity.5.2.3. csharp.
You need to do this in the hierarchy through the script.
It turns out to move the object to the topmost Parent'u. Thus:
using UnityEngine;
using System.Collections;
public class ImpulseObject : MonoBehaviour {
public GameObject inHands;
public GameObject Slight;
public GameObject Box;
void Update () {
if (Input.GetKeyDown(KeyCode.C))
{
print ("yes");
///////////////////////////////////////////////////////////////////////////////////
Slight.transform.parent = inHands.transform;
///////////////////////////////////////////////////////////////////////////////////
Box.GetComponent<Rigidbody2D>().isKinematic = true;
//Box.transform.position = inHands.transform.position;
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question