Cloned Object does not run Scripts

Good day for all.

Well, My point is: I have created a simple GameObject which has a Renderer with a Single Sprite.
No Animations, no magics, not fancy… OK.

Secondly, i´ve created a C# Script. The most simple C# Scripts ever seen:
I have a void update method which print(“hello world”).
OK, so now a dragged that GameObject to my Project, so it becomes a “Prefab”, right?

In parallel, i´ve create an ObjectPool Script, so i can Instantiate 20 clones of my Prefabs in its start method. OK?

So, I attach this ObjectPool Script to an empty GameObject and associate my prefab as the type to be pooled.

Here i have the premisse: 1 empty GameObject which has a script to pool GameObjects which has my “Simple Prefab”, which contains a Script which prints “hello world”.

I play my “game”, what i can see that all of the clones are created in hierarquy but none of them runs my print(“Hello World”) unless for the original prefab.

It seems that the Instantiate method is not cloning my whole prefab.

Does anyone have idea about the why my Clone´s Scripts are not running? In addition: does inactive objects are still able to run their scripts??

Att,
Marcello

First, while the game is running, select one of the spawned object. Verify that the script you created is attached to the clone. If that is working, next go to the console window and make sure the ‘collapse’ button is not pressed. If ‘collapse’ is enabled, then all of your ‘hello world’ statements are being compressed into a single statement.

I am listing 3 cases that can solve your issue. one of them should work for you.

1.)I was facing same issue like bullets were cloned in my game. then I gave the bullets prefab a tag and used script with the targets. It worked for me. on collison i used this
if(other.gameObject.CompareTag (“bullet”)){
code lines
}

2.)otherwise you can use the script which is creating the prefabs clones to do something for you.
becaues when you create the clone you can use the clone to do whatever you want. so you wont need a new script for clone because some times that causes issue.

3 .) if it is compulsory in your case to attach a script with clones then put a original prefab in the scene and attach script to it. once script is attached then disable it from inspector. and your script is also cloned with the prefabs.