Freezing the Current Frame

I am looking for a way to freeze the current camera frame. It is for a local multiplayer game, so there will be four cameras in the scene. I don’t want every player’s screen to freeze at the same time, so I can’t use Time.timeScale. The screen freeze happens for several seconds when a player dies, but of course to other players the game keeps going. How would I just freeze the current frame of a single camera without using timescale?

Much thanks Unity Community! :slight_smile:

First, you need to travel back to 1981 and hire the J Geils Band. They have a complete solution for this problem.

Second, and more seriously, what you are looking for is called a “RenderTexture.”

With a RenderTexture, you essentially “Capture” the current frame contents to a Texture2D image, then replace what the player is seeing with that image, essentially freezing what they are looking at because it hides everything behind it.

This also lets you add other effects to the image, like a slow bleed-down to red (such as Red Dead Redemption’s pause screen), or a slow fade to black and white (like GTA4 and GTA5 “Wasted!” screens).

Look up RenderTextures and “capturing current screen to render texture,” and see how all that works. It’s a bit fiddly to set up, but it will do what you are looking to do, I believe.

1 Like

So I gave it a shot, but it doesn’t appear to be doing anything. All the code is being reached and executed, I checked for that. I am creating a new render texture, assigning it to the camera, making the camera render out a frame, clearing the target texture, and then using Graphics.Blit to render the RenderTexture to the screen.

void Update()
    {

        if (Input.GetKeyDown(KeyCode.Space))
        {
            StartCoroutine(TakeScreenShot());
        }

        if (rt != null) { Graphics.Blit(rt, (RenderTexture)null); }
    }

    public IEnumerator TakeScreenShot()
    {
        yield return new WaitForEndOfFrame();
        rt = new RenderTexture(Screen.width, Screen.height, 32);
        Camera.main.targetTexture = rt;
        Camera.main.Render();
        Camera.main.targetTexture = null;
        yield return null;
    }