See I have a working flight system, but its really icky. The only way I thought of easily making it was using the mouse to point and fly in directions, but this isn’t my vision for what I wanted. I wanted a flight system that the player could control using WASD and freezes when the player isn’t using any of those keys. I’m not too versed in lookvectors, ect so I need some help with this if that could be provided! Thank you! Below is the code I’m using currently,
local flightCooldown = false
fire_curse:newAttack(Enum.KeyCode.J,function()
if flightCooldown then return end
print('flight')
local speed = 50
local extrakeybindcheck = "j"
local uis = game:GetService("UserInputService")
local char = plr.Character
local hum = char:WaitForChild("Humanoid")
local Torso = char:WaitForChild("UpperTorso")
local Mouse = plr:GetMouse()
local toggle = false
Mouse.KeyDown:Connect(function(key)
if key == extrakeybindcheck then
if toggle == false then
toggle = true
local BV = Instance.new("BodyVelocity",Torso)
BV.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
while toggle == true do
BV.Velocity = Mouse.Hit.lookVector*speed
wait()
end
end
if toggle == true then
toggle = false
Torso:FindFirstChildOfClass("BodyVelocity"):Destroy()
for i, stoptracks in pairs(hum:GetPlayingAnimationTracks()) do
stoptracks:Stop()
end
end
end
end)
end)
It looks like there is no acceleration and the player is changing speed instantly. If you add acceleration it should feel a lot better. To make the player hover, what I would do is raycast straight down to see if the player is close to the ground, and if they are high enough, let them hover instead of dropping.
I mean thats not really my issue right now, fluidity isn’t my problem. My main questions is how I would implement a system that didn’t use the mouse, and the player would just move around using WASD and where their camera is facing. I haven’t really used raycasting nor lookvectors much and just took advice from a friend.
The vector you are getting from the mouse can be replaced with a vector based on which WASD keys are pressed. You’ll probably want to get these relative to the camera, so that turning the camera and holding W is still effectively “mouse” controlled.