Jcw87 / c2-sans-fight

Undertale Sans Fight Clone
http://jcw87.github.io/c2-sans-fight/
527 stars 494 forks source link

No Automatic Jump. #59

Closed iKNIFEu closed 4 years ago

iKNIFEu commented 4 years ago

I have lots of issues in my custom attack because there is no autojump, why not adding it? I tried looking for it in construct 2, but failed.

Jcw87 commented 4 years ago

Duplicate of #5

If you want to change this yourself, this is where you would need to look image All inputs are routed through the VPad object. It keeps track of what buttons you are pressing with a 1 meaning the button is pressed, and a 0 meaning that it is not pressed. It also keeps track of what buttons you were pressing on the previous frame. This allows the detection of new button presses instead of button holds by checking if the current value is greater than the previous value. If you want to allow continuous input, you would replace this condition with one that only checks the current value.

There are 4 different checks for jumping, 1 for each gravity direction.

iKNIFEu commented 4 years ago

Sorry I am confused about what you were saying.

Jcw87 commented 4 years ago

What are you confused about? What have you tried so far?

iKNIFEu commented 4 years ago

"you would replace this condition with one that only checks the current value." I didn't know what was that, I tried many conditions especially the "loops" category in the condition list for system, But.. it didn't work.

Jcw87 commented 4 years ago

You do not need to add a loop to make this change. Why do you think you need a loop?

iKNIFEu commented 4 years ago

Well it is hard to understand what were you saying.. Can you please make it clearer?

iKNIFEu commented 4 years ago

because I don't know what the "one that only checks the current value." Can you please tell me what is that?

Jcw87 commented 4 years ago

My explanation about how my inputs were structured wasn't there for nothing. Think about it for a moment. The VPad object keeps track of the pressed state of each input, both for the current frame, and for the previous frame. The variable names should make it obvious which is which. Both sets of info are used together to detect button presses and button releases, allowing me to restrict the jump action to button presses instead of button holds. If you are only interested in button holds, then you only need to consider the current pressed state, and not the previous pressed state.

iKNIFEu commented 4 years ago

Now I understand what VPad is, but all I need to know is to what to do, what to replace and add.

Jcw87 commented 4 years ago

The message I keep hearing from you is "I don't want to learn how to do this, just tell me the exact steps to follow". That's telling me that you don't want to put in any effort, and putting in effort is part of my stipulation for continuing to help you. If you think this interpretation of your words is wrong, then prove it by sharing the details of what you tried and why you thought it would work. If you can't do this, I won't help you.

I suggest you start reading some materials on basic programming. Construct 2 events (read thoroughly, including links to other pages) C++ relational and comparison operators (read only linked section)

Those links + everything I have mentioned here should be enough to figure this out.

iKNIFEu commented 4 years ago

Alright, sorry for replying late. I just found out that automatic jump isn't possible in construct 2. I've seen that on other construct games, even construct 3 games. So, I'm sorry for wasting your time and all, thank you for trying to help. I was literally not knowing what the hell I was doing. So, I'm sorry.

iKNIFEu commented 4 years ago

@Jcw87 Hold on, now I understand!

I understand what you meant by "Continuos input (sorry for misspeling i'm just lazy to fix)" I just need to add a condition that checks.. hmm.. I see. I'll try it out now. I'll inform you if it works or not. (My mind was dumb 4 months ago xD)

iKNIFEu commented 4 years ago

@Jcw87 I tried what you meant, it was successful, but there is just one bug from it. No matter how many milliseconds I press the jump button, it jumps to the highest it could. No, I didn't delete the "Set VPad.LastUp/Down/Left/Right to VPad.Up/Down/Left/Right", I made special vpad conditions for the player soul (You are so smart to add them btw). I tried everything possible with the palyer soul thing, and it was working! (Because I pressed the highest jump possible to test the auto-jump). The LastLeft/Right/Down/etc. is what makes it not having auto-jump. can you please help me?

Jcw87 commented 4 years ago

Regarding autojump 'not being possible' in Construct 2, I disagree. While the default platforming behavior has a check to stop autojumping in the simplest use case (if user holds button, then jump), you can still make it autojump if that is what you want. This project doesn't use the default platforming behavior however, so nothing about that applies here.

Regarding what you tried, I want to see a screenshot of what you changed. That will allow me to give you more appropriate hints.

iKNIFEu commented 4 years ago

