Teleporting to a Destination WITH a Fade in + out

what I am looking for is, for my ‘Player’ to hit a Trigger, which will cause the Player to teleport to another location. I am got this all down and scripted, but what I am having trouble with is having the Scene fade to a Colour of my choice, and then fade out to the new destination.

Now obviously, the player is going to have to teleport AFTER it has faded to the colour. or else it would just look like he teleports straight away and then the fade comes in afterwards. I have tried a few things, yet none of them work.
Here is my current Teleport script:

    var destination : Transform;
    function OnTriggerEnter(other : Collider) {
    if (other.tag == "Player")
    var startPosition = other.transform.position;
    other.transform.position = destination.position;
    var moveDelta = other.transform.position - startPosition;
    Camera.main.transform.position += moveDelta;

Here is also a Fade script which may or may not work with what I want to achieve:

    alphaFadeValue = Mathf.Clamp01(alphaFadeValue - (Time.deltaTime / 5));
    GUI.color = new Color(0, 0, 0, alphaFadeValue);
    GUI.DrawTexture( new Rect(0, 0, Screen.width, Screen.height ), blackTexture );

Good luck Everyone, and Thankyou :slight_smile:

You need a teleport method where you perform the move of the player.

Then when you enter the collider you start a coroutine that fades out the scene.

Once the color reaches a defines value, which is black enough to hide the screen, you call the teleport and start the fade in.

var myDelegate : Function = Teleport(){//What you do to teleport};

function OnTriggerEnter(other:Collider){

function FadeInOut(delegate:Function){
   //Your fading
      //Decrease alpha
   while(color < alphaValueUp){
      //Increase alpha

I am not familiar with UnityScript delegate so try it and report if it works.

What it does is that myDelegate is a “function pointer”, a variable that refers to a method. We can pas the method just like a variable to the coroutine.

The coroutine first performs the blackout and when black enough calls the delegate that actually calls the method indirectly.
After that, we get back to normal.

You may want to also disable input during that part to avoid having your guy goign around when blacking out.