English 中文(简体)
How to make a sliding brick that dissapears into another on ROBLOX
原标题:

Do I have to use bodyposition? BodyVelocity? 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





相关问题
What does it mean "to write a web service"?

I just asked a question about whether it was possible to write a web-page-checking code and run it from free web server, and one supporter answered and said that it was possible only if I run "a web ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Dynamically building a command in bash

I am construcing a command in bash dynamically. This works fine: COMMAND="java myclass" ${COMMAND} Now I want to dynamically construct a command that redirectes the output: LOG=">> myfile.log ...

Why does Scala create a ~/tmp directory when I run a script?

When I execute a Scala script from the command line, a directory named "tmp" is created in my home directory. It is always empty, so I simply deleted it without any apparent problem. Of course, when I ...

Ivy, ant and start scripts

I have a project that uses ant to build and ivy for dependencies. I would like to generate the start scripts for my project, with the classpath, based on the dependencies configured in Ivy, ...

热门标签