Ridzzzz
Ridzzzz

Reputation: 31

Getting the trigger Object [PONG Game]

i was making a pong game but i am coming across a problem. When my ball (sphere collider) collides with one of the side walls (Box collider - trigger object), i want to know which wall it collided with (i put that tag in both walls). The problems is, OnTriggerEnter() method only tracks the object that is not the trigger. How should i get the information on which wall my ball collided with? I need to specificily know whether it was wall a that the ball collided with or was it walla b that the ball collided with. Any help would be greatly appreciated.

Upvotes: 0

Views: 79

Answers (1)

cjf93
cjf93

Reputation: 317

You have the gameobject inside the collider

void OnTriggerEnter(Collider other) {
    Debug.Log(other.gameobject.name);
}

Upvotes: 1

Related Questions