Announcement

Collapse
No announcement yet.

[Theory] Improving my Wall Jump script

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

    [Theory] Improving my Wall Jump script

    Hi everyone, this is another of my theory threads.

    I currently have a wall jump script that uses a trace to check for walls, it's very simple and I did it just to have something to work on.

    Now I need to improve it, because the character movement is blocked by a box instead of the cylinder, so when you try to jump in a 45º angle the trace is not long enough to reach the wall and the wall jump fails.



    (That picture is just so you can see the box bounding with the trace, it's not the actual length or distance)

    One of the solution is to make the trace longer, but that will make you do wall jumps at 90º without touching the wall. (See, walljumping when not touching the wall directly is not bad, but the distance would be too far).

    I tried the touchingactors iterator, but apparently it does not work with geometry level...

    So, do anyone have any ideas?

    #2
    I thought about doing that circle iterator around my pawn, but is that less or more expensive than the trace?

    Is there any way to check performance between different implementations?

    Comment


      #3
      Ummz I did have a think about this for you but I wasnt sure exactly what you want to accomplish. Basically cant you extend the trace if the player is holding two directions? I know in some instances air control and the mouse will get you moving at odd angles but its not going to be as severe as the 45 degree's you seem to be mentioning

      Comment


        #4
        Originally posted by MonsOlympus View Post
        Basically cant you extend the trace if the player is holding two directions?
        I thought about that, but "holding two directions" is too much vague and only covers the extremes angles.

        I was trying to do something with the rotator, when casting to vector it changes from -1 to 1.
        And the nearest to 0.6 the longer the trace needs to be.
        (So, a function that increases the output as the value get closer to 0.6 and lowers as it get out of that range)
        But I'm not very good with this kind of math.

        And Sen function works like that for 0.5 only, right?

        Comment


          #5
          Just if someone want to know I did this by converting the rotator to a vector and I was getting 0.7 in every corner (Where the trace needs to be the longest to reach the wall).
          Then I asked my friend to do a math function where 0.7 = 1 and are 0 at the extremes (0 and 1).

          So I use this function to increase the length of the trace on the corner, this is just to optimize and don't waste trace length, because I have to do a distance check to the wall even so because the trace length is not perfect.

          Comment


            #6
            That seems like a perfect plan, so once the player rotates to a 45 degree angle extend the trace a little bit so that it touches the wall but when hes directly facing the wall the trace goes back to its original length, if that's what your implying? : ]

            Comment


              #7
              Oh I get this now, the player is rotated thats not a velocity vector.

              Comment


                #8
                Originally posted by TheAgent View Post
                That seems like a perfect plan, so once the player rotates to a 45 degree angle extend the trace a little bit so that it touches the wall but when hes directly facing the wall the trace goes back to its original length, if that's what your implying? : ]
                Exactly.

                I could make the trace always big enough to work when the player is rotated, but I'm a optimizing freak D:

                Comment


                  #9
                  You should use extents!
                  Use your pawn's collisioncomponent's bounds' boxextent as the trace's extent.
                  Afaik that's how movement is "done" natively, too.
                  Thus the trace will look more like

                  or like

                  (I'm not sure about which one is closer to reality, so if someone clears that up, that'll be nice.)

                  Comment


                    #10
                    Originally posted by toxicFork View Post
                    You should use extents!
                    Use your pawn's collisioncomponent's bounds' boxextent as the trace's extent.
                    Afaik that's how movement is "done" natively, too.
                    Thus the trace will look more like

                    or like

                    (I'm not sure about which one is closer to reality, so if someone clears that up, that'll be nice.)
                    How do I use that, are you a wizard?

                    Comment


                      #11
                      I... am not a wizard! But thanks!
                      Well, look at the Trace function definition:
                      Code:
                      native final function Actor Trace( out vector      HitLocation,
                                                         out vector      HitNormal,
                                                         vector          TraceEnd,
                                                         optional vector TraceStart,
                                                         optional bool   bTraceActors,
                                                         optional vector Extent,
                                                         optional out material Material)
                      You can see the extent (second to last argument) variable, and if you specify it, it should work!
                      I'd try
                      Pawn.CollisionComponent.Bounds.BoxExtent
                      as the extent, or you can use
                      Pawn.CollisionComponent.Bounds.BoxExtent*vect(1,1, 0)
                      if you want to get rid of the "z" part, that's what I do to "only trace horizontally"

                      Comment


                        #12
                        Originally posted by toxicFork View Post
                        I... am not a wizard! But thanks!
                        Well, look at the Trace function definition:
                        Code:
                        native final function Actor Trace( out vector      HitLocation,
                                                           out vector      HitNormal,
                                                           vector          TraceEnd,
                                                           optional vector TraceStart,
                                                           optional bool   bTraceActors,
                                                           optional vector Extent,
                                                           optional out material Material)
                        You can see the extent (second to last argument) variable, and if you specify it, it should work!
                        I'd try
                        Pawn.CollisionComponent.Bounds.BoxExtent
                        as the extent, or you can use
                        Pawn.CollisionComponent.Bounds.BoxExtent*vect(1,1, 0)
                        if you want to get rid of the "z" part, that's what I do to "only trace horizontally"
                        Could you explain me what each X, Y and Z does when you use an Extent?
                        Like, what X control? What happens if I change it's value?

                        Thanks.

                        Comment


                          #13
                          extent describes the size of the box used to perform the trace.

                          Comment


                            #14
                            Yeah, so
                            z defines how "high" and "low" the box is going to be from its center
                            x defines how "long" it will be "forward" and "back" from the center,
                            y defines how "wide" it's gonna be.
                            These are in world coordinates, so if you rotate the trace, it doesn't matter, it will be the same size.
                            The "box" will follow the trace from start to end. If the box hits anything, it will stop, and the position relative to the box (its center) will be the hitLoc.





                            And, you can use this for your case, too, so a box will follow your pawn's trace, covering "possible movement obstacles", so that you will definitely know if there's something to walljump from.
                            Of course, as you can guess, it's not very precise.

                            Comment


                              #15
                              Thanks for the help!

                              Comment

                              Working...
                              X