i made a dive for my game, it ragdolls the character, uses pivotto to position them off the ground since being in contact with the ground reduces forces by like 99% for some reason, and use apply impulse to apply the force in the direction the character is facing
after dying for some reason the dash doesnt go anywhere, im pretty sure this has something to do with the code for the input running twice despite having a debounce, this isnt the case after you respawn though, itll only fire once like its supposed to, something else thats probably the main problem is that the apply impulse just generally feels weaker, first i thought maybe its just not going anywhere since the pivotto isnt placing it high enough in the air so its still grazing the floor, if i put the character 10 studs into the air the first life its fine, after you die once though the apply impulse doesnt take you anywhere
thanks for reading, not sure if anyone knows whats up with this
some notes
this script is a character script, the player character has been changed
and whenever the character dies i loop through the characterscripts in starter player
and parent them to the new character through characteradded, which is also
where the character is replaced with the new one,
heres the code for the dive
local userInputService = game:GetService("UserInputService")
local ragdoll = game.ReplicatedStorage.ragdoll
local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
--local raycasting = false
local cooldown = false
local spring1 = game.SoundService["spring1"]
local spring2 = game.SoundService["spring2"]
local springs = {spring1, spring2}
local rules = RaycastParams.new()
rules.FilterDescendantsInstances = {character}
rules.FilterType = Enum.RaycastFilterType.Exclude
userInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift and humanoid:GetState() == Enum.HumanoidStateType.Running and not cooldown then
cooldown = true
--raycasting = true
-- this is just so that in the time it takes to raycast you cant dive again
--local result = workspace:Raycast(character.Torso.Position, Vector3.new(0,-4.5,0), rules)
-- check if player is on ground
-- for some reason this raycast breaks the debounce every other dive???
--raycasting = false
-- replaced raycasts with just checking if player is running
local torso = character:WaitForChild("Head")
local direction = torso.CFrame.LookVector + Vector3.new(0,0.5,0)
-- i do this before i ragdoll in hopes of it going in the right direction
ragdoll:FireServer()
local mass = character.PrimaryPart.AssemblyMass
character:PivotTo(character:GetPivot() * CFrame.Angles(math.rad(-40),0,0) * CFrame.new(0,12,0))
-- position off the ground since if youre in contact with the ground
-- forces do nothing, friction is crazy?
--task.wait()
print((direction * mass * 25).Magnitude)
torso:ApplyImpulse(direction * mass * 25)
springs[math.random(1,2)]:Play()
task.wait(2)
cooldown = false
end
end)
