Announcement

Collapse
No announcement yet.

How To Make A Cube Character Rotate When Jumping?

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

    How To Make A Cube Character Rotate When Jumping?

    I been trying to make a static mesh cube character to rotate while it jumps. The cube moves forward by itself, but I can make it jump whenever I press the space keyboard and move sideways only (the cube doesn't stop). Once I do that, I want the cube to rotate mid air forward and once it lands it gets back to normal. How can I do that? Do I have to make the blueprints for the jumping function or the movement for the cube?

    #2
    The simplest way to rotate is to add a RotatingMovementComponent to your blueprint and activate it on jump and deactivate on landing. You'd just need to either get your rotation speed right to have it land flat again, or rather handle the land rotation after deactivating the RotatingComp with a timeline and lerp possibly. Not sure of which is better, maybe someone else has done that before and provide guidance.

    For jumping there is actually a built in function: check here for some guidance: https://answers.unrealengine.com/que...e-jumping.html
    SolidGasGames

    Comment


      #3
      Originally posted by Telimaktar View Post
      The simplest way to rotate is to add a RotatingMovementComponent to your blueprint and activate it on jump and deactivate on landing. You'd just need to either get your rotation speed right to have it land flat again, or rather handle the land rotation after deactivating the RotatingComp with a timeline and lerp possibly. Not sure of which is better, maybe someone else has done that before and provide guidance.

      For jumping there is actually a built in function: check here for some guidance: https://answers.unrealengine.com/que...e-jumping.html
      Adding the RotatingMovementComponent to the Jump blueprint does work, but not quite right. The cube starts rotating sideways as soon as I jump and won't stop rotating.

      Comment


        #4
        and won't stop rotating
        You can disable the rotation of the component when the cube lands.

        On the other hand, do you care whether you land flat on a face or is landing on the edge ok? If you want to perform precise multiples of 90 degree spins, use a timeline. You can use the same one for jumping and spinning. Or is this physics based and you want to let the chips fall where they may?

        Comment


          #5
          Originally posted by Everynone View Post

          You can disable the rotation of the component when the cube lands.

          On the other hand, do you care whether you land flat on a face or is landing on the edge ok? If you want to perform precise multiples of 90 degree spins, use a timeline. You can use the same one for jumping and spinning. Or is this physics based and you want to let the chips fall where they may?
          I want the cube to land on its face. The cube moves forward by itself. I only control it whether to move it left or right and jump. Sorry, but could you please tell me how to disable the rotation once it lands? I'm new to UE, but not that new. Also, how can I use this timeline thing?

          Comment


            #6
            Have a look this, my 10min take on the matter - it's not much but perhaps can get you started:

            Click image for larger version  Name:	Capture.PNG Views:	1 Size:	361.1 KB ID:	1622784
            vid:

            https://i.gyazo.com/910f728122c5a121...2d63e85b34.mp4

            It's quite limited but can be improved, of course. Ask away if you have any questions.

            Comment


              #7
              This is what I have for the character movement (cube). It allows the cube to move forward non-stop. I can control it so it can move sideways and jump only. However, when I tried to follow your blueprints, for the timeline, I'm not sure how to have does "Spin" and "Jump Spin" connections. Also, I don't think this would work with my movement blueprints since you have an Event Tick connected to Add Movement while I got some other settings.
              https://blueprintue.com/blueprint/0cpvao_t/

              Also, for the jumping part, I only have InputAction Jump connected to Jump.

              Comment


                #8
                for the timeline, I'm not sure how to have does "Spin" and "Jump Spin" connections
                Double click the timeline to open it, add a float track - the f in the upper left corner. Shift-click the graph to add keys, change their time / values, right click keys to change interpolation method, set the length of the time line. More on timelines:

                https://docs.unrealengine.com/en-us/...uide/Timelines

                and here:

                https://www.youtube.com/watch?v=v7bdcvGlgIg

                They're pretty essential and incredibly useful, time well invested.

                You can leave the movement as is, it should work fine.

                Comment


                  #9
                  Originally posted by Everynone View Post

                  You can leave the movement as is, it should work fine.
                  You said I can leave the movement as it is. So, what exactly can I change then? Can I just leave everything I have the same way and just plug in the timeline to the MovingForward event or the InputAction Jump event?

                  Comment


                    #10
                    Originally posted by TheGamingInc View Post

                    You said I can leave the movement as it is. So, what exactly can I change then? Can I just leave everything I have the same way and just plug in the timeline to the MovingForward event or the InputAction Jump event?
                    The timeline is only updating the static mesh component going up / down and its rotation in Relative Space - it has no effect on forward movement whatsoever; the actor can do its own thing here. I used Tick for movement as you mentioned the cube moves on its own (in your example you actually do use input, though). The above is just an example of how to implement a timeline component rather than an immediate solution to all the intricacies the movement may involve. The whole lot can be easily expanded from this point, if you wanted to tie a number of mid-air spins to the height of the jump, it's quite easy to do so as Timelines suggested by @Telimaktar are more than versatile enough. You can also adjust the curves and points of the TL to get the desired jump / spin characteristics as well as hook up proper variables to drive the whole thing.

                    I do not know how you set up your Pawn / Character, you've included no details regarding what the end goal is or how the movement is supposed to work apart from:

                    The cube moves forward by itself, but I can make it jump whenever I press the space keyboard and move sideways only (the cube doesn't stop). Once I do that, I want the cube to rotate mid air forward and once it lands it gets back to normal.
                    And this is what the script does, as seen in the vid. It's built to your specifications so to speak ;p
                    Last edited by Everynone; 05-23-2019, 02:58 AM.

                    Comment


                      #11
                      [QUOTE="Everynone;n1622969"]
                      I do not know how you set up your Pawn / Character, you've included no details regarding what the end goal is or how the movement is supposed to work apart from:
                      /QUOTE]

                      It's exactly how I explained it. There is nothing more into that. Basically, the game is similar to those endless runner games where the character start running by itself and you only control it to turn left, right or jump. However, mine just goes straight (there are no corners to turn) and you only need to avoid the obstacles and jumping. The problem is that I would love to have an animation for when the cube jumps to make it look better.

                      Comment


                        #12
                        So that's exactly what the script does, no? Have you implemented any of it, is it working? Can you show the progress?
                        Last edited by Everynone; 05-23-2019, 01:07 PM.

                        Comment


                          #13
                          Originally posted by Everynone View Post
                          So that's exactly what the script does, no? Have you implemented any of it, is it working? Can you show the progress?
                          I'll test it.

                          Comment

                          Working...
                          X