Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a smash bros platform?

Asked by 6 years ago

I'm trying to make a platform that is similar to the one's in smash bros, where you can stand on it from the top, and you can go through it from the bottom (I'll worry about how to make it so you can go through from the top using S + Jump).

H o w e v e r, I HAVE ABSOLUTELY NO IDEA WHERE TO EVEN START.

I've tried making it so they lose collision when anything but the legs touch it, but players bump into it from the side with the legs only, and other plays will fall through when a player going through from the bottom, So I'm just lost.

If anyone can help, greatly appreciated.

P.S. If you're just gonna make the script, thank you, I will credit you and see how I can fuse them with my scripts (Though I doubt this will ever happen, and I also wanna learn how to do this rather than just taking a script.)

2 answers

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
6 years ago

I would reccommend generating a Region3 above and below the platform that you consistently check for the character in. If a character is detected in the Region3 below the part, the platform would be made CanCollide false for them. If they were detected above, it would make the platform CanCollide true again, allowing them to stand on the platform. It would be best to do this in a local script to reduce potential delay, and so that you don't have to use collision filtering (assuming you have FilteringEnabled).

0
Will this allow a Player to stand on it while another goes through the bottom? Or is it one at a time? avatarnoob 13 — 6y
0
It does allow for that Filipalla 504 — 6y
Ad
Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
6 years ago
Edited 6 years ago

It's better to not try to solve this using collisions, because that won't really capture the "idea" of what's happening.

You want a platform that you collide with from above and that you don't collide with from below. Said another way,

  • When you are above platform, collide with platform.
  • When you are below platform, don't collide with platform.

This can be as simple as

-- (as a LocalScript, so that this is handled separately for each player)
local player = game.Players.LocalPlayer
while wait() do
    local above = isCharacterAbove(player.Character, platform)
    platform.CanCollide = above
end

where isCharacterAbove is defined appropriately. I would consider a character to be above a platform when the bottom of their feet are no more than ~ 0.5 studs into the top surface of the platform:

function isCharacterAbove(character, platform)
    local platformTop = (platform.CFrame * (platform.Size / 2)).y
    local characterHeels = character.HumanoidRootPart.Position.y - 2.35
    return platformTop < characterHeels + 0.5
end

Answer this question