How to add continuous forward motion to my pawn which is a cube?
So I've tried replacing the input axis forward node with the event tick node (in third person side scroller character) and that didn't work. I've tried to plug an add movement input directly into event tick and nothing. I've tried everything I can find. Basically I've got a cube as a static mesh in an actor blueprint class, I want this cube to be what the player will control throughout the game. However, the only thing the player will control is the jump as seen in something like geometry dash or flappy bird, but i can seem to achieve any motion whatsoever with this cube. The images below are the blueprints that didn't work. All in all, all i want is the cube (Pawn blueprint class) to move forward continuously and maybe even speed up but i haven't even thought about doing that. I'm also new to blueprint scripting so sorry if it's really obvious.
asked Jan 07 '18 at 05:25 AM in Blueprint Scripting
The reason that your cube doesn't move is because you don't have any Movement Component attached to it. If you look at the default Side Scroller Character blueprint, you'll see that it has an inherited Character Movement Component in its Component list. Movement Component is necessary to handle all unique behaviors of your pawn. The nodes such as Add Movement Input are in fact interface functions that work in conjunction with a movement component. They don't have any movement logic themselves! If you know C++, you can code your own Movement Components and create interesting and unique movement behaviors! Take a look at this official tutorial to get started with custom pawn movement.
In case of your cube movement, you can easily accomplish the movement behavior you want by adding a Floating Pawn Movement component to your Pawn blueprint. Just as you would add a mesh or camera to your Pawn, click on the Add Component and search for Floating Pawn Movement. Once added, select it and tune its movement parameters to your liking. To properly use it, you need to call the Add Input Vector node and give it a direction vector. The following picture shows how you would do this for sideways movement along Y axis. For another example of how to using this, see my other post in here.
Alternatively, you can take advantage of Unreal Engine physics system and move your pawns or static meshes by applying different kinds of forces and torques to your static mesh. Here's a very simple setup that shows how this can be achieved for a static mesh such as your cube:
Note that in the above scenario, applying this force is similar to giving your mesh a constant acceleration. Its speed keeps increasing as long as the input key is held down. You can also lock rotations of your cube mesh to prevent it from rolling around.
Hope this helps.
answered Jan 07 '18 at 08:46 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here