I’d like to make Bunny Hop with creating a new VectorForce based on Workspace.Camera.CFrame.lookVector so that when the player jumped it was created a vector force pushing it in the direction of the camera for 0.5 seconds and then destroying the vector Force
VectorForce Creating with wrong direction
I tried to change the values given to the vectorForce() function but it didn’t work
Here`s the code:
-- Functions
function vectorForce(Vector)
local VectorForce = Instance.new('VectorForce')
VectorForce.Parent = char.HumanoidRootPart
VectorForce.Attachment0 = char.HumanoidRootPart.RootAttachment
VectorForce.Force = Vector
print('forceApplied')
end
function clearForce(location)
for i,v in pairs(location:GetDescendants()) do
if v:IsA('VectorForce') == true then
v:Destroy()
end
end
end
-- Bhop Control
humanoid.Running:Connect(function(speed)
print(speed)
if speed > 11 then
if not RunAnim.IsPlaying then
RunAnim:Play(1,1,2)
CameraUp:Play()
SpeedUp:Play()
forceApplied = false
end
UIS.InputBegan:Connect(function(input)
if speed > 11 and input.KeyCode == Enum.KeyCode.Space and humanoid.MoveDirection.Magnitude > 0 and BHopCooldown == false then
BHopCooldown = true
vectorForce(Camera.CFrame.lookVector * 1000)
print(Camera.CFrame.lookVector * 1000)
wait(0.5)
--clearForce(char.HumanoidRootPart)
BHopCooldown = false
end
end)
Have you tried using my actual solution to the issue? That post is just me correcting @MikeartsRBLX. LOL! I was not expecting my answer to solve this issue.
If you defined the variable “Camera” before you started bhopping, I’m pretty sure it’d get the lookvector from the time you defined it. Try re-defining / updating the camera variable every time you want to bhop.
-- Functions
function vectorForce(Vector)
local VectorForce = Instance.new('VectorForce')
VectorForce.Parent = char.HumanoidRootPart
VectorForce.Attachment0 = char.HumanoidRootPart.RootAttachment
VectorForce.Force = Vector
print('forceApplied')
end
function clearForce(location)
for i,v in pairs(location:GetDescendants()) do
if v:IsA('VectorForce') == true then
v:Destroy()
end
end
end
-- Bhop Control
humanoid.Running:Connect(function(speed)
print(speed)
if speed > 11 then
if not RunAnim.IsPlaying then
RunAnim:Play(1,1,2)
CameraUp:Play()
SpeedUp:Play()
forceApplied = false
end
UIS.InputBegan:Connect(function(input)
if speed > 11 and input.KeyCode == Enum.KeyCode.Space and humanoid.MoveDirection.Magnitude > 0 and BHopCooldown == false then
BHopCooldown = true
Camera = workspace.CurrentCamera
vectorForce(Camera.CFrame.lookVector * 1000)
print(Camera.CFrame.lookVector * 1000)
wait(0.5)
--clearForce(char.HumanoidRootPart)
BHopCooldown = false
end
end)