如何在 ROBLOX 上制作一块可以消失的滑动砖块

发布于 2024-10-04 16:11:54 字数 24 浏览 0 评论 0原文

我必须使用体位吗?身体速度?请帮忙

Do I have to use bodyposition? BodyVelocity? PLEASE HELP

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

静谧幽蓝 2024-10-11 16:11:54

如果我明白你想尝试什么,有很多方法可以做这样的事情。为了让它有效地“滑入另一块砖块并消失”,您可以做两件事:

1)在另一块砖块的方向上有一个强大的 BodyVelocity,其 CanCollide 为 0。当砖块与另一块砖块接触时,它会会等待一小段时间,然后自行移除。

2) 您可以使用 CFrame 移动砖块,使用 CFrame.new(Brick1.Pos, Brick2.Pos) 查找角度,然后使用框架系统将该 CFrame 添加到 Brick1 CFrame,创建“移动”的效果。当“框架”结束时,您将移除砖块。

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.

浮世清欢 2024-10-11 16:11:54

“消失在另一个人身上”是什么意思?您可以使用多种方法来模拟滑动。您可以使用 CFrame、BodyVelocity、BodyForce 甚至 BodyPosition。你甚至可以制作一块没有摩擦力的砖块,然后在上面滑动。还有什么您需要知道的吗?如果是这样,请发表评论。

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.

2024-10-11 16:11:54

好吧,还有另一种更现实且不太可能失败的方法,您可以简单地制作一块砖块,然后在函数上,例如 onClick(),您可以使其消失并且锚定的砖块变得可见,使用透明度,并使原始砖块不可碰撞,并且新替补的位置朝 方向移动,而且,我倾向于使用 BodyPosition,因为它适用于该位置,并且可用于锚定和非锚定砖块(不适用于非锚定砖块),而 bodyvelocity 用于非锚定砖块移动在一个方向上,这有点乏味,好吧,我说它不太可能失败,因为如果替代品失败,那么原始砖块仍然在那里,并且您可以制作一个备份脚本来保存它,如果替代品损坏。

我希望其中一些有所帮助。
-奥比安。

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.

缘字诀 2024-10-11 16:11:54

据我所知,您想使用 CFrame。
为了能够使两块砖块在同一空间中移动(两块砖块都具有 CanCollide = true),您必须使用 CFrame。所有“Body”实例(BodyVelocity、BodyPosition)都会对砖块施加力,因此无法使它们在同一空间中移动。

如果您想要滑动门,可以使用以下脚本:

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()

确保第二块砖比第一块大。

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.

花落人断肠 2024-10-11 16:11:54

您可以创建一个 onClick 脚本,该脚本将使一块砖块具有将第二块砖块滑入到位的速度,然后使用一个新的 onClick 脚本来使速度的影响为负值,以便它将把第二块砖拉出来。

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.

月依秋水 2024-10-11 16:11:54

使用传送带将其滑入,使砖块可以碰撞并使其比c厚

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文