How to Move my Pawn up on z axis on key press and return to its previous location on release

Hi all,
I have a Pawn that needs to jump on z when a key is pressed and should return to its position on the act of key release. I simply created a BP for moving up. The movement is kind of a Step. its not fluidic. I dont know how to return it back to its position on key release. Thanks in advance!

If you don’t care by using a step-like movement then try scaling by -1 the vector when you release the flap button like this.

If the actor rotates on any of the X or Y axis this probably won’t work because the Up vector isn’t aligned to the Z axis, in that case you could just use the Height variable directly.

1 Like

Thanks for the quick reply. Actually my BP is resulting in a step movement which i dont want. I want it to be fluidic. I ll try u r method. Thanks once again!!

Hi Kaldosail,

InterpTo will help you achieve some fluidity!

Also note that I’m using ‘SetActorRelativeLocation’ node instead of ‘AddActorLocalOffset’

Let us know if you have any more questions.

1 Like

Hi Astrotronic,

Unfortunately its not working. On the game play, the Board starts to fall down. I dont know wat to do

image

Are you making a flappy bird?

no… this is kind of just a plank and start hitting the ball untill u miss it out

The plank should go up on pressing a key and return to its previous position on release.
The plank is movable in fwd/rwd left and right direction as well. I did the movements. only this moving on z is not working for me

Sounds like we’re making a 3d arkanoid, how close is this:

Is bouncing allowed? If I hold the Jump key, do we stay up in the air?

yeah more or less. btw how did u take this video output?

no bouncing. The more you hold the more higher it can go on

1 Like

A pawn with a movement component:

Produces this:

The world vector is the speed you go up / down. Make sure you put a negative value as default - think of it as of simulating gravity.

video output?

Gyazo.

Thank you!!. I ll check it out right away.

1 Like

Thanks for the reply. it works well. But when released its not returning to the position from where it bounced up. becoz of the vector value is negative it keeps falling down on release

Place a blocking collision volume underneath.


Alternatively, check the Z value of the Pawn and if it drops below a desired threshold, stop adding negative input - either with a Branch or Gate.

So, initially, I’m thinking that you need to create three unique variables: two bools and a vector. For this example, let’s call the first bool “IsOriginalPosition” (default value = true), the second bool “InitialPress” (default value = false) and let’s call the vector “OriginalPosition”. (name the variables whatever you want)

On press, use a branch to check if the IsOriginalPosition bool is true. If it is true, set the vector variable to equal the actor’s current world location and then set the IsOriginalPosition bool to false. Add a do-once node right after that sets the InitialPress bool to true.

Use whatever method you’d like to move the actor upwards so long as it’s while the IsOriginalPosition bool is false.

On release create a branch to check if the InitialPress bool is true. On True, set InitialPress to false and then create a looping timeline.

On the timeline’s update, create a branch that checks if the actor’s world location is (NEARLY) equal to the OriginalPosition vector.

On the false option of the branch, use whatever method you’d like to move the actor downwards.

On the true option of the branch, set the bool IsOriginalPosition to true and then create a sequence node with the first event in the sequence unlocking the Do-Once node from earlier and the second event in the sequence to stop the looping timeline.

Kind of like creating your own moving platform that the player can directly control to some degree. This method should prevent the player from repeatedly pressing the button and continuously going upward before the actor has returned to its original position.

Hi, Thanks for the reply. I find it really difficult to understand becoz, I am a super noob!!.
I will give it a try and let you know. Thanks once gain for the post!!

Is this the result you are looking for?

Exactly :smiling_face_with_three_hearts:

Can you share a screenshot of the bp pls?