Teleporting separate objects

I’m trying to teleport an object from place to place, but with a separate trigger collider located somewhere else in the game. In other words, I’d like the character to trigger a collider and then have a another different object teleport from one place to another. Is this possible?

Of course it’s possible!

So I guess that your goal is: When the player enters a trigger, a certain object would teleport itself to another location? There are tons of ways to do this!

first you’ll need to add a script to your Trigger that detects if the player is in. Define your player tag to ‘Player’ and add these lines to the script:

public bool playerIsInTrigger;

public void OnTriggerEnter(Collider other)
{
    if (other.tag == "Player")
        playerIsInTrigger = true;
}

public void OnTriggerExit(Collider other)
{
    if (other.tag == "Player")
        playerIsInTrigger = false;
}

Then add a script to the object that needs to teleport itself if the required condition is true! Example:

[Tooltip("The place where the object will teleport")]
public Transform teleportTarget;
[Tooltip("The Trigger containing the script")]
public ScriptName triggerToCheck;
[Tooltip("True if you want the object to come back at initial position if player is not in trigger")]
public bool teleportBack = false;

Vector3 initialPosition;

public void Start()
{
    initialPosition = transform.position;
}
public void Update()
{
    if (teleportTarget == null || triggerToCheck == null)
        Debug.LogWarning("Please drag and drop the proper values!", gameObject);

    //If the object teleports itself only one time
    if (triggerToCheck.playerIsInTrigger)
    {
        transform.position = teleportTarget.position;
    }
    else
    {
        if (teleportBack)
            transform.position = initialPosition;
    }

}

Is that what you were looking for?

Thank you M-G-Production, this may be what I’m looking for! I’ll give it a try and get back to you.