Announcement

Collapse
No announcement yet.

Help improving my Mario-style jumping setup

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Help improving my Mario-style jumping setup

    For a while now I've been trying implement Mario-style jump mechanics into my game such as being able to control the height of your jump by how the long the jump button is held (a.k.a. variable height jumping), and being able to take out enemies by jumping on them as well as bouncing higher off of them by holding the jump button down while doing so.

    I've managed to work out the mechanics for the most part, but I've been plagued with problems of my player character occasionally taking damage while jumping on the enemy. In order to fully explain what is very likely happening, I'll first need to explain the setup of the jumping & damage mechanics, starting first starting with the player's hit collision:

    Click image for larger version

Name:	collision.png
Views:	136
Size:	35.7 KB
ID:	1715838

    1.) This is the collision capsule for the player character, if an enemy touches this then the player takes damage.
    2.) This is jump collision box, which is actually more of a flat 2D plane rather than a box, attached directly below the collision capsule; if this box comes into contact with a vulnerable enemy then the player will bounce off the enemy's head and the enemy will take damage, with the player bouncing much higher if the jump button is held down.

    Next is the blueprint for jumping as a whole, including mechanics for variable height jumping, as well as SFX while jumping:

    Click image for larger version

Name:	jump_bp.png
Views:	333
Size:	197.5 KB
ID:	1715836

    And this is the Jump & Bounce function which is called upon in enemy blueprints to allow the player to be able bounce higher off of an enemy by holding the jump button:

    Click image for larger version

Name:	jump_and_bounce_bp.png
Views:	156
Size:	288.4 KB
ID:	1715837

    Next up is the Receive Damage portion from my player character's blueprint. Here is where the logic for the player taking damage is set up and is connected to a custom event that can then be called upon within the enemy's blueprint:

    Click image for larger version

Name:	receive_damage_bp.png
Views:	142
Size:	254.5 KB
ID:	1715840

    And lastly is the portions of the enemy blueprint related to the player taking damage from the enemy & jump collision. I thought I should also point out that the Receive Damage function targeted to the enemy is entirely separate from the Receive Damage custom event that handles damage to the player, I just didn't bother to give the two events different names:

    Click image for larger version

