A question about collision between 2 gameobjects

Hi,
I very well know that in order to run a script it has to be attached to a gameobject ( except the scriptableobject class ). My problem is as follows:
I have a main script file for my in game scene, in which i create gameobjects which are to be used in that particular scene. So, I can attach it to either an empty game object or to the main camera.
However, the problem comes how to check collision detection between 2 game objects which are created from within this script. For e.g. - I have created a sphere and a cube ( as a floor ) from within the script. All things work fine. But I am not able to get the collision detection between these 2 objects as according to the OnCollisionEnter function documentation it is related to the gameobject to which the script is attached.

So, what can I do if I have created gameobjects from within a script and want to check collision detection between them?

Thanks

Well is the OnCollisionEnter script attached to the new gameObject that you created (IE the sphere), or is it part oft the script that simply creates the object (because if thats the case it will not work). So what you want to do is create an instance of the sphere that already has the collision script attached to it (IE a prefab).

No actually the scenario is that i have a script ( which is attached to an empty game object OR main camera ) and I have created a sphere and a cube from inside the script. And now I want to check collision between these 2 game objects. And as far as I know OnCollisionEnter can be used only for the game object the script is attached to.

Aiursrage2k’s suggestion is good. Write a generic script. Assign it to a prefab and give that prefab All the features / properties it needs and instantiate your objects from the prefab.

That way each instance has its assigned script. Voila.

Good luck

/Chris

thanks guys for the advice. I will surely try this out. Thanks once again.