Delay Trigger Event By 2 Seconds?

Hi.

I want to make it so that when my character collides with a trigger, it teleports after two seconds. I got the teleportation feature working, but its instant, which is really annoying.

Can someone help me delay it?

Thanks.

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

[Serializable]
public class ActivateTriggerEvent : UnityEvent<GameObject> { }

public class ActivateTriggerOnEnter : MonoBehaviour
{
    public bool m_sendColidingObject;
    public bool m_filterTriggerObjects;
    public int[] m_allowedObjectID;

    public ActivateTriggerEvent m_activateTriggerEvent;


    public void OnTriggerEnter(Collider other)
    {
        {
            if (m_filterTriggerObjects)
            {
                ObjectID otherID = other.gameObject.GetComponent<ObjectID>();
                if (otherID)
                {
                    for (int i = 0; i < m_allowedObjectID.Length; i++)
                    {

                        if (otherID.m_iD == m_allowedObjectID*)*

{
Activate(other.gameObject);
}
}
}
}
else
{
Activate(other.gameObject);
}
}
}

private void Activate(GameObject other)
{
if (m_sendColidingObject)
{
m_activateTriggerEvent.Invoke(other);
}
else
{
m_activateTriggerEvent.Invoke(this.gameObject);
}

}

}

I assume that your Activate function is the one teleporting the object, then you can do an Invoke with 2 second delay.

Invoke("Activate", 2);

If not then you could put the teleporting code into a new function and Invoke.
If you need the parameters with the function then you could start a coroutine.

public void OnTriggerEnter(Collider other) {
        if (conditions) {
                StartCoroutine(Activate(parameters));
        }
}

private IEnumerator Activate(parameters)
    {
        yield return new WaitForSeconds(2);
        teleporting code
    }

hope this helps