I want to make the player able to jump through the bottom of a platform, and stand on the top. But, i really have no idea how to make this work. Any ideas?
Video of what I mean:
This is a clip from a platform fighter
I want to make the player able to jump through the bottom of a platform, and stand on the top. But, i really have no idea how to make this work. Any ideas?
Video of what I mean:
I guess raycasts, you could send one below and above the player, lets say a platform has a tag “Platform” and the below ray hits it then the canCollide will turn on however if the upper ray hits then its canCollide turns off
I don’t understand what you really mean, can you provide more details and maybe some imagery?
I can Provide sample code if that’s what you want?
Yes that would be good too any example
i can provide a video from a game im trying to emulate if you’d like
Sorry for the wait, I only realized half through making it that I had it backwards
task.wait(.5)
local run = game:GetService("RunService")
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local raycastLimb = char:WaitForChild("HumanoidRootPart")
local PlatformTag = "Platform"
local raycastLength = 7
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Exclude
params.FilterDescendantsInstances = {char}
local function renderStepped(dt)
local upRaycast = workspace:Raycast(raycastLimb.Position, raycastLimb.CFrame.UpVector * raycastLength, params)
local downRaycast = workspace:Raycast(raycastLimb.Position, -raycastLimb.CFrame.UpVector * raycastLength, params)
if upRaycast then
if upRaycast.Instance:HasTag(PlatformTag) then
if upRaycast.Instance.CanCollide then
upRaycast.Instance.CanCollide = false
end
end
end
if downRaycast then
if downRaycast.Instance:HasTag(PlatformTag) then
if not downRaycast.Instance.CanCollide then
downRaycast.Instance.CanCollide = true
end
end
end
end
run.RenderStepped:Connect(renderStepped)
usually I would do something more indepth like making sure that it isn’t a child of a model and if it is then loop through all the model stuff but I feel for an example this works – note: the part you want to go through needs to have the same tag as the “PlatformTag” variable
script goes in starterCharacterScripts and its local.
Thank you, it works perfectly.
I would like to say as this is just an example I wouldn’t use it as a full on thing/fix for a game I would more or less use it as a stepping stone, as I stated I would personally check if the part is a child to a model and what not. of course if your only going to have simple parts this would certainly work but once you add a model with multiple parts the player might get snagged on them or so on. just a warning, this will definitely work for a quick fix for testing though, good luck
Sorry for bringing up a solved topic but for anyone wanting something like this but with dropthrough with a key this should work
task.wait(.5)
local run = game:GetService("RunService")
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local uis = game:GetService("UserInputService")
local raycastLimb = char:WaitForChild("HumanoidRootPart")
local PlatformTag = "Platform"
local raycastLength = 7
local dropDownKey = Enum.KeyCode.F
local dropKeyDown = false
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Exclude
params.FilterDescendantsInstances = {char}
local function down(setCollide)
local downRaycast = workspace:Raycast(raycastLimb.Position, -raycastLimb.CFrame.UpVector * raycastLength, params)
if downRaycast then
if downRaycast.Instance:HasTag(PlatformTag) then
if downRaycast.Instance.CanCollide ~= setCollide then
downRaycast.Instance.CanCollide = setCollide
end
end
end
end
local function up()
local upRaycast = workspace:Raycast(raycastLimb.Position, raycastLimb.CFrame.UpVector * raycastLength, params)
if upRaycast then
if upRaycast.Instance:HasTag(PlatformTag) then
if upRaycast.Instance.CanCollide then
upRaycast.Instance.CanCollide = false
end
end
end
end
local function renderStepped(dt)
if not dropKeyDown then
down(true)
else
down(false)
end
up()
end
local function keyDown(key,proc)
if not proc and key.KeyCode == dropDownKey then
dropKeyDown = true
end
end
local function keyUp(key, proc)
if not proc and key.KeyCode == dropDownKey then
dropKeyDown = false
end
end
uis.InputBegan:Connect(keyDown)
uis.InputEnded:Connect(keyUp)
run.RenderStepped:Connect(renderStepped)
again sorry for bringing up a solved topic I just saw that in the video it showed drop down through the platform and wanted to make the code I provided work for just that.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.