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

Question on lookVector?

Asked by
Hibobb 40
10 years ago

I'm trying to teleport in front of the block, not on top of it. I figured lookVector would be the way to go because it it the direction the block is facing. However I'm not very experienced in using it. Am I doing this wrong? Everything is defined, exists, etc.

for _,v in pairs(workspace.Bricks:GetChildren()) do
    if v.Name == "GreenBrick" then
        if v.CanTeleport.Value == true and v ~= script.Parent then
            print(v.CFrame.lookVector)
            char:MoveTo(v.Position * v.CFrame.lookVector)
        end
    end
end

2 answers

Log in to vote
0
Answered by 10 years ago

The :MoveTo method automatically detects collisions in moving, and tries to put the moved model in the topmost unoccupied space. You must be trying to move your model somewhere inside something, which cause MoveTo to put your model on top of the part instead.

0
Exactly. Thats why I am trying to change the position that it is trying to move the character to so that it places it in front of the brick. Hibobb 40 — 10y
Ad
Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

v.Position * v.CFrame.lookVector doesn't really mean anything unless you're specifying the origin is for some reason very important.


You probably want to add them -- v.Position + 5 * v.CFrame.lookVector* would be 5 studs away fromv.Positionin the direction ofv.CFrame.lookVector`.

As per iconmaster's suggestion, you shouldn't use :MoveTo if you want it to be exactly at this position. Instead, you should set the CFrame of the thing you're moving (presumably char is a Character and you'd set the .CFrame of the Torso)

Answer this question