Moving a cube

Hello everybody,
I am new @UE4 and I code by myself with an other engine in my freetime :slight_smile:
I make a dynamic cube that you can move by WASD. It move with a linear velocity. You can jump (twice) if you hit the spacekey and you can look around with the mouse.
Here is a small video I load up so I can show you what I mean.

https://www.youtube.com/watch?v=LLBKwm8g7P4 (23 sec)

I tryed to reproduced this in the unreal engine but with no success :frowning: I tryed with with the examples ā€œThird Personā€ and ā€œRollingā€. I thought I can just replace the character in the ā€œThird Personā€ example model with a dynamic primitive and its done …
I also tryed to move a cube with linear velocity in BP and change the torque to linear velocity in the ā€œRollingā€ example. It move but without the rolling effect like in the video. Also I can just move left and right not foward and backward :smiley: .
On top of that I have no idea how to make the camera so that it follow the player and you can rotate it with the mouse.

Have someone some idea or tips how I can reproduce the video with the UE4 ?

I personally always like to start with a blank project.

So first, I would make a new character blueprint.
In the components tab, add a static mesh, make it a cube. On this cube… I think you will need to enable physics in the details panel.
Then, add a camera boom and a camera, make the camera a child of the boom. Set the camera to the approximate distance away from the cube that you’d like. Also, there’s a setting on the camera, something like ā€œTry to use the rotation of the pawnā€, make sure that’s disabled. Actually that might be on the ā€œDefaultsā€ tab of the blueprint. In any case, it will make it so the camera tries to rotate with the cube which will just make you sick with this setup :slight_smile: .

In the event graph… this is where it gets trickier with the moment controls. In the video, I can’t tell if the cube is moving purely due to rotation, but it looks that way.
So… Pressing ā€œWā€ should rotate the cube in the direction the camera is facing, Pressing ā€œSā€ should rotate the cube towards the camera, pressing ā€œAā€ should rotate the cube to the left and ā€œDā€ to the right.

I had a few paragraphs typed up here, but I’m having a tough time coming up with the solution. You can use the camera’s forward vector to get the direction in which the pawn should rotate along with Add Controller Pitch Input and Add Controller Roll Input to do the actual rotating, but I’m not sure of a good way to take the directional vector and turn it into a rotator. Maybe someone smarter than me can weigh in on that.

Now we need to be able to move the camera. Under the second menu in the editor window, I think it’s ā€œEditā€ or ā€œPreferencesā€ or ā€œsettingsā€ā€¦ I can’t remember. In any case, the menu that has ā€œProject Settingsā€ as an option. Go in there, go to the ā€œInputā€ tab on the left. Here, you should see axis mappings. Add one for Look Up, select Mouse Y from the dropdown, and Look Down, select Mouse X from the dropdown, setting the scale to 1 for each.

Now back in the event graph, right click and add an event for ā€œLook Upā€. This should get triggered whenever the game detects you’ve moved the mouse on the Y axis. If you link this up to a Add Pitch Input node (make sure to link the output of the ā€œLook Upā€ to the input of the ā€œAdd Pitch Inputā€ node), I believe that should rotate the camera up and down. Do a similar thing with the ā€œLook Rightā€, linking it to a Add Pitch Input node. I think that should be it for the camera.

The only thing left is jumping and double jumping, I think. ā€œJumpā€ is a standard function in the Unreal Engine. If you create a new event ā€œSpaceā€ and link a ā€œJumpā€ node to it… I’m honestly not sure what will happen. Normally, the pawn jumps upwards, completely normal. But I’ve never done this with an actor that rotates like the cube. You may need to use the Launch Character node instead. In either case, I believe you will need to use the ā€œLaunch Characterā€ for the double jump (I think the standard ā€œJumpā€ function only works if on the ground). I’ve done this recently, here’s how I set it up.

Note: This might not be perfect, I’m at work and can’t test it. I also had to piece it together in MSPaint from other images I found.

So that should allow them to ā€œjumpā€ one additional time while in the air. Replace the ā€œ1ā€ in the ā€œLaunch Velocityā€ on the launch character node with however strong you want the jump to be. Probably closer to 300-500.

Ok, well that’s about as good as I can do with the resources at hand, but hopefully this at least gives you a starting point.

Thank you for you detail answer =)
I will try everything in the next few days :slight_smile: