Hello,
I have a cube parented to a sphere manually.
I can unparent at runtime with this script.
function Update () {
if (Input.GetButton(“Fire2”))
transform.parent = null;
Is there a script to re-parent cube to sphere
at runtime? Things I try don’t work. Thank you
for any help. David Butler
Have you tried a variable to keep track of the sphere? eg:
private var parentSphere : Transform;
function Awake() {
parentSphere = transform.parent;
}
function Update() {
if(Input.GetButton("Fire1"))
transform.parent = parentSphere;
// + other code from before
}
Thank you Novodantis,
Your script worked. I hope I can help you
some day.
David Butler