Instantiated objects accessability


In my game, I can "shoot" balls with instantiate function in the script, that is attached to my Character Controller.

To Character Controller is attached another script, which Im trying to use to check if the ball hit the player. I have 2 versions, but they dont work. I think its because of I can do this check only to original Ball and not to its copies. But I dont know how to access them :(


void OnControllerColliderHit(ControllerColliderHit hit) {
    if( == "Gule")


public Transform Gule;

void OnControllerColliderHit(ControllerColliderHit hit) {
    if(hit.gameObject == Gule)

Thank you for your ideas! Erhan

Try using tags instead.

Every object is different. Storing a reference to one ("public Transform gule") only references that specific one.

When an object is created through Instantiate(), (Clone) is added to its name.

The best way to do this is to give the balls a unique tag or a unique component. You can then use

if ( hit.gameObject.tag == "Tag" )


if ( hit.gameObject.GetComponent( ComponentName ) )