Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What does this script mean? Taken from Dev Wiki About CFrame

function lookAt(target, eye)
    local forwardVector = (eye - target).Unit
    local upVector = Vector3.new(0, 1, 0)
    -- You have to remember the right hand rule or google search to get this right
    local rightVector = forwardVector:Cross(upVector)
    local upVector2 = rightVector:Cross(forwardVector)
 
    return CFrame.fromMatrix(eye, rightVector, upVector2)
end

What is the Unit? Why is Cross? What is fromMatrix refering to? Why return from matrix, is it calling the function?

2 comments

0

I know you are interested about CFrame, but this website is a place for help on script errors. If you want, check out AlvinBlox on youtube. He has videos on CFrame and is great at explaining.

3

How do I downvote a comment? Nobody with a right mind suggests alvinblox

1 answer

It looks like a camera change script for 2D games on roblox

1 comment

1

Please read the docs before assuming anything. That is the replacement to the constructor CFrame.new(a, b), provided by Roblox.

This discussion is preserved as it was. New answers, comments, and votes are closed.