Blender to Unreal Engine tips

Software:
Blender 2.9 | Unreal Engine 4.25

The following is a list of guidelines for preparation and export of 3D content from Blender to Unreal Engine 4 via the FBX file format.

Disclaimer:
This is not a formal specification.
It’s a list of tips I found to work well in my own experience.
* Some of the issues listed here may have already been solved


Blender Scene and model settings:

System units in Blender:
Define the scene units in Blender as:
Metric unit with 0.01 scale (centimeters)
And model your content correctly using centimeter units.
* Modeling in 1 meter units may seem to be imported correctly into UE4 but will cause unsolvable problems like a skeletal mesh physics asset having incorrect auto-generated shapes, a problem that in my experience can’t be fixed manually.

Transform:
Model your model in Blender facing the -Y world axis, +Z obviously being up (obviously for Blender).
* This way the model is aligned to Blender’s views so the front view displays the model’s front etc.
Make sure to apply your model’s transformations before export.

Armatures:
Make sure the Armature object isn’t named “Armature”.
naming or leaving the Blender skeleton named “Armature” will cause the UE4 importer to fail due to “multiple roots”.
* Also remember some weird related bug with animation scale incorrectly imported, but can’t confirm this now..
No need for a dedicated root bone in the hierarchy. the Armature object is the root of the bone hierarchy.
* See export option below

Texture baking:
Set the normal map’s green channel to -Y.
* This is not critical at all because if baked as +Y it can easily be fixed in UE4.

Metadata:
Blender custom properties import as UE4 asset metadata that can be read by editor scripts for automation purposes.
* See export option below


FBX Blender export and UE4 import settings:

I recommend saving an FBX export preset with these settings.

Optional:
I prefer the export settings to include only selected objects.
* It’s more efficient for me to select the specifics objects I want to export into a single FBX file prior to export, than to delete all the temp / reference / draft objects from the scene.
If you want to export Blender custom properties with to the FBX check the “Custom Properties” option

Axes:
Blender’s native model/world orientation is model’s forward facing the -Y axis, left side facing +X and of-course up facing +Z.
UE4’s native model/world orientation is model’s forward facing the +X axis, left side facing -Y and up facing +Z.
There are axis settings in Blender’s FBX export module, that theoretically, should be set like this:

However, in tests I did, The axis settings made no difference when importing to UE4, even when setting intentionally incorrect upside-down axes.
Maybe the FBX exporter writes these settings to metadata that the UE4 importer doesn’t read..
From my experience, what’s important is to orient the model correctly in Blender (see above), apply the transformations,
And in the UE4 import menu, check the “Force Front XAxis” option:

Geometry:
Make sure either “Edge” or “Face” is chosen in the “Smoothing” option to import the mesh’s smooth shading correctly ans avoid a smoothing groups warning on import:

Optional:
Depending on how much control you need over the mesh’s tangent space,
You may want to check the “Tangent Space” export option,
This will make Blender export the full tangent space to the FBX and make UE4 read it from FBX instead of generate it automatically.
* For this option to be supported, the mesh geometry must have only triangle or quad polys.
In the UE4 import settings, choose the “Import Normals and Tangents” option in “Normal Import Method”:

Armature:
Set “Armature FBXNode Type” to “Root”.
Uncheck the “Add Leaf Bones” option to avoid adding unneeded end bones.
Set bones primary axis as X, and secondary axis as -Z.

Animation:
Uncheck “All Actions” to avoid exporting actions that don’t actually belong to the skeleton.
* Un-related animations in the FBX can also corrupt the character rest pose in UE.
The “NLA Strips” option is useful for exporting a library of animations with the skeleton.
* In Blender’s NLA editor, activate the actions you want exported to the FBX.


Related:
3ds max & V-Ray to UE4 Datasmith workflow

Blender – Python – Access animated vertices data

Software:
Blender 2.83

The following is simple example of reading a mesh’s animated vertices data.

This example code gist

Note that accessing an model’s animated vertex locations requires reading the model’s evaluated (deformed) mesh state per frame.
For that reason a new bmesh object is initiated per each frame with the the model’s updated dependency graph.

import bpy
import bmesh
obj = bpy.context.active_object
frames = range(0,10)
get the object's evaluated dependency graph:
depgraph = bpy.context.evaluated_depsgraph_get()
iterate animation frames:
for f in frames:
    bpy.context.scene.frame_set(f)
    # define new bmesh object:
    bm = bmesh.new()
    bm.verts.ensure_lookup_table()
    # read the evaluated mesh data into the bmesh   object:
    bm.from_object( obj, depgraph )
    # iterate the bmesh verts:
    for i, v in enumerate(bm.verts):
        print("frame: {}, vert: {}, location: {}".format(f, i, v.co))