Name:	enemy_collision.png
Views:	141
Size:	381.9 KB
ID:	1715839

    Sorry for the long-winded explanation but anyways, the reason that the player is taking damage when they're not supposed to is that the player's collision capsule is coming into contact with the enemy when it shouldn't. The jump collision box in addition to dealing damage to the enemy is supposed to prevent this happening by bouncing the player upwards upon the jump collision box connecting with the enemy's collision capsule.

    I've been told somewhere else that the likely culprit behind this glitch is irregularities in tick timing, which I suspected might be the issue as I noticed that putting space between the jump collision box & the collision capsule appears to reduce the frequency at which the player takes damage from jumping on the enemy.

    To remedy this problem, I tried to number of things that were recommended to me such as adding a brief period of invulnerability for the player when jumping on the enemy and enabling Continuous Collision Detection (CCD) on the player's collision capsule. Adding the brief invulnerability period did help a bit, it hasn't completely fixed the problem, while Continuous Collision Detection's effectiveness isn't really obvious.

    Also likely tied to this problem is another glitch I've been experiencing where if I press the jump button in rapid succession while bouncing on an enemy results in the player bouncing rapidly in a manner that shouldn't be happening. The reason I suspect this glitch is related to the other one is because I've noticed that the player is far more likely to take damage while the jump button is being held down. This particular glitch is almost definitely the result of the Launch Character node that is used to control the jump height of the player character when the jump button is released. I've been told elsewhere that this node is very likely a major contributor to the irregular tick timing issue and should be replaced by something else.

    The problem with this though, is that I don't know what else I could replace the Launch Character node with. Unreal Engine 4's built-in Stop Jumping event doesn't cancel the player's jump when the jump button is released, while other solutions I've seen involving playing around with gravity & using timelines go way over my head and so I'm unable to implement these solutions myself.

    I was also recommended to increase the "Position Solver Iteration Count" but I'm rather hesitant to play around with values I don't understand what their function is.

    So does anyone know how I can control the height of my player character's jump by how long the jump button is held down without the use of the Launch Character node? Or any other methods of how I can better optimize my setup so that the player character no longer takes any damage from jumping on an enemy?

    Any help with this matter would be greatly appreciated!

    #2
    Can anyone please help?

    I noticed that I forgot to add the brief invulnerability phase for the player upon jumping on the invincible enemy I made for testing purposes, only applying it to the other proper enemy I made. Unfortunately though, adding the missing invulnerability phase only appears to have reduced the frequency at which the player took damage from jumping on the enemy & not eliminate it altogether.

    At this point the only options I see available so far are increasing the "Position Solver Iteration Count" which I still don't know what it is, and retooling my jump setup to get rid of the Launch Character node, which apparently is contributing to the problem. I just made a recent attempt at redoing my jump setup using the setup recommended in this topic, but it hasn't gone well:

    Originally posted by kenmorechalfant View Post
    I don't know why my question was merged in with this one. They are not the same at all.

    The OP for this thread does not want the jump delayed until the key is released, but rather, the jump should just add more velocity (mid-jump) if the key is held down longer.... Which can be accomplished with the CharacterMovement component included in the Character class.

    So, to the OP:

    In your Character's Construction Script, drag off a node from the Construction node and type "jump hold", under Character, look for "Set Jump Max Hold Time". Then, I would make an editable variable so you can more easily edit this on your Character later.

    [ATTACH=CONFIG]28467[/ATTACH]

    Now, when you select your Character (top left), you should see your editable variable in the Details panel.

    [ATTACH=CONFIG]28468[/ATTACH]

    Over in your PlayerController, you also want to make sure that your only actually calling Jump when the player "Can Jump"; and also make sure to call "Stop Jumping" when you release the key.
    Otherwise, you'll be able to infinitely 'double-jump'... going higher and higher... Which is probably not good.

    [ATTACH=CONFIG]28469[/ATTACH]

    I think that's all it takes.
    The problem I'm having with this setup, besides my character jumping way too high (necessitating changing their personal gravity, which in turn causes all sorts issues that need their own solutions), is it that my character is still taking damage as they did before, even when I'm not holding the jump button down.

    I absolutely cannot have this glitch in my game, but I just don't know what to do, everything I've tried so far either seems to only reduce the frequency at which the glitch occurs but not eliminate it altogether or does nothing to alleviate the problem.
    Last edited by Hungry Moogle; 02-04-2020, 02:43 AM.

    Comment


      #3
      As far as I can tell, the root of the problem seems to be that the Jump Collision Box's events aren't responding fast enough to launch the player character into the air before their Capsule Component comes into contact with the enemy's, resulting in the player taking damage. If this is indeed the cause of the problem then I need to somehow fix the response time of the Jump Collision Box so that it's events will fire off immediately every single time it comes into contact with the enemy, as opposed to right now where the response time appears to be rather inconsistent.

      Does anyone know how I can improve the Jump Collision Box's response time? I've already enabled Continuous Collision Detection (CCD) on the player's collision capsule, so what else can I do aside from maybe changing the "Position Solver Iteration Count", although I still don't know what that is and whether or not if that'll be enough to fix this issue.

      So please provide any help that you can if you're able, I desperately need the help.

      Comment


        #4
        I've read through your problem here and all I can say is that I agree that it (at least in part) has a lot to do with the planar jump collision box. Is it possible that the collision boxes on either the character or the enemy are firing more than once? If so, maybe a "doonce" node might help?

        Comment


          #5
          I've read through your problem here and all I can say is that I agree that it (at least in part) has a lot to do with the planar jump collision box. Is it possible that the collision boxes on either the character or the enemy are firing more than once?
          I don't know, how would I go about finding that out?

          If so, maybe a "doonce" node might help?
          I guess I'll check this out along with whatever "Position Solver Iteration Count" is, since I don't really have any other options available at this moment, so I'll take whatever I get. Thanks for the suggestion.

          Comment


            #6
            Sorry, I'm pretty new at all this. Fast motion + small collision box = problems... and I'd guess that CCD will help, but in extreme circumstances it just won't be enough. A finer iteration sounds promising too, but yeah... I really don't know.

            Comment


              #7
              So how did the developer Good-Feel manage to accomplish this in Yoshi's Crafted World, which was made with Unreal Engine 4? I don't know how jumping on enemies is done by professional game designers, so I just decided to use tutorials for melee combat like this as the basis for my own jump collision attempt. However, since it appears that what I'm trying to do is simply too much for Unreal to handle, I was considering the possibility of scrapping the entire Jump Collision Box setup I have right now and instead try Line Trace by Channel.

              In this video tutorial here, they use Line Tracing for taking out an enemy by jumping on them, so I was wondering if would possible to use Line Tracing to create a setup that would override the player's damage collision with the enemy if the Line Trace (or whatever the proper terminology is) comes into contact with them from above. I've never used Line Trace before so I'm not sure of the feasibility of my idea or how to set it up, so any input would be appreciated.

              Comment


                #8
                Awwww... now your just forcing me to learn stuff! LOL!

                Comment


                  #9
                  I've decided to go ahead and try use line tracing for my jump collision setup, using the tutorial I linked in my previous post [Link]. The idea I have in mind is to use the existing Null Damage - Player boolean to disable the Receive Damage custom event when the line trace hits the enemy. However, this will also require having to set up a branching path where if the player's line trace isn't in contact with the enemy, then the Null Damage boolean is disabled so the enemy can do damage to the player. Does anyone have any suggestions on the best way of accomplishing this?

                  Comment


                    #10
                    Can anyone help because I've never used Line Trace by Channel before and I can't find any examples of how to do a "else" condition for a line trace.

                    Comment


                      #11
                      Okay, after watching the whole video tutorial and contemplating how to re-tool the whole setup, I think I'm more lost than I initially thought I was. I'm having trouble trying to figure out how to get the player's Line Trace set up in a way that can then be called upon in enemy blueprints when contact is made.

                      Click image for larger version  Name:	enemy_collision.png Views:	0 Size:	381.9 KB ID:	1719098

                      I just simply don't know what to do, I'm in way over my head with all this Line Trace stuff and I am in a desperate need of aid.

                      Please help .
                      Last edited by Hungry Moogle; 02-09-2020, 01:15 PM.

                      Comment


                        #12
                        I'm not sure if this helps but here's a screenshot of the Line Trace as it set up in the tutorial I've been using.

                        Click image for larger version

