i want to use childoject collider in parentobject script
public childobjectcollider collider
void OnCollisionEnter2D(Collision2D coll)
{
if (coll.gameObject.tag == “ground”)
{(if childobjectcollider hit coll)
{
life++;
}
}
i want to do it all in one script,
You should put your collision event in a script on the child object.
Child object with collision script on:
OnCollisionEnter2D(Collision2D coll)
{
if (coll.gameObject.tag == "ground")
{
transform.parent.GetComponent().AddLife();
}
}
Let me know if I’ve misunderstood what you want to do.