What is the best way to go about making an airwalk system?
The current system I have uses a BodyPosition with a max force of 0 for the x and z values so the player can move with WASD, but this leads to the player looking like they are just floating and suspended in free fall.
I want to give the impression that the player is actually moving through the air with their legs. What alternatives would allow me to do this, but keep the same functionality?
I am looking for an effect similar to the anime Bleach:
You might be able to spawn a small invisible platform under the player’s feet which updates it’s CFrame to constantly follow the player in all directions.
As a rough pseudo-code guide, you could use these functions:
-- some variables you want set up
local airwalking = false
local airwalkPlatform = nil
-- call this when the player starts their airwalk
function airwalkStart()
airwalking = true
airwalkPlatform = Instance.new("Part")
airwalkPlatform.Anchored = true
airwalkPlatform.Transparency = true
airwalkPlatform.Size = Vector3.new(4,1,4)
end
-- call this when the player completes the airwalk
function airwalkEnd()
airwalking = false
airwalkPlatform:Destroy()
end
-- you will need some way to update the part's position on each Physics Step
game:GetService("RunService").Heartbeat:Connect(function()
if airwalking and airwalkPlatform ~= nil then
--The -3.5 is determined by the distance from the ground to the position of the HumanoidRootPart, plus half of the height of the part itself as defined in airwalkStart()
airwalkPlatform.CFrame = CFrame.new(character.HumanoidRootPart.Position + Vector3.new(0,-3.5,0))
end
end)
If you had any issues with the invisible part colliding with unwanted things, such as unanchored objects or other players, you can set up Collision Groups to mitigate that issue. It should also be fairly easy to add your desired effects and graphics as needed.
Then you change it to .idle when the player stops moving.
Give @BirdieI90’s answer a try first. It’s probably the easiest thing to do.
Although instead of resetting it to 0 after you should get their original hipheight and store that then reset it to that value.