Weapon array not returning values

0 favourites
  • 6 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • Trying to figure out how to set the default ammo amounts, I have a counter that should return the value to the HUD here:

    And here is the array, I'm playing around with the cells, trying to figure out how to bring in the right value:

    Where am I going wrong?

  • Depth of your array has to be set as least to 1, otherwise the whole array has no size. You can see that, if you look at your array in debug.

  • Depth of your array has to be set as least to 1, otherwise the whole array has no size. You can see that, if you look at your array in debug.

    Thank you! I was thinking the depth started at 0, so it works now! I was thinking it might be better to switch weapons by pushing the array, I think that's what it's called? Where you shift the cells in a cycle, so the game reads from the fixed cell, but the array shifts the cells around. Would that be a better way of doing it? And I should I be doing all this on every tick for performance?

  • Depth of your array has to be set as least to 1, otherwise the whole array has no size. You can see that, if you look at your array in debug.

    Thank you! I was thinking the depth started at 0, so it works now! I was thinking it might be better to switch weapons by pushing the array, I think that's what it's called? Where you shift the cells in a cycle, so the game reads from the fixed cell, but the array shifts the cells around. Would that be a better way of doing it? And I should I be doing all this on every tick for performance?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm not certain if I understand correctly what you think to achieve by using an array. An array is useful if you don't want to deal with a huge amount of variables or you need something that change its size dynamically. Also you can go through all elements of an array very easily. A bad Idea is to change the size of an array every tick by inserting or deleting elements. It will have to reorder the index. Depending of the size of the array it could take some time to do this.

    If you store all your Weapons by name or number in an array in the beginning and you want only to cycle through the weapons in the game, you can do this by using the index or use the 'for each element' loop to go through all weapons at once, but I wouldn't use push and pop.

  • I'm not certain if I understand correctly what you think to achieve by using an array. An array is useful if you don't want to deal with a huge amount of variables or you need something that change its size dynamically. Also you can go through all elements of an array very easily. A bad Idea is to change the size of an array every tick by inserting or deleting elements. It will have to reorder the index. Depending of the size of the array it could take some time to do this.

    If you store all your Weapons by name or number in an array in the beginning and you want only to cycle through the weapons in the game, you can do this by using the index or use the 'for each element' loop to go through all weapons at once, but I wouldn't use push and pop.

    Excellent, I'm using a global variable to control which column is being shown, so that confirms I shouldn't be pushing and popping. Here's the finished result:

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