Alright, please wait. I'm going to load it up.

iKNIFEu commented 4 years ago

image I do understand that "LastDown/etc." does the problem. and this is the only problem. I do not know how I can make the jump at a high rate. second picture: image

Third picture: image

Fourth One: image

Here are all the pictures for the PlayerVPad

Jcw87 commented 4 years ago

Ok, you are waaaaay over-thinking this. You don't need to create separate player direction variables. You don't even need to change anything outside the jumping events.

Starting from my codebase without any of your changes, you only need to change 1 condition for each direction. Just one. If you feel the need to do more, you are over-thinking it still.

iKNIFEu commented 4 years ago

I see. Do you mean the "Playerdown > LastPlayerDown"? OK. Sorry for replying late. Do I need to change this? I really think I should.

Jcw87 commented 4 years ago

Yes

iKNIFEu commented 4 years ago

Ok, I'll tell you what will happen when I do this. OK?

iKNIFEu commented 4 years ago

You meant this: image image If yes, please tell.

iKNIFEu commented 4 years ago

image I'll wait for your answer in this one, I'll take "VPad.Down/VPad.LastDown" as an example. What will I do?

Jcw87 commented 4 years ago

Let's think about all of the possible scenarios here.

  1. Down is 0, LastDown is 0. This means that the player isn't pressing the button
  2. Down is 1, LastDown is 0. This means that the player just pressed the button
  3. Down is 1, LastDown is 1. This means that the player is holding the button
  4. Down is 0, LastDown is 1. This means that the player just let go of the button

Now ask yourself. "What can I change about this condition to make the player always jump when pressing or holding the button?"

iKNIFEu commented 4 years ago

Hm, good idea.

iKNIFEu commented 4 years ago

but it's complicated lol

Jcw87 commented 4 years ago

There's nothing complicated about this.

The current condition is VPad.Down > VPad.LastDown. This condition will only be true for scenario 2. You are looking for a condition that will be true in scenario 2 and 3, and false in scenario 1 and 4. What would allow you to check for scenarios 2 and 3, but not 1 and 4?

If you are still struggling, recall what I said before: "If you are only interested in button holds, then you only need to consider the current pressed state, and not the previous pressed state."

iKNIFEu commented 4 years ago

Alright. I'll go try my best now. Brb

IamToxin commented 4 years ago

i made it @iKNIFEu . try this; image

iKNIFEu commented 4 years ago

i made it @iKNIFEu . try this; image

Thank you so much! @Jcw87 There you go. Thanks to him. He helped me, too. As a reward for you Jcw87, I'll make something for your bad time simulator. This might take days so yeah 😅

Jcw87 commented 4 years ago

i made it @iKNIFEu . try this; image

Great, you just gave him an answer. Now he won't learn anything. But it seems you have a couple things to learn. Those keyboard conditions are completely unnecessary, and just break jumping for gamepad and touch controls. The whole point of the VPad object is to abstract all of the input so that you never have to think about things like the input device and button mappings in the game logic. Trying to handle all of these input sources in the game logic is a recipe for strange behaviors and difficult to find bugs.

While this answer technically works, these answers make more sense for readability: VPad.Up > 0 VPad.Up = 1

It really was that simple. Not complicated at all. Either one of those would work.

iKNIFEu commented 4 years ago

i made it @iKNIFEu . try this; image

Great, you just gave him an answer. Now he won't learn anything. But it seems you have a couple things to learn. Those keyboard conditions are completely unnecessary, and just break jumping for gamepad and touch controls. The whole point of the VPad object is to abstract all of the input so that you never have to think about things like the input device and button mappings in the game logic. Trying to handle all of these input sources in the game logic is a recipe for strange behaviors and difficult to find bugs.

While this answer technically works, these answers make more sense for readability: VPad.Up > 0 VPad.Up = 1

It really was that simple. Not complicated at all. Either one of those would work.

You are right. And actually, thanks to your explanations, ALL of them. I understood how the VPad works. When I was overthinking. I literally am trying hard to add auto-jump. But when you told me I was overthinking, I stopped. And thought. Right now, I know that you weren't giving me an answer just so I can learn what VPad is actually used for. Thank you. Thank you really. and by the way, thanks for reminding me that touch and gamepad controls exist :/ Again, thank you. Have a good day! Edit: Or night..

iKNIFEu commented 4 years ago

Now this issue is fully closed, thank you Jcw87.