Using .csv data to generate objects in level

Hey guys,

So the question title may be a bit misleading. I have a .csv file that contains times/information about notes for a music game I’m beginning development on.

I’ve imported the .csv as a DataTable into the Engine. What I want to do is use it to generate physical note objects in the level that I can then manipulate and save as part of the level in in the editor.

The reason I can’t simply spawn them in the game and then use them from there is because, while this is a beat-matching music game, it takes on a path the player is running down that will have scenery in it and characters coming and going based upon different points in the song. With that in mind, we want to be able to edit and add this stuff in based upon where the notes are in the editor.

Anyone know of a good way to do this?

Thanks!

I don’t think it’s as simple as just importing the .CSV asset into the editor. There has to be a custom-written hook up, so far as I can gather from this: https://docs.unrealengine.com/latest/INT/Programming/Gameplay/DataDriven/index.html

In a forum post (Read data from File - Some kind of dynamic level - Blueprint Visual Scripting - Unreal Engine Forums) Joe Conley writes: “The format the .csv files are in isn’t well documented yet, nor is the process of defining the type of data for the columns in a Data Table, but I’m hoping to write a blog post on it sometime in the near future. Right now this is a C++ feature, but we’re looking into making it more accessible from Blueprints and require less programming (or preferably none), but we have a fair amount of work to do in this regard.”

I’m also very interested in this workflow. I came across RAMA’s blueprint plugin library recently and there’s a node in there called load string array from file. This lets you read in any txt file and seperate each line into an index to form an array. I tried using this to bring in transforms from Maya. It works for the most part, but I’m having an issue getting the rotations to match from Maya to UE4…

For anyone that’s willing to help out, here’s my mel script to save out transform data from Maya as a txt file

//STEP 1: // Define Your File Path
// folder must exist for it to save the file.

string $filePath = “C:/mel/ue4CSV_test001.txt”;

//STEP 2: // select all the objects you want to send then run this:

$fileId = fopen $filePath "w";
string $sel[] = ls -sl;
int $count = size $sel;
for ($i=0; $i<$count; $i++)
{
select $sel[$i];
string $transform;
vector $p = xform -q -ws -t;
vector $r = xform -q -ws -ro;
vector $s = xform -q -ws -s;
$transform = ($p.x + “,” + $p.y + “,” + $p.z + “,” + $r.x + “,” + $r.y + “,” + $r.z + “,” + $s.x + “,” + $s.y + “,” + $s.z);

fprint $fileId ($transform + "\n");

}
fclose $fileId;

You can find Rama’s plugin here:

Here’s my simple blueprint for getting the values from the txt file

This is what the layout looks like in Maya:

notice how the shapes follow the pattern and don’t intersect with one another

Here’s my result in UE4:

you can see that they follow for the most part, but some of them are rotated incorrectly and intersect with one another. This is a simple example, but it looks even worse trying to populate a scene as most of the objects are rotated incorectly.

I know Maya is Y up and UE4 is Z up, so thats why I have swapped the Y and Z inputs in the blueprint. I also found that inverting the yaw gave better results in some orientations, but broke in others…

I know this must be possible as things like mtu exist…

If anyone could help out with a solution to this I would be very grateful! :smiley:

thanks,
Richard

doesnt look like the script was formatted properly, here is it again:

//STEP 1: // Define Your File Path
//folder must exist for it to save the file.
string $filePath = "C:/mel/ue4CSV_test001.txt";


//STEP 2: // select all the objects you want to send then run this:
$fileId = `fopen $filePath "w"`;
string $sel[] = `ls -sl`;
int $count = `size $sel`;
for ($i=0; $i<$count; $i++)
{
    select $sel[$i];
    string $transform;
    vector $p = `xform -q -ws -t`;
    vector $r = `xform -q -ws -ro`;
    vector $s = `xform -q -ws -s`;
    $transform = ($p.x + "," + $p.y + "," + $p.z + "," + $r.x + "," + $r.y + "," + $r.z + "," + $s.x + "," + $s.y + "," + $s.z);
    
    fprint $fileId ($transform + "\n");
}
fclose $fileId;