playMaker

Author Topic: Parent Rigidbody, Child Colliders  (Read 1517 times)

abend

  • Playmaker Newbie
  • *
  • Posts: 36
Parent Rigidbody, Child Colliders
« on: July 28, 2020, 02:38:53 PM »
I've got a situation now where I have a rigidbody on the parent, and 5 children all have colliders. Previously, the parent did not have a rigidbody, but now I need it. I am using an OnCollision event, which used to give me the child's name, but now it rolls up to the parent's name. The parent has a different tag, but OnCollision doesn't care. So after clicking around for a while, I've come across the fact that this is the default function, I can understand that since in most cases you want to group some colliders for a parent. I have seen that something like this I could use:

myCollider = collision.contacts[0].thisCollider; // child collider

I was wondering if there is an action that exists to get this information before I tried to wire something up myself.

abend

  • Playmaker Newbie
  • *
  • Posts: 36
Re: Parent Rigidbody, Child Colliders
« Reply #1 on: July 28, 2020, 08:35:14 PM »
I have appended a new variable to GetCollisionInfo which is
Get Child Game Object Hit.

I use:
childGameObjectHit.Value = Fsm.CollisionInfo.GetContact(0).otherCollider.gameObject;

as I have recently read that contacts[0] uses GC, and GetContact(0) does not.

This is working well, and a small change to the existing action. I believe it will still return the correct GO even if it has no children.

curb47

  • Sr. Member
  • ****
  • Posts: 256
Re: Parent Rigidbody, Child Colliders
« Reply #2 on: July 30, 2020, 02:50:24 PM »
Cool.