input moveup key is not working help

the movement wont change verticaly, the ship i made works yet not respond for vertical axis, it not work
input is mapped with n and - m
please see here no error in print

please can someone inform how this can be done

  • put a print string after MoveUp - does it print?
  • new var 0 - what’s the value?

thanks the value was zero lol so i changed it to 300, thing is now vehicle contantly moving verticaly without input
i thought would only move when hit key, why it like this now

Use the axis value you defined:

Multiply it by the New Var 0.

not sure how multiply it right, went like this then it still float away

I think this is what @Everynone sugested.

2 Likes

also, if you have trouble with the input type in a math operation pin you can right click the pin and convert to a different type, like this, in this example there is no float convertion bacause i clicked in a pin thats already a float, if you click in a vectr type it will show the float option too :slight_smile:

thanks it worked this time was many hours with that print and could not find it.

i dont really understand wat was added though why it affect the play this way
i been on these prints a few weeks and managed build 3 vehicles, a jet car and ship that kinda hovers
and sometimes the code i add works and i dont know why…
its like a language with its own alphabet if could write like a sentence when required so not take much time

i will try to explain in detail whats happening in the code here:

1 - The InputAxis MoveUp node gets the player input and give you the ‘direction’ the player wants to move in the form of a float value, usually between 1 and -1. When you are not pressing any key the axis value will be 0. If you are using keyoard buttons the values will probably be 1 when you press ‘UP or W keys’ and -1 when you press ‘DOWN or S keys’.
This is a float value because if you want to use an analog from a xbox controller, for example, this value will gradually go from 0 (with the stick is released) to 1 (when the stick is all the way up) and to -1 (when the stick is all the way down), but in the analog controller it will have all the values in between, if the stick is half way up the value will be 0,5 and half way down -0,5.

2 - When you have an axis input the execution wire that goes from the InputAxis node to the Set Actor Location node will keep triggering the Set Actor Location with the InputAxis value of 0, but we usualy want it to trigger only when the player actually press the button or move the stick, so we get the input axis value and see if its == 0, if 0 the FALSE pin of the branch will be triggered, doing nothing, and when the value is not 0 the branch will trigger TRUE setting the actor location.

3 - Set Actor Location is pretty self explanatory, it will set the actor location to the location you put in the New Location pin.

4 - Self is just a reference to the actor you are coding, if its the ship blueprint in this case it will say, ‘hey im the ship’ and pass that info to Get Actor Location and Get actor Up Vector nodes.

5 - Get actor location will pick that self reference and get its location, self is the ship, so get the ship location in the world.

6 - With the same self reference the Get Actor Up Vector will basically tell you which direction the ship should go to go up.

7 - The ‘New Var 0’ is the value to tune your InputAxis with the speed you want the ship to go, higher values means a faster ship speed up or down. I would rename the variable from ‘New Var 0’ to something like ‘MoveUp Speed Multiplier’ for better organization of the code.

8 - Here we are getting the player input axis and multiplying by ‘MoveUp Speed Multiplier’ (New Var 0) /. So if the speed you set is 100 and player is pressing up the Axis Value will be 1 x 100 = 100. (back to the 1 topic, if its a controller and you are with the analog stick half way up and the Axis Value is 0,5, the math will be 0,5 x 100 = 50, so the ship will go up slower when the analog stick is not all the way up)

9 - This is getting the result of ‘player input x speed’ and multiplying by the Up Vector (topic 6) of the ship, if ‘player input x speed’ is positive it will point up, if negative will point down.

10 - Here we get the ship current location (Get Actor Location) and add the result of the 6, 7 ,8 and 9 topic i explained before. /. Basically get current location, see if the player want to go up (positive) or down (negative) and add the current location. Pick all that and give to the Set Actor Location node. Current Location + player input == new location.

(This requires a little bit of math knowledge to fully understand, not only blueprints, so i recommend you a very cool series of videos by [Freya Holmér] called Math for Game Devs, its math but is not that hard with a good explanation Vectors & Dot Product • Math for Game Devs [Part 1] - YouTube )

1 Like

thanks that helps my math is good, the piece with the branch makes sense thats what
i didnt know, so when no input = 0
cuz before i try map keyboard events not work, this way fine with branch and zero input

1 Like