Inherite a script to a child

I have created a parent which defines only the behaviour of it’s childs. The childs contain the colliders,models,etc. Now I want to apply my scripts from the parent to the childs so that they behave like the parent. I thought that every component from the parent is inherited to the childs. But it isn’t so. How can i do this without copying the script component from the parent into the childs?

In the Hirarchy it looks like this:

Parent (containes scripts)

  • Child1(containes model…)

  • Child2(containes another model…)

Do i have to modify the scripts with any keywords?

There’s no such thing as inheritance between game objects in the hierarchy. If childs inherithed components from the parents then you couldn’t make a sphere a child of a cube, since the sphere would also inherit the MeshRenderer that draws a cube.

If you want the childs to act like they have the component you have to add that component to them, or add some reference to the childs on the script, so the parent can do whatever it does to the childs too.

The only thing that’s kind of inherited is the position, rotation and scale, but it’s not actually inheritance like objects inheritance, it’s how a parent-child relation funcitons in any 3D environment; when the parent moves, the child moves with it.