Control collision of an object, with a script linked to another object

I’ve a script linked to an object A, this script creates another gameobject B with a collider, now I would like to control the collision of the object B using my script linked to the object A, is it possible?
I can’t use the OnCollisionEnter function because it refer to the object A…

Hmm. Have you tried making a prefab for the object you’re spawning? That way you can put a script on object B itself and use the OnCollisionEnter function to accomplish whatever task you need done.

To do this you might want to:
Create a variable in your script on object A and then drag and drop your prefab into it.

public GameObject objectBprefab;

Then you just have to Instantiate the prefab into the scene using:

Instantiate.GameObject

Hopefully this helps you solve this problem! For further reading on Instantiating prefabs look here. Thank you and good luck coding!