Name:	line_trace.png
Views:	97
Size:	172.6 KB
ID:	1719211

                        Comment


                          #13
                          Can anyone please help, I have no idea what I'm doing . Its been well over a month and I still hasn't had any luck in trying to figure out how to use line tracing for jumping collision.

                          To reiterate what I'm trying to accomplish, I've been trying to create a branching condition where if the line trace detects a hit from the player jumping onto an enemy then said enemy will take damage, while damage to the player from colliding with the enemy will be disabled as long the player is making contact with the enemy.

                          I tried looking at other tutorials on line tracing such as this one [Link] for help to see if I could work something out but no such luck thus far.

                          Click image for larger version

Name:	line_trace.png
Views:	29
Size:	172.6 KB
ID:	1736675
                          I thought I could follow this previous example and create a Branch event connected to the Break Hit Result in order to set up the branching events from the line trace, but it appears that you can't directly connect a Branch event to the Break Hit Result. As a result of this, I'm stuck with no clear path forward and I just don't know what to do now. The only tutorial I've found on using line tracing for damaging enemies by jumping on them, is this one [Link], which is far too simplistic for my needs.

                          So how I do I use line tracing for jumping on enemies? I I desperately need help, as I have no others idea on what else I could do or where else I could turn for help.

                          Comment


                            #14
                            I know it can be frustrating knowing what you want to do, but it being just out of your grasp. I had the same thing happening to me for a couple months over a relatively small feature. I don't have an answer for you just yet, but wanted you to know that you aren't alone in any of this. I'm not an expert in any of these things, but I'm looking into your issue to see if I can be of any help. That being said, if anyone out there is reading this has some suggestions it would go a long way to chime in to at the very least let the OP know he's not just flapping in the breeze.

                            Comment

                            Working...
                            X