Skip to main content
deleted 131 characters in body; edited tags
Source Link
starikcetin
  • 5.3k
  • 4
  • 26
  • 60

I am making use of OnTriggerEnter(Collider other), is there a way to get access to the script attached to my other gameobject without explicitly writing the name of the script? my code is:

void OnTriggerEnter() { other.attachedRigidBody.GetComponent(); }

void OnTriggerEnter()
{
  other.attachedRigidBody.GetComponent<xyz>();
}

In the above code, after GetComponent and before parantheses, there are angular brackets with xyz written. Somehow, it's not visible in the code. xyz is the name of the script attached to other, but I don't want to write xyz, but rather want to find a way to make my other gameobject implicitly look for whatever script is attached to it.

I am making use of OnTriggerEnter(Collider other), is there a way to get access to the script attached to my other gameobject without explicitly writing the name of the script? my code is:

void OnTriggerEnter() { other.attachedRigidBody.GetComponent(); }

In the above code, after GetComponent and before parantheses, there are angular brackets with xyz written. Somehow, it's not visible in the code. xyz is the name of the script attached to other, but I don't want to write xyz, but rather want to find a way to make my other gameobject implicitly look for whatever script is attached to it.

I am making use of OnTriggerEnter(Collider other), is there a way to get access to the script attached to my other gameobject without explicitly writing the name of the script? my code is:

void OnTriggerEnter()
{
  other.attachedRigidBody.GetComponent<xyz>();
}

xyz is the name of the script attached to other, but I don't want to write xyz, but rather want to find a way to make my other gameobject implicitly look for whatever script is attached to it.

Source Link
NAnn
  • 339
  • 1
  • 5
  • 14

Is there a general name to refer to a script attached to a particular gameobject in Unity?

I am making use of OnTriggerEnter(Collider other), is there a way to get access to the script attached to my other gameobject without explicitly writing the name of the script? my code is:

void OnTriggerEnter() { other.attachedRigidBody.GetComponent(); }

In the above code, after GetComponent and before parantheses, there are angular brackets with xyz written. Somehow, it's not visible in the code. xyz is the name of the script attached to other, but I don't want to write xyz, but rather want to find a way to make my other gameobject implicitly look for whatever script is attached to it.