I made a very simple slide script that uses cframes, I also added the ability to cancel the slide movement when the player jumps but here is the issue:
the momentum of the player doesn’t carry on when he jumps [cancels the slide] obviously because I’m using cframes which has nothing to do with physics,
he just stops in place when he jumps rather than having some forward force/ momentum in the slide direction
another issue is that I don’t want the momentum to be based on the player weight since momentum = mass * velocity but rather be fixed for every mass so heavier players won’t have any advantages.
I thought about using vector forces but sometimes the player was able to slide through walls or just collide with something and get thrown away outside of the map probably because I don’t have much info about how to properly use it and optimize it.
I already use ray casting to cancel the slide movement and vector forces as I mentioned I don’t have much info about how to optimize it for my use case, done the research about it and couldn’t find anything useful.
so you need to keep setting the cframe after he jumps
– this is not working code its just to demonstrate my point
local speed = 0
local sliding = false
local slideDirection = Vector3.new(0, 0, 1)
runService.Heartbeat:Connect(function(deltaTime)
if sliding == true then
speed = 5
else
speed += -speed * 0.1 -- this will tween the speed down to 0.000000000001 (it will never reach 0)
end
character.PrimaryPart.CFrame += slideDirection * speed
end)
if you want to use vector forces then take a look at my video
the mass of the character does not effect the speed in this video the force is normalised based on the character mass