How to track and register multiple frame changes in an animation?

0 favourites
From the Asset Store
Selection frame like in RTS games, works both on mobile and desktop devices.
  • Hi everybody

    I have a problem to solve and I would like to ask for some help from you.

    I have a sequence of frames and three options that change the order of this sequence according to the positioning of each frame. I need to register the result of the last change in a variable.

    For example, the first frame sequence is 3210 (i.e. frame 3 at position 1, frame 2 at position 2, frame 1 at position 3, and frame 0 at position 4)

    Then appears the first sequence changer (1432) that will define the positions of the frames of the first sequence of frames (3210). Based on this initial sequence, frame 3, which is the one in position 1, remains in it. Then we have frame 0, which is in position 4, then frame 1 which is in position 3, and frame 2 which is in position 4. Result: 3012

    A new sequence changer appears: 2314. This will change the result of the previous sequence (3012) to 0132

    Finally, the last sequence changer: 4132, which will transform the result of the penultimate sequence changer to 2031

    It is this last value (in this case, 2031) that I need access to.

    Could someone give me suggestions on how to get this sequence in the background and only receive the final value?

  • Is this what you need?

    https://www.dropbox.com/s/f58gszxn2ey79mz/1-Sequence%20Numbers.c3p?dl=0

    I don't have much time to spend on this so I hope I get it right.

    I created many Global Variables so you can debug and follow easily but you can change them as your like.

    The final number that you need you will find it on the Global Number "Final_Number"

    Is a string Number so you may have to convert it to an integer if you need to

    On Preview "For each sequence number" you will find the results next to it on the Right

    For example:

    Here the starting Number is "2310"

    And the Final Number after all the sequences are done is "1203"

    Also, you can remove the sprite events you don't need them they are just for visual.

  • Hi tarek2

    Right in the bull's eye! That's exactly it. Thank you very much!!!!

    The only issue is that in the example the sequences are drawn, but in my case, I already have these values ​​allocated to variables (seq1/seq2/seq3). It is possible to change the script to use these values ​​instead of drawing them, right?

  • Hi tarek2

    Right in the bull's eye! That's exactly it. Thank you very much!!!!

    Np, glad it was helphul

    The only issue is that in the example the sequences are drawn, but in my case, I already have these values ​​allocated to variables (seq1/seq2/seq3). It is possible to change the script to use these values ​​instead of drawing them, right?

    The drawing sprites it is just for debugging, I tried to explain in my last comment:

    Also, you can remove the sprite events you don't need them they are just for visual.

    You can remove those events

    And Yes for the (seq1/seq2/seq3) you already have them in the Global variables the same as yours, you just have to rename them or copy the results into your variables:

    For example to save Sequence1 look at the (Event 12) (Action 2)

    And the result for that sequence after we modify the value Number is saved into Global "Sequence1_Results"

    The same goes for the other 2 sequences, they are all named exactly matching what they do so it should be no problem to identify them, or at least if I understood you correctly.

    The best thing is to open it on Debug mode as you will see the visually debug sprites on the screen then look at the Global Variables values on the Debugger and you should be able to identify what each variable does and then do your modifications.

    Note:

    Just remember to reset all the Global var whenever you start a new game session.

  • Hi tarek2

    Thanks for replying and also for all the explanation!

    So, my system already sorts the sequences so I wouldn't need to do this process again, through your solution. In that case, since my variables (seq1/seq2/seq3) already contain the values ​​of the sequences, I wouldn't need to use the Array to store them, right?

    EDITED: I also have the starting numbers in my script and the variable already stores the sequence number of each frame.

  • tarek2

    I can't understand one thing: in your script, you use 3 variables (Sequence1/Sequence2/Sequence3) and you store the corresponding Array values in these variables. However, I can't find it in the script when you use these variables.

    I think that in this case, I would just change the name of these variables by my variables (seq1/seq2/seq3),

  • Try Construct 3

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

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

    I can't understand one thing: in your script, you use 3 variables (Sequence1/Sequence2/Sequence3) and you store the corresponding Array values in these variables. However, I can't find it in the script when you use these variables.

    I think that in this case, I would just change the name of these variables by my variables (seq1/seq2/seq3),

    Because I update the "Sequence1" & the new Results at the same time, that's why I didn't need to reference that variable on that same tick, it was there for you just in case you need to reference it in your events to make it easier for you.

    It looks like the more I tried to make it easier for you including visual debugging the more it confused you so I removed all the things that weren't needed and:

    -Renamed the variables to your (seq1/seq2/seq3) names

    -I referenced your (seq1/seq2/seq3) variables to create the New result number

    So now you should have no problem, just take time to study the code as it's very easy to figure out what's going on so you can update your events.

    https://www.dropbox.com/s/rd4k2a0m7q4l86o/2-Sequence%20Numbers.c3p?dl=0

    Good luck

  • Thank you so much for your time, tarek2

    It will help me a lot.

    I'll check/study it and I'll let you know later if I have any questions.

    Many thanks

  • Hi tarek2

    It's me again. Sorry about that :(

    I tried to use my variables, disabling the process of generating random values through the array first, and it didn't work. After that, the system generates several numbers "1" as shown in the print of the variable "New_Result".

    As I understand it, it only works if I generate these numbers randomly, right? As I already generated the values of the 3 sequences, I already disable this action. Maybe I need to add these values into the array, right?

  • Hi tarek2

    It's me again. Sorry about that :(

    I tried to use my variables, disabling the process of generating random values through the array first, and it didn't work. After that, the system generates several numbers "1" as shown in the print of the variable "New_Result".

    As I understand it, it only works if I generate these numbers randomly, right? As I already generated the values of the 3 sequences, I already disable this action. Maybe I need to add these values into the array, right?

    I don't want to be rude but I have to tell you this to help you:

    Your problem is that you not studying the example they give you that's why most of your threads get (3+ Pages) unnecessary. But I thought that by warning you on my first comment

    "I don't have much time to spend on this so I hope I get it right."

    I will make you try harder to try studying the examples but I see that it didn't work so let me try now differently:

    Lets us analyze what's going on here, how is possible that you need to study only two lines of code to understand what you need to do and still can't figure it out?

    The problem is that you spect users to give you exactly the example that will sync perfectly with your already started project which is impossible as we cannot see it so there's no way that anyone can get it right that way, so automatically your approach it's wrong. The examples they give you are for study and understand them and then you will be able to create your own version or integrate them into any projects easily.

    1-First Part: Starting Number:

    You said that you have your code already so you don't need to study that

    2-Sequence changers:

    You have 3 but in truth is the same code repeated three times so you need to just study and understand one of them to understand what going on.

    Lets Pick Sequence: 2

    You said that you already have your sequences done with your own code (seq1/seq2/seq3) so you don't need that either, then what is left?

    How the new sequence is generated right?

    That's just one line of code

    So if you think logically you need to ask what I'm doing in that line of code?

    I'm just looping through the numbers inside the variables

    "seq2"

    &

    "New_Results"

    At the same time and in index order to shuffle the positions of the numbers so you get the new Result at the end inside the "Array New_Sequence"

    Now if you look closely I'm creating the number "seq2" on the fly so my code will be different than yours as I'm targetting the last number added in "seq2" but your code has already all numbers created so what do you think you need to do? definitely, you cannot target the last number like me as your numbers are added already in your "seq2" so it will give you 4 times the last same number on your "seq2"

  • Thanks for replying tarek2

    I took a good look at your code. I knew it was that line I should change, but I still couldn't figure out how to do that. The other two lines above I had already disabled so as not to create the sequence again. But you are right. I was waiting for something closer to what I needed because I've wasted a lot of time on this project and it's just a demonstration of what I intend to do.

    Analyzing that line you highlighted, this time in the first sequence, there is being stored in the new_sequence array, the order of the frames based on the variable seq1 and the order of the initial frames. You used (-1) to match the frame number since it starts at 0, right? Then, the value of the new_sequence array is passed to another variable (new_result). Despite knowing that I must change something in one of these expressions in that specific line, I think (for me) they are correct as they appear. Therein lies the dilemma.

    The code of this sequence it is like this:

    This is the result I am obtaining:

  • Analyzing that line you highlighted, this time in the first sequence, there is being stored in the new_sequence array, the order of the frames based on the variable seq1 and the order of the initial frames. You used (-1) to match the frame number since it starts at 0, right? Then, the value of the new_sequence array is passed to another variable (new_result).

    That's correct

    You are making progress but you're still missing the most important which is the thing that confused you as you try to copy my code exactly.

    This line of code is your issue as you still didn't understand the concept:

    Because my "seq2" starts empty = ""

    So repeat 4 times:

    First Loopindex:

    And I add the First number to "seq2" -------- Example = 2

    So to set the New Value in the Array Sequence I need the last number Added in "seq2" that's why I use -------------- int(right(Seq2,1))

    This will Pick = 2

    So we set the New Value at index = (2) -1 to match the Array index as it starts (from = 0) as you found out

    ===========================================

    Second Loopindex:

    And I add the second number to "seq2" -------- Example = 1

    So to set the New Value in the Array Sequence I need the last number Added in "seq2" that's why I use -------------- int(right(Seq2,1))

    This will Pick = 1

    So we set the New Value at index = (1) -1 to match the Array index again

    ====================================================================

    Third Loopindex:

    And I add the third number to "seq2" -------- Example = 4

    So to set the New Value in the Array Sequence I need the last number Added in "seq2" that's why I use -------------- int(right(Seq2,1))

    This will Pick = 4

    So we set the New Value at index = (4) -1 to match the Array index again

    =================================================

    Four Loopindex:

    And I add the Fourth number to "seq2" -------- Example = 3

    So to set the New Value in the Array Sequence I need the last number Added in "seq2" that's why I use -------------- int(right(Seq2,1))

    This will Pick = 3

    So we set the New Value at index = (3) -1 to match the Array index again

    =================================================================

    So far we have the Sequence modifier = 2143

    Now, where is your problem that I want you to find out?

    If you look closely you cannot use my code:

    int(right(Seq2,1))

    Because you already have the full Number = "2143" created Right?

    So instead you need to loop from the first number to the last one in order, the same way I did but with your own code, that's the only thing you need.

    I create the number on the fly and I pick on each loopindex the last number added but you already have your full number created so you should just loop through your "seq2" number to pick one by one in order.

    2

    1

    4

    3

    the same logic goes for (seq1/seq2/seq3)

    So in truth, the concept was just to loop through the Sequence number in order that's all, the only difference is I add the number and pick the last number and you will loop through yours without picking the last number and instead just do it by index order.

    ===========================================================

    So finally you shouldn't use:

    int(right(Seq2,1)) -1

    Should use something like:

    mid(sq1, loopindex, 1) -1

    Or pick the code you are more comfortable with as they are many ways you could do it.

  • Now I got it!

    Just to use the same expression I am using to loop over starting_numbers (specifically talking about the "sequence 1" commands).

    Thank you so much for your time and also for your enormous patience!

  • Hi tarek2

    The results on my project are unstable, sometimes the first is right and the other two are wrong, other times the first and third are right and the second is wrong, despite the variables being shown at the correct value. The only difference for your code, is that I'm using the "trigger once" event instead of using the "on start of layout", because this code is inside a function. Do you think this could be the problem?

    Some screenshots:

  • The results on my project are unstable, sometimes the first is right and the other two are wrong, other times the first and third are right and the second is wrong, despite the variables being shown at the correct value. The only difference for your code, is that I'm using the "trigger once" event instead of using the "on start of layout", because this code is inside a function. Do you think this could be the problem?

    Some screenshots:

    Honestly, your questions are getting very weird you know that?

    How can I know what you did in your project? I don't know and honestly, I don't have the time for debugging your project.

    I gave you already two working versions and I just tested them again they seem to work without any bugs so whatever problems you having is on your side.

    You have 3 choices:

    1-(Copy & Paste) my exact code in your project and use that as it works 100%, I'm thinking why you didn't do that?

    2-Start Debugging your project as you do with any other game, I don't think it will take you long to find out what's wrong though. Again I'm thinking why you didn't do that?

    https://www.construct.net/en/make-games/manuals/construct-3/interface/debugger

    https://www.construct.net/en/tutorials/checking-for-errors-in-browsers-5

    3-Leave this project, as it looks, is too difficult for you and do some C3 tutorials to start learning the basics when you think you improved your skills come back to this project and you will see how easy was to solve if you just use the "Debugger" + some basic skills.

    I say this because if you have to come back with every little error you have then not sure how you gonna finish any small Game.

    I strongly recommend Option 2 but for this, you need to take the time and debug as you will learn from that also for your future projects. The problem I see is you are always in a hurry and that there is always a deadline to showcase the example etc... so that's why you don't take the time to study the examples or debug your own code so this is a big problem as Game dev needs time and focus.

    I think I helped you already with your main issue so for me, I'm gonna have to end here as I don't have time even for my own projects so I will pass it to anyone else who wants to give it a try, though I wouldn't recommend it as it looks like you are not willing to put effort to learn, sorry I have to tell you the truth, normally I wouldn't mind keeping going the back and forward as long as it takes but on this thread, I'm really scratching my head where are we going with this.

    Also, there is option 4 that just came to my mind:

    I'm pretty sure you can find it on Fiver or any other Services like that, someone that you can pay small money to so it can guide you and answer any questions you will have, like a personal coacher (24/7).

    And think this is the option that you are looking for as here on the forum I will be surprised if anyone will have the time for that when it could work on his own projects.

    I hope you don't take this too personal.

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