开发者

How to make a sliding brick that dissapears into another on ROBLOX

Do I have to use bodyposition? BodyVeloci开发者_开发百科ty? PLEASE HELP


There are many ways to do something like this, if I understand what you want to attempt. For it to effectively "slide into another brick and dissapear", you can do 2 things:

1) Have a powerful BodyVelocity in the direction of the other brick, which has a CanCollide of 0. When the brick makes contact with the other, it will wait a short amount of time, then remove itself.

2) You can move the brick using CFrame, finding the angle using CFrame.new(Brick1.Pos, Brick2.Pos), and using a frames system to add that CFrame to the Brick1 CFrame, creating the effect of "movement". You would remove the brick when the "frames" ended.


What does "disappears into another" mean? You can use a multitude of ways to simulate sliding. You can use CFrame, BodyVelocity, BodyForce or even BodyPosition. You can even make a brick with no friction and slide it on that. Is there anything else you need to know? If so, comment.


Well, there's another more realistic and less likely to fail way, you can simply make a brick, and on function, example onClick(), You can make it dissapear and an anchored brick become visible, using transparency, and make the Original Brick nonCanCollide, and the new substitute's position move in the direction, also, I would tend to use BodyPosition, because it works for the position and can be used for anchored and nonanchored bricks (Not as well for nonanchored) and bodyvelocity is for nonanchored bricks to move in a direction, which is kinda tedius, well, I say it's less likely to fail, because if the substitute fails, then the original brick is still there, and you can make a backup script to save it if the sub breaks.

I hope some of this helped. -Orbian.


From what i can tell, you want to use CFrame. To be able to make two bricks move in same space (with both bricks having a CanCollide = true) you MUST use CFrame. All "Body" instances (BodyVelocity , BodyPosition) apply force on the bricks, and thus can't make them move in the same space.

If you want a sliding door you could use this script:

local StartPosition = script.Parent.CFrame
local ToPosition = workspace.TargetPart.CFrame -- Make sure this is right

function Open()
    for i=0,100,1 do
        script.Parent.CFrame = StartPosition + CFrame.new(StartPosition.p,ToPosition.p).lookVector *     ((StartPosition.p-ToPosition.p).magnitude/100) * i
        wait(0.01)
    end
end

function Close()
    for i=100,0,-1 do
        script.Parent.CFrame = StartPosition + CFrame.new(StartPosition.p,ToPosition.p).lookVector *     ((StartPosition.p-ToPosition.p).magnitude/100) * i
        wait(0.01)
    end
end

local Moving = false
local IsOpen = false
function Toggle()
    if Moving then return end
    Moving = true

    if IsOpen then
        Close()
    else
        Open()
    end
    IsOpen = not IsOpen

    Moving = false
end

-- Following code is just for testing
Toggle()
wait(1)
Toggle()

Make sure that the second brick is bigger than the first one.


You can make an onClick script that will make a brick have velocity to slide the second brick into place then have a new onClick script to make the affects of the velocity negative so it will pull the second brick back out.


use a conveyer belt to slide it in and make a brick cancollide and make it fat thanthe c

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