Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Stop Motion Camera Effect

Discussion in 'Scripting' started by ravsters, Sep 10, 2013.

  1. ravsters

    ravsters

    Joined:
    Jan 18, 2008
    Posts:
    30
    I'm trying to achieve a stop motion effect similar to those claymation movies of the 50's. I seem to be running into a problem though.

    I'm taking a "snapshot" of the scene then waiting till enough time has passed (framerate speed), then replacing that snapshot with a new one... over and over.

    The script seems to be working, BUT there is kind of a stuttering effect. It seems as if the image that is getting snapshotted, is blank. (All I see is grey)

    Here is the script. Let me know if you guys notice anything funky. Thanks!

    Code (csharp):
    1. var frameRate:float;
    2.  
    3. private var nextFrame:float = 0;
    4.  
    5. function OnRenderImage(source:RenderTexture, dest:RenderTexture){
    6.     if(Time.time >= nextFrame){
    7.         Graphics.Blit(source, dest);
    8.         nextFrame = Time.time + (1/frameRate);
    9.     }
    10. }
     
  2. Digital

    Digital

    Joined:
    Feb 6, 2011
    Posts:
    182
    You can do it with OnGUI function, take a screen snapshot and use GUI.DrawTexture. Update the image every 0.2 seconds and display it again. And everything else behind the image is working normal.
     
  3. ravsters

    ravsters

    Joined:
    Jan 18, 2008
    Posts:
    30
    Thats an good idea.

    However, the script that I have above should be doing that exact same thing. O.O I took a deeper look into it and it seems that the "RenderTexture" isn't getting saved and this causing a stuttering effect. It looks as if nothing is being displayed during the time when it should be. D:
     
  4. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190