Blender – Basic time-dependent animation driver examples

Software:
Blender 2.82

To setup a time-dependent Driver in Blender, simply use the built-in frame variable.
In this example the expression:

sin(frame)

Set as a Z axis location driver for the cube causes it to oscillate up and down:

frame_driver

Changing the expression to:

sin( frame * 0.1 ) * 2

Causes the motion to be twice as high and 10X slower:

frame_driver2

 

In this example, the expression:

( pow( -1 ,  floor( frame / 30 ) )  *  0.5 ) + 0.5

Set to the cube’s Emission shader’s Strength attribute causes it to alternate between values of 0 and 1 every second (30 frames in this case):

frame_driver3

 

Related:
Blender – Create constraints quickly

UE4 – Create and Play a Level Sequence

Software:
Unreal Engine 4.24

To create animations and trigger them to play on game start:

First create a Level Sequence containing the animation:

  1. Create a new Level Sequence actor:
    Annotation 2019-12-23 164745
  2. Name the new Level Sequence and drag it to into the level:
    Annotation 2019-12-23 165833.jpg
  3. Select the actor you want to animate in the level and double click the Level Sequence in the Content Browser to open it in the Sequencer window:
    Annotation 2019-12-23 170453.jpg
  4. In the Sequencer window, press the +Track button to add a sequence track, choose the upper most option Actor To Sequence, the option to Add the selected actor will automatically appear first on the menu that will open on the right:
    Annotation 2019-12-23 170622
  5. Add the selected actor as a sequence track, expand the track’s Transform channels to reveal the Transform property you would like to animate, and click the + button for that channel to create the first key-frame:
    Annotation 2019-12-23 171623
  6. Activate the Create when channels/properties change option button:
    Annotation 2019-12-23 171932
  7. Move the time slider to a desired time for the motion and move/change the actors transform to create a new key-frame:
    Annotation 2019-12-23 172115.jpg

The Level Sequence now contains animation for the Actor, but when we play the game, the animation doesn’t play.
For the animation to play in game, we must trigger it fro a Blueprint, in this case the Level Blueprint:

  1. From the Editor Blueprints menu, choose Open Level Blueprint:
    Annotation 2019-12-23 173450
  2. In the Level Blueprint, drag the Event BeginPlay execution graph and create CreateLevelSequencePlayer node that will follow it:
    Annotation 2019-12-23 173759
  3. Drag the CreateLevelSequencePlayer node’s Return Value output and create a Play node that will be executed after it and receive it’s output:
    Annotation 2019-12-23 173854
  4. The Level Blueprint now has instructions to play a Level Sequence,
    but it’s not yet specified which Level Sequence to play:
    Annotation 2019-12-23 173929
  5. In the Variables list on the left, press the +Variable button to create a new variable and name it:
    Annotation 2019-12-23 174757
  6. With the new variable selected, in it’s details on the right, press the Variable Type button, and locate Level Sequence – Object Reference type:
    Annotation 2019-12-23 174932.jpg
  7. The Level Blueprint now contains a variable named seq of type: Level Sequence – Object Reference:
    Annotation 2019-12-23 175200.jpg
  8. Drag the new variable to the Blueprint and choose Get when placing it:
    Annotation 2019-12-23 175536
  9. Connect the variable’s output to the Level Sequence input of the CreateLevelSequencePlayer node:
    Annotation 2019-12-23 175609
  10. With the variable selected, in the details panel on the right, select the Level Sequence object it will be referencing:
    Annotation 2019-12-23 175627
  11. Press Compile and save the Level Blueprint:
    Annotation 2019-12-23 175646

The Level Blueprint now has instructions to play the desired Level Sequence when the level begins playing so a the animation we created plays when we hit play game in the editor:
Annotation 2019-12-23 180500

animseq.gif

 

Related:
UE4 Camera Animation

Blender Skeleton (Armature) Mirroring

Software:
Blender 2.8

To mirror a skeleton (Armature) in Blender:

  1. Create bones for one side of the rig and name them with “.L” for Left or “.R” for right.
  2. Select all the bones on that side.
  3. In Armature Edit Mode choose:
    Armature > Symmetrize

