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

How to get the Lookvector on left-/right-hand side of a Part?

Asked by 4 years ago

Hi, I got a script from my friend that makes a player fly. But only fly infront (with W) and back (with S). But not on left or right. Here is a part (more important part) of the script:

UIS.InputBegan:Connect(function(Input)
    if Input.KeyCode == Enum.KeyCode.W then
        if Toggle == false then return end
        PlayAnim:Play()
        HumaoidRP.Anchored = false
        if HumaoidRP:FindFirstChildOfClass("BodyVelocity") then
            HumaoidRP:FindFirstChildOfClass("BodyVelocity"):Destroy()
        end
        local Forward = Instance.new("BodyVelocity",HumaoidRP)
        Forward.Name = "ForwardMovement"
        Forward.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
        local Gyro = Instance.new("BodyGyro",HumaoidRP)
        Gyro.MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
        Gyro.D = 100
        Gyro.P = 10000
        while Toggle == true do
            Forward.Velocity = Mouse.Hit.lookVector*150 --HERE
            Gyro.CFrame = Mouse.Hit
            wait()
        end
    end
end)

There where --HERE is, is the lookVector. If we look at this here:

---------FRONT--

LEFT--player--RIGHT

---------BACK---

FRONT is the position of lookVector. There would make logic if there is also something for LEFT and RIGHT?

I tryed to get left/right with CFrame. But CFrame is global value(it is always on the same orientation, not like a part or a player).

Now my Question: Is there a way to get left/right vector?

1 answer

Log in to vote
1
Answered by 4 years ago

Along with LookVector, there are two other properties of CFrame called RightVector and UpVector. To find the left vector, simply multiply the RightVector by -1, and the same to get the bottom vector from UpVector.

0
WOW, thanks! I did not found anything in the internet about rightVector and UpVector, now I know this. Thanks! DieStockEnte 11 — 4y
0
Or, you know, just negate the vector. `-cf.RightVector`. Link150 1355 — 4y
Ad

Answer this question