How do child objects work with tags?

14_pb_cu2

#1

So currently im trying to make a 2 player game where they joust it out with their rocket heads like rams and ive made a complete new rocket and i was wondering how can i make it so that only the rocket head kills the other player and not the entire body. Ive tried making the head in the prefab a death tag but it doesnt read it when i crash it into another rocket but when i marked the entire prefab rocket death tag it works but thats not what i want because they ships will die to any part of the rocket.

And then when i call the entire object death it works.


#2

Hi Jayy,

What is “the other player”? Aren’t the players represented by “entire bodies”?

The Rigidbody collects the messages sent by the colliders attached to the children and acts as a single collider.


See also:


#3

So the red rocket is called player1. and it has child object. One of the child objects being the head or (Jousthead) is what i tagged as death so that when the other rocket hits this head and just the head its the same as colliding with an obstacle and dies but it seems like the death tag on the jousthead is wrapped around the parents tag so nothing happens. How do i make it so that my childs tag gets called if thats possible? I would assume the only way is to unchild my jousthead but i dont know how to make it so an unchilded object sticks to another object.


#4

So far what ive done is given the joust head a rigidbody and that works but the problem is that it moves or if i freeze rotations and everything it still pushes into the rocket makiing it die if it collides head first with something. so basically what i want to do is working i just need the child object jousthead not to move at all when colliding with something. i already froze the positions but it still rotates when collided with something

so far ive worked around it by changing the cubes into spheres so the rotation wont matter but idk how good doing this will be in the future.


#5

You could try the following:

  1. Duplicate the “head”. Remove the MeshRenderer and the MeshFilter so you have a Collider only.

  2. Create a new Layer (top right corner of your Inspector), name it “Head” or whatever makes sense.

  3. Go to Edit > Project Settings > Physics and have the Head layer interact with the Head only.

  4. Add a new script to the head game objects and destroy the parent game object if a collision happens. Due to the layer, the other object will always be a “head”.

  5. Depending on the shape of your rocket, you could remove the collider from the visible head and make the collider of the “body” a bit higher so it covers the head, too. This is a little optimisation.

I don’t know if this will work. In theory, it could.


See also:


#6

i think that would work. changing the cube into a sphere worked out so the rotation doesnt matter anymore. thank u for the helpful links.


closed #7

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.