Bezier Curves from Blender to UE4 Splines.

Hey everyone!

Recently, I hit a bit of a problem whilst working on a little project of mine, for some context this project involves tanks! (the vehicle).

I’ve been through several iterations and had numerous prototypes for handling the tank tracks, coming up with a simple and fluid workflow that achieves the desired results I want and I’ve finally decided to use splines to build the basic “track loop” then create some instanced static meshes and attaching instances along the length of the spline for the track segments.

So far has worked out great, it’s fast and the results are quite nice and currently, it’s all being dynamically generated based on a set of sockets I configure in the mesh, however, as they’re being dynamically created, there’s often issues with the in/out tangents on the spline points resulting in the track segments clipping too much into the floor and various other issues so I have to go back and “fine tune” the tangents each time I regenerate the track loops, this is time consuming and awfully tedious.

Preview of the issues I’ve run into with the tangents on the lower portion of the tracks:

I realized there had to be a better way… and there was! Instead of dynamically generating my splines, I can just create a bezier curve in blender directly with the tank models and include that as part of the export process (since a bezier curveĀ and UE4’s splines are functionally the same), I’ve created a little blender python script that will export the positions and tangents for the curve’s points to a CSV which I can then import it into UE4 as a DataTable, from this data I can then create my track splines.

With a little help from THIS live training video by Alan Noon from Epic Games detailing the same process but for exporting from 3DS Max, I was able to get my spline perfectly replicated in the engine as you can see below.

Preview of a spline in UE4 (left) created based on a blender bezier curve (right):

I felt like this is worth sharing so I have added it to my Gumroad with a set what you want to pay price starting from $5 (NOTE: This price includes any updates and should you need it, Discord support), all the blueprint data (see Note#1) needed the replicate this (with the DataTable/Spline from the example in my image) and the blender script (see Note#2) to export the currently selected curve to a csv are provided in the zip, it’s not 100% perfect and is best suited for splines that loop over themselves in a vertical direction (with flat splines on a horizontal axis, you can just rotate the individual points 180 degrees and they work correctly), it will likely need some modifications for other use cases, but feel free to make any edits you like to suit your uses.

Click this button and a Gumroad window will popup where you can grab the files.
I want this!

To use the files, simply copy the Content folder included in the zip to the root of your UE4 project (the folder containing the uproject), the script is run from within blender itself, simply setup a python console window and then paste the contents of the script in and hit enter a couple times (It will create a csv file in the director of your blend).

Hope this proves useful to someone!

Notes:

  • The blueprints have been created in UE4 version 4.25 (though it will work in newer versions fine), If you require support for an older version of the Engine, feel free to contact me on Discord! (Shown at the bottom of every page on this site).
  • There is 2 versions of the python script, one for blender 2.7 and the other for blender 2.8 (denoted by the 2.7x/2.8x at the end of the filename), select the appropriate one for your blender version.

 

Leave a Reply