De-attach child from parent and remove from animation

Hi All!

I have a GameObject with some child objects and a animator controller for parent object, in animator I move childs by curves and on keypress I need to deattach 1 child object from parent and this child should not be used in animation any more.

I do transform.parent = null for child and there are two cases:

  1. if child do not have RigidBody2D it appears at coordinate center and update position by animation in keypress
  2. if child have RigidBody2D it appears at coordinate center and still move by animator

so how to fully deattach child and remove them from animator process?
and leave deattached child on old world position?

P.S child should be with rigidbody2d all time

version 4.5.0f6

thanks

I think that i find answer, use a Animator.Rebind

I found this function we use helps to resolve this issue

public static void RemoveObjectFromAnimator(GameObject gameObject, Animator animator)
		{
			Transform parentTransform = gameObject.transform.parent;
			
			gameObject.transform.parent = null;

			float playbackTime = animator.playbackTime;
			
			animator.Rebind ();
			
			animator.playbackTime = playbackTime;

			gameObject.transform.parent = parentTransform;
		}