- Home /
Scriptural Child Implementation
Okay. I have a GameObject that contains a set of my spoilers, at a centralized point, and only 1 is set active by a script. There is a tracker object that moves with the game object to place the spoiler game object at the correct point of different car. I have all that set up, but now when I use SetActive to destroy the car, my Spoilers also disappear. What I want do is Remove the Spoilers game object from the car, and make it a parent, Destroy the car, and use SetActive to show another car, And then move the Spoiler GameObject back as a child. The spoiler has to be a child because the car will be moving on Ramps, and other things. You can view the Demo Here.
Answer by programmrzinc · Jan 09, 2013 at 06:17 PM
What I did however is not set the Parents or Children, but used the following script to move the Spoiler Object where ever the Marker is.
var SpoilerGO : Transform;
var SpoilerMarker : Transform;
var Transforms : String;
function Start () {
}
function Update () {
SpoilerGO.position = SpoilerMarker.position;
Transforms = SpoilerGO.position+ " "+ SpoilerMarker.position;
}
Answer by Loius · Jan 09, 2013 at 06:08 PM
childObject.transform.parent = parentObject.transform
To set the parent to nothing, set transform.parent = null.
Your answer works, but I needed more versatility for my own project.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Can a parent SetActive a child GameObject anymore 2 Answers
How can I access a child object? 1 Answer
Problems with save 1 Answer
ReActivate object with null movement ?? 2 Answers