[ANSWERED] How to make BodyVelocity only change 1 axis velocity?
Asked by
5 years ago Edited 5 years ago
The question says it all. How would I make BodyVelocity only change 1 axis? The BodyVelocity is in the players head and I am trying to make the player go up at a constant rate when they press SPACE without affecting their WASD movement (x and z-axis) but, when in mid-air, their WASD movement gets suspended and they travel up only. How can I make it so that body velocity only affects their y-axis?
I tried this:
01 | local bodyvelocity = Instance.new( "BodyVelocity" ) |
02 | bodyvelocity.Parent = character.Head |
05 | mouse.KeyDown:connect( function (key) |
06 | key = string.lower(key) |
07 | if string.byte(key) = = 32 then |
09 | bodyvelocity.Velocity = Vector 3. new( 0 , 1 , 0 ) |
This is in a Local Script in the player. 'character' and 'mouse' are defined. The script works but when flying up, the player can no longer use WASD to move their x and z-axis. How would I make the BodyVelocity only affect the y-axis and still allow WASD movement?