i have the following code which works but throws a little yellow warning due to active being obsolete…my question is how would i go about changing this code to use the new functionality?
static function CopyTransformsRecurse (src: Transform, dst: Transform) {
dst.position = src.position;
dst.rotation = src.rotation;
dst.gameObject.active = src.gameObject.active;
for (var child: Transform in dst) {
// match the transform with the same name
var curSrc = src.Find(child.name);
if (curSrc) CopyTransformsRecurse(curSrc, child);
}
}
the above function is called in the following piece of code…
if (hit.collider.gameObject.CompareTag("Target")){ // if collided with the right object...
// create replacement at same position and with same rotation:
var dead: Transform = Instantiate(replacement, transform.position, transform.rotation);
// copy position and rotation to the children recursively:
CopyTransformsRecurse(hit.collider.gameObject.transform, dead);
// destroy the original object:
Destroy(hit.collider.gameObject);
}
thanks for any help