boss根节点上挂RigidBody2D(且boss根节点以下任何子节点均不挂RigidBody2D),boss腿部骨骼节点挂collider2D,标签为"bossLeg",boss头部骨骼节点挂collider2D,标签为"bossHead"。

则,当boss的leg或head与其它物体发生碰撞时,可以通过coll.attachedRigidbody.transform获得boss根节点,如下:

void OnTriggerEnter2D(Collider2D coll){

  if(coll.gameObject.tag=="bossLeg"){

    Transform bossRoot=coll.attachedRigidbody.transform;

  }else if(coll.gameObject.tag=="bossHead"){

    Transform bossRoot=coll.attachedRigidbody.transform;

  }

}

05-11 21:59