Getting information from a trigger box

Hello. I’ve got a row of trigger boxes the player can enter which are meant to shoot them in a particular direction. For the coordinates, I attached a script with:

public GameObject playerTarget;

to each of the trigger boxes, and used Unity to add a gameobject to it that acts as a target. But I’m having trouble getting the location of the target from the game object so I can send the player there.

What does that mean?

You can just get the gameObject of the collision target from the parameter.

    private void OnTriggerEnter(Collider other)
    {
        other.gameObject; // do stuff with this
    }

Sorry. I’ve rephrased it. I’ve used the code I mentioned to link a GameObject to my trigger box to act as a target, but I’m having trouble getting that target’s location from the GameObject so I can send the player there.

Basically: There’s a linked gameObject on the trigger box and I want to get its location.

Can’t you just do playerTarget.transform.position?

I’m trying to get the target bit into the script. Basically, the player tripped a sensor box and I want to send the player to a game object. The gameobject is stored on the sensor box. I have the script to get from one to the other, I just can’t get the destination.

I’m not understanding, isn’t the target’s position your destination?

The destination is currently stored on the trigger box. I need OnTriggerEnter to search the trigger box for a stored GameObject so I can get the coordinates it’s meant to send the player to. Currently I have no way to get those coordinates. The script to send the player to the coordinates works fine, but I need a way to get the stored coordinates off the trigger box. Basically:

  1. Player trips trigger box.
  2. OnTriggerEnter is supposed to get the coordinates from the game object, which are stored as “public GameObject playerTarget;”. This is the step I’m having trouble with.
  3. Move the player to the coordinates.