How do I detect a specific value in an array (it's x,y,z)?

0 favourites
  • 7 posts
From the Asset Store
It's here!
$2.48 USD
50% off
Creepy and nasty horror track. It's terrifying from the beginning till the end. Goosebumps guaranteed
  • So my for example, i have a 1 in my array and everything else is just 0. Now i want to know what event i need to use to detect where that 1 is in my array by it's coordinates.

    How do i do that?

  • For each XYZ

    System compare two values array.curvalue=1

    You can then get the coordinates with the Array.curX, array.curY, and array.curZ expressions. Save them to a variable, or push the coordinates into another array if you expect to have multiple locations that have the value 1.

  • For each XYZ

    System compare two values array.curvalue=1

    You can then get the coordinates with the Array.curX, array.curY, and array.curZ expressions. Save them to a variable, or push the coordinates into another array if you expect to have multiple locations that have the value 1.

    You would have to go through every point of the multidimensional array every time you wanted to detect that one value, that would take a ton of processing power and would most likely halt your game if your array is substantially big, How do you generate those one values ? Isn't there any way to keep them in a one-dimensional array as multidimensional tokens? For example: "4/2/5"

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You would have to go through every point of the multidimensional array every time you wanted to detect that one value, that would take a ton of processing power and would most likely halt your game if your array is substantially big, How do you generate those one values ? Isn't there any way to keep them in a one-dimensional array as multidimensional tokens? For example: "4/2/5"

    Well, I'm trying this 3D space in just 2D space. So every time I'm moving an object the array deletes itself and refreshes with new 1's. That get input from the objects own X,Y (adjusted). First I tried 250x250x250. The game just froze here. Then I try lower numbers until I reached a good non-laggy game. It was only 38x38. But I could just try with initial variables, I guess it would work the same way.

  • Maybe try a different approach? You can add a "z" instance variable (and a "depth" variable) to each object to base calculations off of.

    Using an array in this manner doesn't seem very suitable.

  • Yep, your approach is not optimal in this case, deleting and recreating array every tick is basically butchering your fps

  • Sounds like you are trying to use a 3d array to simulate 3d space? Each cube representing a possible position?

    It would be better to use a 2d array to store the coordinates of each object instead. Then you can make the 3d space any size you want...

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