Announcement

Collapse
No announcement yet.

Character Walk on a Wall? (E.g Sonic running around a loop)

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

    Character Walk on a Wall? (E.g Sonic running around a loop)

    Is it possible to create a BP where a character can attach itself to a wall and run across it? For example, thinking about the Sonic games; When Sonic runs around a loop, would it be possible to pull off in a blueprint? I have no idea whatsoever on where to start!

    If someone could point me into the right direction; I'd be extremely grateful!

    - Ryan S
    KITATUS
    "Information shouldn't be behind a paywall, It should be free for all!"

    #2
    my first idea would be to run a trace downwards, get the normal from the hit and align the pawn to that. probably a very crude method with some issues along the line, but I don't see why it wouldn't work.

    Comment


      #3
      That seems a very complicated way as to what I had in mind; I was thinking something along the lines of "If Pawn is on "Floor", Ignore Gravity" - but alas, I cannot find any gravity functions in BP.
      - R
      KITATUS
      "Information shouldn't be behind a paywall, It should be free for all!"

      Comment


        #4
        Hello,
        I believe you could achieve this by constraining plane movements and play with forces.
        Luckily, UE4 have variables for planner movements ,you can find it if you go to defaults tab in your character then to planner movement.

        from there you can constraint the player movement to a particular plane

        Comment


          #5
          Originally posted by HoOz View Post
          Hello,
          from there you can constraint the player movement to a particular plane
          I've found it in the Defaults tab, but it doesn't let me let around a loop for example; He gets to a specific part of the loop (90 degree) and can't run up anymore. I'm trying to figure out how to get it to ignore gravity while the player is on the loop.
          KITATUS
          "Information shouldn't be behind a paywall, It should be free for all!"

          Comment


            #6
            You could use the "Set Enable Gravity" node to turn the gravity off on your player, then apply your own force using the "Add Force" node in whatever direction you like to simulate gravity.

            Comment


              #7
              Originally posted by Funkenstein View Post
              You could use the "Set Enable Gravity" node to turn the gravity off on your player, then apply your own force using the "Add Force" node in whatever direction you like to simulate gravity.
              But around a 360 loop, wouldn't this mean I'd have to add force 360 different times in order to make the character stick to the loop completely?

              I tried doing this, but the Blueprint doesn't seem to function AT ALL. Weird. I mean it compiles fine, saves fun, casts from GravZone1 (Trigger Volume) to player, but the player doesn't get affected by the gravity. I did a "Print String" to find out if it's actually working. The "Set Gravity" target doesn't seem to be working.

              There must be a solution; a simple one that I'm overlooking. I mean I have a loop mesh and a character, surely there's some simple thing I'm missing where when the actor touches the mesh, he clamps to the mesh? :/
              KITATUS
              "Information shouldn't be behind a paywall, It should be free for all!"

              Comment


                #8
                Good question. I have never tried to apply gravity when the player is colliding with a large complex object.
                I only know on simple objects you can get the "normal" direction from a collision which still might work in this case.

                Try using a collide event and getting the normal from it so you can apply your gravity inversely.

                Comment


                  #9
                  Originally posted by Funkenstein View Post
                  Try using a collide event and getting the normal from it so you can apply your gravity inversely.
                  Still no luck, the player just doesn't want to be affected by the Gravity... Weird. Maybe there's a way to just simply connect the player to the prop while he's touching it? I can't seem to find it but it must exist.

                  I guess one way to make this work could possibly be to take control away from the player, switch to Matinee with a custom animation of going around the loop, but that's not an ideal solution; Especially if I wanted two players to play.
                  KITATUS
                  "Information shouldn't be behind a paywall, It should be free for all!"

                  Comment


                    #10
                    Originally posted by KitatusStudios View Post
                    Still no luck, the player just doesn't want to be affected by the Gravity... Weird. Maybe there's a way to just simply connect the player to the prop while he's touching it? I can't seem to find it but it must exist.

                    I guess one way to make this work could possibly be to take control away from the player, switch to Matinee with a custom animation of going around the loop, but that's not an ideal solution; Especially if I wanted two players to play.
                    I think the approach of transitioning to and from an animation might be the best approach here. You can decrement a variable if the player stops pressing forward, and switch back to the standard player control to break out of the animation when the player lets go of the controls at the top of the loop, or perhaps just isn't going fast enough.

                    Comment


                      #11
                      Originally posted by saluk View Post
                      I think the approach of transitioning to and from an animation might be the best approach here. You can decrement a variable if the player stops pressing forward, and switch back to the standard player control to break out of the animation when the player lets go of the controls at the top of the loop, or perhaps just isn't going fast enough.
                      But can you control a player controller with matinee and instantly let them have the control back? I didn't think this was possible.

                      EDIT: Just tried this with Matinee; It won't let me hide / remove / edit the player. I tried animating the player pawn but nope, wouldn't even let me add it into Matinee. Am I doing something wrong there? I tried deleting the player, hiding the player and using an animated static mesh of the character running over the loop; But the player just won't hide / remove / move, the static mesh does, but the camera in matinee and even in the player won't respond to what I'm trying to do.

                      EDIT EDIT: I noticed Sonic GDK/UDK managed to pull this off in UDK; But I didn't use UDK and I can't find where they would've set their loop to attach to their Sonic. I tried looking in their Kismet, but couldn't find anything and I tried looking through the UnrealScript, but their pawn is just a regular pawn.
                      KITATUS
                      "Information shouldn't be behind a paywall, It should be free for all!"

                      Comment


                        #12
                        This sounds pretty fun!

                        Originally posted by KitatusStudios View Post
                        but the player doesn't get affected by the gravity. I did a "Print String" to find out if it's actually working. The "Set Gravity" target doesn't seem to be working.

                        There must be a solution; a simple one that I'm overlooking. I mean I have a loop mesh and a character, surely there's some simple thing I'm missing where when the actor touches the mesh, he clamps to the mesh? :/
                        Gravity doesn't affect the character when they're walking, only falling, flying, and swimming.

                        If you want to take a sort of physical simulation approach, here is my suggestion:

                        - Allow a walkable surface normal up to right about 90 degrees (vertical)
                        - Set MaintainHorizontalGroundVelocity to false in your CharacterMovementComponent. This means movement speed will be relative to the surface rather than a flat plane.
                        - Detect when you hit a surface that is too steep and you start "falling" (you should get a OnMovementModeChanged event).
                        - At this point, send the character upwards with a velocity tangential to the surface where you stopped being able to walk. You might try GetPhysicsLinearVelocity() on the capsule, or extrapolate from the character movement component velocity (which is only going to be in XY since it was walking; this is a little confusing I know, but the magnitude should be correct).

                        Basically the goal here would be to run up as high as possible, and then launch the character upwards in falling mode so that they basically undergo a physics sim that should cause them to glide around the top of the loop. If they make it around to the other side, they will hit a walkable surface and resume running. If they didn't have enough speed, they could fall off the loop at some point.

                        Since you're falling, you can modify gravity if you like (note the GravityScale variable on CharacterMovementComponent that you can use rather than change world gravity, which would be safer for multiplayer). You also may want to fiddle with UpperImpactNormalScale if you find that the collision is a bit strange on the upper portion of the capsule (probably just set it to zero).

                        ---

                        An alternative could be to place a trigger that is activated only on appropriate velocities (ie moving up the steep part of the loop), and then attach the character to a path that takes them around the loop to the other side (this is probably the Matinee solution). This would be a bit different than Matinees in UE3: you'd want to attach to an actor that interpolates using a matinee actor along the loop, and try to control the speed based on the initial velocity.
                        Zak Middleton
                        Sr. Engine Programmer, Epic Games

                        Comment


                          #13
                          Cheers Zak, I'll give it a try now and report back!
                          KITATUS
                          "Information shouldn't be behind a paywall, It should be free for all!"

                          Comment


                            #14
                            So I tried following your steps; But as I realised as I put it together; Since this is taking over the falling state; When a character jumps, he immediately flings to another side of the map. Is there anyway to stop this from happening; Do I have to create a custom state? But even then, if a character were to fall to the side of the loop as he was looping, he could possibly fling off to another side of the world. I suppose I could fill that part in with a blocking volume, but this volume would overlap the entry / exit points of the loop thus making that most probably the least effective way of doing it.

                            Here is the blueprint, in case I've totally messed up:

                            Click image for larger version

Name:	sPLPx8y.jpg
Views:	1
Size:	160.2 KB
ID:	1050095

                            Mirror:
                            KITATUS
                            "Information shouldn't be behind a paywall, It should be free for all!"

                            Comment


                              #15
                              Ah so I guess the trick is knowing that this falling state is happening because you have run up your loop, rather than something else (like manually jumping or running off the edge of something).

                              You might try tracing forward in the proposed velocity first, to see if you actually hit geometry that you care to use this with. So sweep a capsule forward a short distance and either check the type of the actor, physical material, impact normal, etc and then decide if you want to add this velocity or not.
                              Zak Middleton
                              Sr. Engine Programmer, Epic Games

                              Comment

                              Working...
                              X