How do I push a value in a 3D array?

0 favourites
  • 5 posts
From the Asset Store
Push the Box Puzzle Game likes Sokoban made with Illustrator
  • Hi,

    I just tried to push a new value in front of an array. The array is 3 dimensional and I want to add a new value at the front of the X axis and at a specific Y and Z index.

    But the Push action only uses 1 axis.

    How do I use the Push function in that case?

    Thanks for any help!

  • Pushing a value in multidimensional arrays will always create more than one new cell. It'll create a new row/column in a 2D array, and an entirely new plane in a 3D array. The axis you choose will decide how the array is expanded... but the value you push will be duplicated in the row/column/plane thus created. What I usually do in this case is push a 0 (or blank if a string array) value on the wanted axis, and then use a "Set value at" at the cell I want to adjust.

  • Thanks for your reply!

    But how do I add a value at the back of my array and at a specific Y and Z index? So for example:

    Front.X, 0, 1 and the Value to add there is "Hello World!"

  • Instead of using push, you could just set the size of the array to be bigger and set the value like your last post.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • R0J0hound,

    Thanks for your reply!

    I didn't get it to work like you said but I found another way to do it. I'm using a loop now that tests for an unused index of the array. If it finds one it simply sets the variables at the loopindex.

    Thanks again!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)