I’m making a capsule based character controler in roblox, I’ve got the base movement working like jumping and walking and now I want to add functionality for stairs, so that the collider doesn’t get stuck on a step, I know a way to fix this issue, once the player gets near a step just teleport them upwoards based on the distance between the players feet and the top of the step, but thats the thing, how do i get that??
Here’s the collider and it’s collision detectors look like:
The ground detection collision is just for jumping, it does nothing here.
So basically whenever the blue collider detects a wall and if that wall does not collide with the wall collider then the controler considers that as a step, therefore it should teleport the player upwoards to compensate. Heres the code that detects that:
function checkForStep()
local stepParts = workspace:GetPartsInPart(collider:FindFirstChild("StepCheck"), ovParams)
local wallParts = workspace:GetPartsInPart(collider:FindFirstChild("WallCheck"), ovParams)
local step = false
for _, p in pairs(stepParts) do
if not table.find(wallParts, p) then
step = true
end
end
if step then
print("step")
local distFromFeet = (collision.Position - collision.Size.X/2) -- THIS IS WHERE I AM HAVING PROBLEMS, ITS NOT FINISHED
velocity = Vector3.new(0,200,0)
collision:ApplyImpulse(velocity*100*globalDelta)
end
end
(The checkForStep
function gets called every frame using RunService.RenderedStep)
In summary, just do this…