local function doDive()
DivePermission = DivePermissionEvent:InvokeServer(Humanoid)
if not DivePermission then return end
if Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
Humanoid:ChangeState(Enum.HumanoidStateType.Flying)
emitRollEffects(true)
Root.Velocity = Root.CFrame:VectorToWorldSpace(
Vector3.new(0, Humanoid.JumpPower * DIVE_POWER, -Humanoid.WalkSpeed * DIVE_LENGTH)
)
Root.RotVelocity = Root.CFrame:VectorToWorldSpace(
Vector3.new(-math.rad(DIVE_ROT), 0, 0)
)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
Humanoid:GetPropertyChangedSignal("FloorMaterial"):Once(function()
if Humanoid.FloorMaterial ~= Enum.Material.Air then
rollAnim:Play()
task.wait(rollAnim.Length)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
end
end)
else
Root.Velocity = Root.CFrame:VectorToWorldSpace(
Vector3.new(0, 0, -Humanoid.WalkSpeed * DIVE_LENGTH * 2)
)
rollAnim:Play()
emitRollEffects()
end
end```
Above is the code snippet.
When the dive or roll is "activated", the player's jump state is disabled, and then enabled again when touching the ground (which is checked by the floormaterialchanged event).
But, very rarely, the event doesn't work properly, making the player not be able to jump permanently.
How do i fix this?
#Help with roll and dive edge case
1 messages · Page 1 of 1 (latest)
I would do a sphere cast for if the players on an edge or something
I tried this myself,
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.FilterDescendantsInstances = {Character:GetDescendants()}
local direction = -Root.CFrame.UpVector * 5
local origin = Root.Position
local raycastResults = workspace:Raycast(origin, direction, raycastParams)
visualizeRaycast(origin, direction)
if raycastResults then
print(raycastResults.Instance)
rollAnim:Play()
task.wait(rollAnim.Length)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
end
Works fine right now for normal surfaces, but how about walls and/or slopes?
(haven't used sphere casts yet bc only for tests)