Array and structures

Hi all!

I am looking to import an excel file (in csv format) that contains the coordinates (x,y,z) for 3 different actors (named A,B,C) over a 2 second period. So essentially I have a location for each actor at second 0 (starting position), 1 and 2 (final position). The actors could be something as simple as a cube for argument sake.

I was thinking i could use the “Move Component To” function to move the actors between each x,y,z location for each second, but I am having trouble setting up the blueprints. Any help would be much appreciated. I am guessing it involves both arrays to store the different Actor names, and a Structure set up to store the different x,y,z locations associated with each Actor name.

Arrays and Structures
.

1 Like

I feel like this can be dramatically simplified from what is shown, at least as far as the functionality in the description is concerned. All that’s needed is a struct with a single variable:

  • a vector array stores coordinates
  • its array index acts as seconds
  • row name identifies the actor

  • a DT with the provided example data punched in:

  • exported to csv (so you can now edit and re-import):

  • potentially easier on the eyes as json, :


  • use case scenario:

This would spit out: 5,5,5

Everynone, I was genuinely wondering if it was possible to somehow tag you in my quesion - turns out the bat signal was not needed :grin:

Thanks for taking the time to write up that explanation. Unfortunately, I can’t easily rewrite the CSV rows into your format (though it makes a lot more sense) because I have 3000 rows of cordinates and about 50 Actors (see snippet below). So I was thinking I need unreal to do the “tidying up” of the csv input.

1 Like

If you try to do Array, you would need to set all the coordinates for each A B C (Each have a Separate Array) then each second would choose Each Index from said Arrays (1 second set A B C index of Arrays to 1) (Unreal Starts at 0)

Bummer, I was thinking of doing something along the lines of:

Can you confirm that I got the rough idea?


So I was thinking I need unreal to do the “tidying up” of the csv input.

@richarmearup I’ll have a look tomorrow morning, seems doable at a glance. Are actor names / IDs ordered numerals?

Your proof of concept looks spot on in terms of what I am hoping to achieve! No rush, appreciate any help at all! yes all Actor names are ordered numberals (all integers).

1 Like
  • this is the data:

The A column needs to be added as we need unique Row Names for the DT. Everything else can be jumbled / missing, including Seconds

  • imported using the very appropriately named sTimeStructMess :innocent: :

image


So I was thinking I need unreal to do the “tidying up” of the csv input.

  • called sActorLocationAtSecond below:

image

  • it becomes a part of mSecondsMap:

It describes which actors are where at each second present in the csv; and gets populated like so:

The temp arrays are necessary because reasons.


To use it:

The actors could be something as simple as a cube for argument sake.

If we knew how the actors should be referenced, it’d be quite possible to incorporate the references directly into mSecondsMap, rather than fetch them via whatever other methods is necessary. Here it’s a hard-coded map:

1 Like

Wow, very impressive stuff! I learned a lot here, so thank you very much. I am planning on having all the actors as static meshes - to incorporate the references directly in mSecondsMap, would that involve adding a static mesh (array) like this?


I am curious what is in your Move to function? I assumed the way to move static meshes smoothly from location to location was by using a Move Component To tick, but that can’t be used inside a function. Does your Move to function just contain a Set World Location node for the actors your feeding into it?

The actors could be something as simple as a cube for argument sake.

Without knowing the details, I did just that:

Since the static mesh is at the root of the actor, the Relative Location becomes World Location. But the movement can be done in many ways, depending on what the end goal is.


would that involve adding a static mesh (array) like this?

You said boxes are actors, so ideally that’d be actors. But yes, that’s the idea. They could even be spawned dynamically based on the data. This can be done with just components, surely.

Finally got my head around your approach and I am 95% of the way there my end. Last hurdle to leap is getting the Move Component To to work inside the For Each Loop. They don’t seem to play nice together so I am guessing that is why you have it in a Custom Event called MoveTo? When I just use a Set World Location in place of the Move Component To, the whole thing works fine but obviously the Cubes jump from location to location instead of gradually moving, which is what I want. Do you know where I am going wrong here? Your code is shown above, mine below for reference.

One cannot combine loops with latent nodes - note the clock icon on the MoveComponenTo.

My MoveTo is a custom event that lives inside another target actor (since each box was supposed be an actor, as in the original description I tried to adapt to - not guilty ;p ); meaning each actor has an instance of `MoveComponentTo’ which, once fired, can live its own independent life detached from what the loop is doing.

If you’re not working with box actors:

Option 1:

  • extend the Static Mesh Component:

You’ll end up with a static mesh component that can handle a mesh asset, but can also host script and variables. I can’t stress enough how convenient this can be at times, and how well it keeps things low profile.

Option 2:

Instead of trying to Move while the loop is looping, let the loop finish and add everything to a neat map as you do. When the loop has completed, fire a Timeline or Move Component To. But then you’ll need to handle data differently. Here’s an example:

Ignore the track being a vector, you’d use a 0-1 float as alpha. Another example:

Top bit prepares the data first, then a timeline moves multiple elements of an array.

There’s probably Option 3 & 4 out there that eludes me. Do tell how it goes. I’ll be around later this week.

1 Like

Genius - you’ve done it again!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.