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

A little help with LookVector?

Asked by 4 years ago

I'm making a plane that drops a bomb onto the map, and I want the bomb to be facing the direction of the plane's "bombpart" which is the part attached to plane in which the bombs CFrame is set to. It is not positioning to this part anymore once I added LookVector. I know this is something that can be easily fixed, so please tell me how to use it properly.

local bomb = coroutine.wrap(function()
    for i = 1, bombnumber do
        local b = game.ServerStorage.bomb:Clone()
        b.Parent = game.Workspace
        b.CFrame=CFrame.new(script.Parent.bombpart.CFrame.LookVector) 
        b.Velocity = Vector3.new(0,0,speed)
        wait(0.2)
    end
end)

--Line 5 doesn't function properly.
0
i dont know anything about lookvector, but it doesnt look like you identified the 2nd object that the plane is supposed to look at? ill go look back at "Understanding CFrames" because im kinda stuck myself... speedyfox66 237 — 4y

1 answer

Log in to vote
0
Answered by
Fifkee 2017 Community Moderator Moderation Voter
4 years ago

LookVector is just a unit vector, all values ranging from -1 to 1. If you were to try to set a value to the unit vector, it would be super close to (0,0,0). Instead, you should add the LookVector to the part's CFrame in order to get things working. If you want it a distance from said vector, multiply it by a scalar to expand. If you multiply the LookVector by 5, it will be 5 studs in front of the part. Multiplying by a negative would move it backwards.

script.Parent.bombpart.CFrame + script.Parent.bombpart.CFrame.LookVector

CFrame + Vector3 is still a CFrame, so you don't need the constructor. Cheers.

0
Thanks for giving me a better explanation! AlexAuthority 22 — 4y
Ad

Answer this question