Blender will create mirrored copies of all the bones with respect to the Armature origin and flip their names to names ending with the opposite side.

  • When editing properly symmetrized bones,
    The X-Axis Mirror tool option will simultaneously update both sides of the Armature to maintain symmetry.

Untitled-1

 

Untitled-3.jpg

Untitled-4

 

3ds max – Use the Particle-Flow Lock/Bond test to have particles move on a surface in

Software:
3ds max 2019

The Lock/Bond Particle Flow test can be used to have particle movement restricted to a surface.

lock_bond.gif

This example shows a simple setup in which the particle teapots have a Speed operator set to Random 3D mode that causes them to move in random directions,
While at the same time the Lock/Bond test forces them to ‘stick’ to the surface:

Untitled-1

 

Python for 3ds max – Animated Mesh

Software:
3ds max 2019

This is an example of procedurally animating a mesh’s vertices via Python script.

Vert_Anim.gif

Notes:
1. The model has to be converted to Editable Mesh before the script is run.
* unless the scrip will be extended to do it.
2. The model must be selected for the script to work.

import MaxPlus
import math
from MaxPlus import INode
from MaxPlus import TriObject
from MaxPlus import SelectionManager
from MaxPlus import Factory
from MaxPlus import Animation
from MaxPlus import Point3
from MaxPlus import Control

ticks_frame = 160

#Selection
sel = []
for n in SelectionManager.Nodes:
    sel.append(n)
node = sel[0]

#Setup Controllers
obj = node.GetObject()
Tri = TriObject._CastFrom(obj)
mesh = Tri.GetMesh()
num_verts = mesh.GetNumVertices()
mesh_anim = obj.GetSubAnim(0)
pnt_ctrl = Factory.CreateDefaultMasterPointController()
node.AssignController(pnt_ctrl,1)
for i in range(num_verts):
    bezp3 = Factory.CreateDefaultPoint3Controller()
    bezp3.SetPoint3Value(mesh.GetVertex(i))
    mesh_anim.AssignController(bezp3,i)

#Animation
Animation.SetAnimateButtonState(True)
for t in range(100):
    time = t * ticks_frame
    Animation.SetTime(time)
    mesh_anim.AddNewKey(time,0)
    for i in range(num_verts):
        vert_anim = mesh_anim.GetSubAnim(i)
        vert_ctrl = Control._CastFrom(vert_anim)
        vert_val = mesh.GetVertex(i)
        vert_val.SetZ(vert_val.GetZ() + math.sin(((Animation.GetTime()*0.5)/(ticks_frame))+i))
        vert_ctrl.SetPoint3Value(vert_val)
Animation.SetAnimateButtonState(False)

* note that when copying and pasting a script from this example, the indentation may not be pasted correctly.

Related:
Python for 3ds max – Mesh manipulation

DJV Player

Software:
DJV View 1.2.3

A highly effective and useful open source frame sequence player, indispensable in an animation studio.

DJV allows smooth cached playback of float EXR file sequences (and many other formats) at a variaty of frame-rates, image / pixel diagnostic tools, view EXR layers, quick mp4 export, and more.

Download DJV here:
http://djv.sourceforge.net/

Untitled-1

Blender – Bake NLA animation

Software:
Blender 2.79

When you wish to bake your NLA animation mix into one Action,
The Bake option in the Animation tab will not work.
The way to do this is to:

  1. Select the object in Object Mode.
  2. Press Space and type ‘bake
  3. Choose Nla: Bake Action
  4. In the Bake dialog, select Pose, deselect Only Selected, and press OK.
  5. After the process, the Armature will have a new action that is the baked animation.

Untitled-2

Untitled-3

Blender – Bake rigid body physics to Keyframes

Software:
Blender 2.82

  • I always forget this, try to do it through the regular animation baking option and get frustrated that it doesn’t work…

When you want to bake an object’s Rigid Body physics simulation to regular Keyframes:

  1. Select the wanted objects.
  2. Press F3 to open the command search floater,
    Begin typing: bake to keyframes to Locate the command:
    Rigid Body: Bake To Keyframes and select it.
    Note:
    The command will appear only if objects with rigid body physics properties are selected.
    Annotation 2020-05-17 154351
  3. Set a frame range for the bake and press OK:
    Annotation 2020-05-17 154413
  4. The physically simulated motion is recorded to keyframes:
  5. Annotation 2020-05-17 154458

 

Related:

  1. Bake NLA animation
  2. Cloth to shape keys