I’m currently trying to use LinearVelocity to create a jetpack-like effect onto the player’s character. The main premise behind this is that the player’s character is shot-up into the air (on the Y-axis) until a particular point, say 100 studs from when the jetpack was activated, where they can then move on the X and Z axis (left and right) as though they were walking on the baseplate, whilst still being positioned constantly on that Y-axis.
The main issues that I am facing are as follows:
The player is positioned instantly, rather gradually over a period of time
The player cannot move on the X and Z axis (stuck in mid air)
The player has to jump first, in order for any of the above to occur, the effect should happen regardless if the player has jumped or not
I’ve attempted to directly alter the CFrame of the player to try and achieve the effect I am looking for, but the result looks glitchy and is not what I am looking for, whereas LinearVelocity seems to be the key for this effect, and I am either missing out something important or not understanding how to use it, or perhaps LinearVelocity is not the correct thing I should be using to create this effect.
For anyone interested in how I have used PlaneConstraints and AlignPosition, you can find my code below!
-- / VARIABLES & CONSTANTS \
local character = script.Parent.Parent.Parent
local humanoidRoot = character.HumanoidRootPart
local humanoidRootAttachment = humanoidRoot.RootAttachment
local jetpackHeightIncrease = 20
-- / MAIN \
humanoidRootAttachment.Orientation = Vector3.new(0, 0, 90) -- Ensures that the plane constraint functions on the Y-axis
-- Creating and configuring plane constraint target
local jetpackHeightPart = Instance.new("Part", game.Workspace)
jetpackHeightPart.CanCollide = false
jetpackHeightPart.Anchored = true
jetpackHeightPart.Transparency = 1
jetpackHeightPart.CFrame = humanoidRoot.CFrame + Vector3.new(0, jetpackHeightIncrease, 0) -- Adjusting the CFrame position to the height gained from the jetpack
-- Creating the attachment for the plane constraint target
local attachment = Instance.new("Attachment", jetpackHeightPart)
attachment.Orientation = Vector3.new(0, 0, 90) -- Ensures that the plane constraint functions on the Y-axis
-- Creating the effect of the jetpack gradually increasing player height, alternative: TweenService
local alignPosition = Instance.new("AlignPosition", humanoidRoot)
alignPosition.Mode = Enum.PositionAlignmentMode.OneAttachment
alignPosition.Attachment0 = humanoidRootAttachment -- The character will move alongside this attachment
alignPosition.Position = jetpackHeightPart.Position
task.wait(1)
alignPosition:Destroy()
-- Creating and configuring plane constraint
local planeConstraint = Instance.new("PlaneConstraint", humanoidRoot)
planeConstraint.Attachment0 = attachment -- The target or 'goal' attachment
planeConstraint.Attachment1 = humanoidRootAttachment -- The affected attachment