[SOLVED] Incrementing to Family member via Array

Get help using Construct 2

Post » Tue Feb 26, 2013 10:28 am

Hello guys and gals!

I have been prototyping an RPG Party System whereby you have several characters and can TAB between them.
The camera pans smoothly to whichever character is selected and has a smooth lag effect when the character moves (I can also employ the Screen Shake effect later, as I'm using Scroll-to).


I first created this without any Arrays or Families and it worked perfectly, but I would like to make it more flexible to future-proof it for changing Party sizes when members join and leave (or die).

I also have future steps planned such as a loop to fill the array, but I'm trying to take baby steps here


I haven't used arrays in construct before and don't seem to be having much luck. My array is simply 3 X values: 0, 1 & 2 (a 3x1x1 array).
X0 stores the UID of Char1, X1 stores the UID of Char2 & X2 stores the UID of Char3.

I increment the Global number PlayerSelected to allow me to select different X values within my array (which in turn should refer to the different Characters, allowing me to cycle through them).

I seem to succeed in everything up to (and including) unpinning the Player Controller from the current Character, but once I increment to the next Character, the Player doesn't want to move over there and be pinned to it, he just wanders off and leaves the first character behind.


Here is my initial setup:




Here is how I handled the Character cycling previously, which worked as intended:




Here is how I am trying to handle it now, using the same logic as before:




Here is the capx:
https://dl.dropbox.com/u/97071084/Scirra%20Forum%20Posts/TAB%20Character%20cycling%20with%20arrays.capx


I am planning to turn this into a tutorial once I'm finished and any help would be appreciated Cereal Killa2013-02-26 21:14:31
B
11
S
2
G
3
Posts: 22
Reputation: 2,595

Post » Tue Feb 26, 2013 11:37 am

I have added a line to check that the incrementing is working (and it is):




It counts up to 2 and then goes back to 0. So it just seems to be the last part of the new formula that doesn't work. Maybe I can't get a new instance of PlayerChars within the same condition, after getting the first??

I'm not really sure.

Cereal Killa2013-02-26 21:17:52
B
11
S
2
G
3
Posts: 22
Reputation: 2,595

Post » Tue Feb 26, 2013 9:09 pm

Ok, I think that was the problem. By taking the first PlayerChars instance-picker condition, and giving it it's own sub-condition, the second PlayerChars instance-picker condition now fires (whereas previously it wasn't firing at all).

It seems that upon a condition picking one instance (or a group of instances), a sub-condition of this is unable to pick a different instance outside of what was already picked (but can possibly pick instances from within the first selection - I haven't tested this), and thus any associated actions never fire.

Therefore, I assume that the original sub condition wasn't working as it was trying to pick an instance outside of what was already picked in it's parent condition

By removing the pick-instance from the parent condition, the 2 sub instances are free to pick different instances of their own choosing

If anyone can confirm this it'd be great!!


Here again is how I was trying to do it:




And here is the solution:




Note: I also added a text line for debugging purposes and I have updated the capx with the solution    Cereal Killa2013-02-26 21:37:12
B
11
S
2
G
3
Posts: 22
Reputation: 2,595


Return to How do I....?

Who is online

Users browsing this forum: blackhornet, makkancs, TiagoCesar and 16 guests