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.
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.
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.
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:
Player trips trigger box.
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.