Creating basic Blender Animations and exporting into UT3! (UDK)
Here's a long very rough tutorial of how to perform some, rather basic, animation within Blender and export it into Unreal engine. (in this case UT3!!)
Notes before reading!!
I'm a complete novice in using Blender! The following tutorial is all I know about using Blender! I also have no clue on what the various windows are called! (hence all the pics!)
There is no standard formatting for this tutorial...it's all over the place...but I hope it all makes sense!
Tutorial is based around animating a custom weapon and using those animations within UT3! It can be a guide or any custom animated meshes though!
Tutorial is using the most recent version of Blender. eg.. version 2.69!
Info grabbed from various sources on the web!
I'm sure there's probably better ways to do this but this is how I know to do it...at this time!
I’ve written this tutorial to hopefully help others, who are lost like I was, with the basics of using animations within Blender!The purpose is to be a guide to achieve basic working animations within Unreal Engine! UT3 in this case, but UDK should be quite similar I'd expect!
Blender windows grab focus when your mouse cursor is over them!! (make sure you remember that!!)
Things required for following this tutorial!
You already have a model in Blender that is rigged!! (Cheers to mAlkAv!An for supplying the rigged model in this tutorial!)
You have 'working' unrealscript code for your weapon!(or whatever model your working on!)
UT3(probably UDK too) uses a default set of sequences for weapons!
You should create these sequences as a minimum to have all the default animations!
They are:
WeaponIdle
WeaponFire
WeaponEquip
WeaponPutDown
You can create others but you will need to call/reference them in your code to use them!
Eg.. I use ‘WeaponAltFire’ at one point in this tutorial as I use an alternative animation for the secondary fire of the weapon!
Now go start Blender!!
Setting up the psk/psa export function!
Goto the file menu and select User Preferences.
Click on the Addons tab.
Scroll down until you see the Import-Export: Export Unreal Engine Format(.psk/.psa) and Click on the check box.(as shown in the pic below!)
Click the close button on the window to continue.
-=-=-=-
Now load your model into Blender.
Optional - Within the 3D ribbon menu click view and select 'Toggle Quad view' to get your 4 viewpoints.
Preparing a Sequence! (required for each sequence!)
Enter Pose mode by selecting 'Pose' within the tree listing on the menu on the right hand window.See 1 in the pic below.
You should now be in Pose mode! See 2 in the pic below! IMPORTANT:Make sure you always stay in Pose Mode while animating!!
-=-=-=-
Next go to the timeframe ribbon and set it to ‘Action Editor’ mode. See 1 in the pic below!
Now move across to the sequence subsection and press the + button to add a new sequence! See 2 in the pic below!
NOTE:Scroll your mouse wheel (while your mouse cursor is on the ribbon) if you can’t see the sequence subsection!
-=-=-=-
Highlight the new sequence name and name it to your sequence as shown as 1 in the pic below. Eg.. WeaponEquip.
Press the F button to ‘lock in’ the sequence (not exactly sure why myself) as shown as 2 in the pic below.
-=-=-=-
Animating your sequence! (required for each sequence!)
At the bottom of the Blender window you have the timeline for your sequence.You can type in how long your sequence goes for!Remember to set the length of your sequence. See 1 in the pic below.
When creating/editing a key frame you can go to the frame you’re working on by typing the number into the current frame subsection as shown as 2 in the pic below.
Move your mouse cursor over any of the visual/3D viewpoints(can’t remember the exact name) and press the a key on your keyboard to select all the current bones, as shown as 3 in the pic below.
NOTE: I assume for more detailed animating you will select only the bones you require to animate.(not covered in this Tutorial)
-=-=-=-
Now before you start animating anything you should create key frames at the beginning and end of your animation, while the model is sitting in its original location.This way the animation will loop smoothly! You can create these key frames by setting the current frame to the beginning frame.Next move your mouse cursor over one of the visual viewpoints and pressing the i key on your keyboard!A yellow line should appear on the timeline window to show there’s a key frame created there.Do the same thing for the last frame of your sequence!
-=-=-=-
Now onto creating your animation!
Set the key frame interval that you want to modify.See 1 in the pic below.
Now move your mouse cursor into one of the visual/3D viewpoints. IMPORTANT:Keep your mouse cursor within this screen when using any keyboard shortcuts!!
Press the i key on your keyboard to create the initial key.
See 2 in the pic below for this part - Now you can use the xyz widget to move the model to the desired location you require for your animation.You can also press the r key on the keyboard to rotate the model on whatever axis you require - depending on which screen your cursor is currently on.If you rotate the model press the enter key on the keyboard to set that rotation.
IMPORTANT:Now, while the mouse cursor is within the viewpoints, press the i key to lock in the new co-ordinates of the model.
You can now use the timeline window to play the current key frames to make sure the one you created worked OK.If it doesn’t then you probably forgot to press iafter modifying the key frame.
NOTE:If you need to delete a key frame, while the cursor is within a viewpoint, press Alt+i on your keyboard to delete the currently selected key frame.
-=-=-=-
Now go create all your required frames!
Once you have finished setting all your required key frames for this animated sequence you can now move onto the next sequence. Don’t forget to save every now and then too!
To create the next sequence you create another as you did for the 1st sequence. See pic below for a reminder!
-=-=-=-
-- Edited by Lord_PorkSword on Friday 6th of December 2013 04:03:35 AM
Possibly optional for this part! - Go to the File Menu then select Export then Skeleton Mesh / Animation Data (.psk/.psa), as shown in the pic below!
-=-=-=-
Now press the Esc key on your keyboard to go back to the main screen.I’m doing this just to get the export panel up!
On the left hand side of the Blender window you should hopefully have the Pose Panel available.Scroll down until you see the exporting subsection.See pic below!
-=-=-=-
Within the UDK Export section choose what you want to Export.Mesh & Animation or just the Animation!See 1 in the pic below.
Next click on the Update Action Set(s) button to display all your sequences. See 2 in the pic below.
Next select the animation sequence(s) you want to export.Tick both the Match and Export fields for each sequence. See 3 in the pic below.
Next Click the Export button! See 4 in the pic below!
-=-=-=-
Optional: I recommend toggling the console on as it can be helpful to confirm your animations exported successfully!See pic below!
If the console shows that 0 animations were exported then you’ve done something wrong!Yes you! :P (I’m sure I covered everything correctly so far… :x)
-=-=-=-
Things to check if you had no animations exported:
You were animating while Pose Mode was active!
You saved all your key frames correctly.
You selected animations to be exported!
Assuming everything went well and your animations were exported correctly it’s now time to go into UT3 (or UDK).
-- Edited by Lord_PorkSword on Friday 6th of December 2013 03:36:45 AM
If you already have an existing package that has your model then ignore this section!
Go into the Content Browser, click the File Menu then select Import.See pic below!
-=-=-=-
Navigate to your .psk file and click OK.
Next give your name a package. See 1 in the pic below.
To keep with Unreal conventions I’m calling this package WP_MyWeapon.
Also name your Weapon Model! See 2 in pic below.
-=-=-=-
Importing the Animations!
Navigate to your package!See 1 in the pic below.
Next right click within the package main window and select New Animset.See 2 in the pic below.
NOTE: In UDK I believe you can right-click on your model and create an Animset off that!
-=-=-=-
Give your Animset a name, as shown in the pic below!
-=-=-=-
Now you’re in the Animset Editor.
While within the Mesh tab make sure your weapon model is selected.If not Click the button and locate it!See 1 in the pic below.
-=-=-=-
Next select the Anim Tab, as shown as 1 in the pic below.
Make sure your AnimSet is selected, as shown as 2 in the pic below!
-=-=-=-
Next go to the File menu and select Import PSA.See pic below!
Navigate to your exported Animation sequences and select them and click OK.
-=-=-=-
Now on the AnimSet editor your imported Sequences should be listed.See 1 in the pic below.
You can preview that they are working by using the controls as highlighted by 2 in the pic below.
-=-=-=-
You will notice that the animation time is extremely long even though your animation is quite short. ( [1702] frames is shown in this tutorial)We need to trim those extra frames!
Using the play and timeline subsection locate the end frame of your animation and leave it at that point.See 1 in the pic below.
-=-=-=-
Next click on the AnimSequence menu and select Remove After Current Position.See pic below.
This will trim your animation down to it’s real length.You can now play the animation but may find it’s extremely quick.
To fix this we need to turn off animation compression.
-=-=-=-
Go to the Animation Compression Menu and select…Animation Compression!See pic below.
-=-=-=-
Next select Bitwise Compress Only, as shown by 1 in the pic below.
In the RotationCompressionFormat field choose ACF_None. See 2 in pic below.
Now click on the Apply To Sequence button.See 3 on the pic below.
Click OK on the window that pops up.
-=-=-=-
Now your animation should play at normal speed. You can now trim off any excess frames that are still active.
Do this for all your sequences!
Calling your animations in Unrealscript!
Now it’s time to tell Unreal Engine that you have custom animations for your model.
While you have your package opened in the Unreal Editor right-click on your AnimSet.Select Copy Reference. See 1 in the pic below.NOTE: This copies the exact pathing to your Animset within your package.
-=-=-=-
Next navigate to your .uc UnrealScript files for your weapon and open the script for the weapon itself.Eg.. UTWeap_MyWeapon.uc, as shown in the pic below.
-=-=-=-
Now under the default properties section of your coding find the subsection that defines your skeletalmesh and Animset.See 1 in the pic below as an example.
Highlight the text within the two ‘ and press CTRL+v to paste the AnimSet reference you just copied from the Unreal Editors Content Browser.It should look similar to 1 in the pic below.
-=-=-=-
Save the script and compile your code!
Assuming that everything went OK(..and I didn’tforget anything…), your animations should now be working in-game!
OPTIONAL:If you created, for example, a custom AltFire animation you can reference that animation sequence within your coding as well.See 2 in the pic above for an example!
Testing ingame!
After compiling your code remember to copy the updated .upk package and the .u script file to the ‘usual’ published directories within the UT3(UDK) directories!
Now I hope that all made sense!
-- Edited by Lord_PorkSword on Friday 6th of December 2013 03:40:51 AM
Here are some notes for anybody interested in this topic:
Once a mesh is bound to an armature you can switch to pose mode from this drop down menu with the armature selected: http://www.abload.de/img/posemode01ryuvk.png The only thing to remember is that this is only available for the armature/skeleton but not the mesh itself.
An armature with multiple bones usually has a herachy which means the bones are parented to each other, a parent bone can have multiple childs and those childs can have childs on its own. If you select a parent bone to rotate or translate, all of its child bones will move along with it.
As mentioned in the tutorial you should set a start and end keyframe first of all. For a looping animation it's important to make the actual animation sequence one frame shorter than the range between these keys. Otherwise there will be one frame played twice which will break the cycle. http://www.abload.de/img/loopanim01bmuvm.png
For more control over you animations, espacially the transition between keys, look into the F-Curve editor. By default blender is using a bezier curve which is fine but sometimes you'll need a linear transition, e.g. a rotating wheel. http://www.abload.de/img/animcurves01gyukf.png
This is a perfect summary! I'm an absolute novice to animating (and not really a skilled modeller, though I intend to work on that) so this will come in very handy! I didnt work with this tutorial yet, but once the time comes, I'll surely let you know if there are any questions on my end and how to make it better for absolute animation newbies in case some parts are hard to understand. But knowing your tutorial writing skills, I doubt I won't understand it.
You will notice that the animation time is extremely long even though your animation is quite short. ( [1702] frames is shown in this tutorial) We need to trim those extra frames!