imagination XD

realizing dream

[Tutorial] Realtime Render Animation With Unity3D


Seiten Taisei's MV Intro | ‎Wednesday, ‎February ‎27, ‎2013, ‏‎6:26:49 PM

Seiten Taisei’s MV Intro | ‎Wednesday, ‎February ‎27, ‎2013, ‏‎6:26:49 PM

That’s my first ever Realtime Render Animation. Back then I used FRAPS to record the animation in Unity, but now, I use better Sequenced PNG renderer. I found this script on Unity3D Wiki named ScreenshotMovie. But in this tutorial, let’s just use my version of ScreenshotMovie (It’s running on background, so you can play psxfin while Unity rendering). It works both on Indie and Pro. But Indie wont get an epic effect. If you use Indie but you want to get an epic effect, use After Effect.

You’ll need this

  • Unity3D
  • VirtualDub
  • Xvid Codec (Optional)
  • A knowledge on Animation (At least Level 3(You’ll need to know what is Flat, Spline, Constant, Keying, Free Smooth and something like that))
  • And Not TLDR Personality (Too long, didn’t read. :D)

Create a new Javascript, named it whatever you wanted, then attach this on MainCamera, and then REMEMBER to disable it (So you wont got lag when previewing the animation).

var folder = "ScreenshotFolder";
var frameRate = 25;

private var realFolder = "";

function Start () {
	Screen.showCursor = false;
	Application.runInBackground = true;

    // Set the playback framerate!
    // (real time doesn't influence time anymore)
    Time.captureFramerate = frameRate;

    // Find a folder that doesn't exist yet by appending numbers!
    realFolder = folder;
    count = 1;
    while (System.IO.Directory.Exists(realFolder)) {
        realFolder = folder + count;
    // Create the folder

function Update () {
    // name is "realFolder/0005 shot.png"
    var name = String.Format("{0}/{1:D04}.png", realFolder, Time.frameCount );

    // Capture the screenshot
    Application.CaptureScreenshot (name); // Use Application.CaptureScreenshot(name,2) if you want 1080HD

function OnDisable(){ enabled = true; }
  1. RT-1You have to animate the scene first, create a new Game Object, then child all objects that you want to animate. Character and NPC also able to animate using this (with NavMeshAgent), but it’s kinda very difficult. I created a special script to animate the movement of the AI using NavMeshAgent and Animator. In this tutorial, I’ll only teach you how to make a simple realtime camera animation.
  2. RT-2Select ‘Actor’ GameObject then click Record on Animation Tab (Press CTRL+6 if you don’t have an Animation Tab).
  3. RT-3You can animate everything you want (turning off gameObject, turning off a certain script, adjusting script value, everything). To animate the Camera, just change any value that you wanted. The animator will automatically key it.
  4. So, if you are saying that you want change camera, you just simply key the first position, then select camera key > Right Click  > Right Tangent > Constant, and then go for 1 frame , and then change the camera position again > Select The camera key > Right Click > Left Tangent > Constant. Repeat this step everytime you wanted to change camera position.
  5. Camera moves crazily ? Check your Position or Rotation Curves, or just set Select The Camera Key > Right Click > Flat.
  6. NOTE : Your animation clip will automatically Loop, to disable this, go to the folder where you save this animation clip and then uncheck Loop.
  7. RT-4After you finish with animating, Click Record Button to stop recording, and then Add that script to Main Camera. You need to adjust the Folder name (It’ll save to your Unity Project’s folder), and the frame rate (I usually use 24). Press Play and LET IT RENDER!
  8. RT-5The renderer will running in background, so you can do anything while Unity Render this (I play psxfin while rendering, haha yeah). Go back and check your Unity, if you believe your animation already finished render, press play again (that button above).
  9. RT-6Check your Unity Project folder, you’ll found a folder that you’ve named on Unity. That’s a large amount of PNG Sequences!
  10. RT-7Go launch VirtualDub, click File > Open Video File
  11. RT-8Open your Unity Project Folder, and then Select the First Image (Usually it’s 0002.png), then Open.
  12. RT-9Now let’s adjust the frame rate, so it wont look very lag (Default frame rate was 10)
  13. RT-10Remember to change the Frame Rate as the rate that you set in Unity (I set 24FPS)
  14. RT-11This is an optional step. You don’t want a huge video file, do you ? Skipping this step will give you 2GB Video for 40 seconds. So you’ll need to compress it using Xvid.
  15. RT-12Alright this is the final step. Click File > Save as AVI. “Hey! Wait! What about the resolution?” Ahaha, yeah. I’m sorry, I was forgot about that. The Resolution will be same as how large you render it on Unity. I use 16:9 Aspect on Unity while rendering. If you are using Free Aspect, you’ll gonna have a large letter box. “My monitor just 1360px, can I render 1920?” Sure you can! Just read back my script comment. Also, you’ll gotta be very patient when rendering 1080.

That’s just a simple camera animation. I’m tired writing very long text with slow internet, so I’ll post about Full Character Animation later. But here, I’ll give you an example of using Full Character Animation.

I don't have Motion Capture, So I have to animate non Walking motion.

I don’t have Motion Capture, So I have to animate non Walking motion.

Here's a sample to play sound. All animation event controlled by ANIMATOR CORE.

Here’s a sample to play sound. All animation event controlled by ANIMATOR CORE.

This is how my Camera Position looks like

This is how my Camera Position looks like

Also make a new Scene everytime you want to shot other location. It makes animating easier, and faster. Since NavMeshAgent only can do walk motion, you’ll need to duplicate the character (1 NavMeshAgent, and 1 just animator). I also made new Animator Controller on the character. I’ll explain what are those (Animator Core)

  • Actors[] : All walkable actors in this scene.
  • ActorsHead[] : All actors that have facial animation.
  • ActorAnimatorValue[] : Unused. Should be set like “Speed”, or “Direction”
  • ActorAnimatorValue[] : Unused. Should be like 1.0, or 0.2
  • NPCDestination[] : an empty game object tells NavMeshAgent where to go.
  • SoundBank[] : All AudioSource that available on this scene.

And this is the final product.



Started making games since 13 year old. 3D CGI Weeaboo | VFX Otaku | Anime Researcher | Indie Game Dev | VR Chuunibyou

2 thoughts on “[Tutorial] Realtime Render Animation With Unity3D

  1. gan mau nanya dong. dari cara yg pertama, aku render berhasil, tp effect windzonenya ga ada. itu gimana ya gan? makasih.


Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s