CFrame.lookIn(position, forward, up)

As a developer it’s currently very annoying to construct a CFrame given a position and direction

Consider a position P and a direction D. If I want to make a CFrame representing P and D I have to do something cringe:

CF = CFrame.lookAt(P, P+D)

This can get super annoying and often requires a new P variable just for this one function call. This can get extremely messy when you’re making several CFrames or when you’re constructing them within something like a function call or table construction.

PA = some + math * here
CFA = CFrame.lookAt(PA, PA+DA) 
PB = some + math * here
F(CFrame.lookAt(PB, PB+DB))
PC = some + math * here
T = { CF = CFrame.lookAt(PC, PC+DC) }

So I want a constructor that makes a CFrame given a position and a look direction. This way I can do something way less cringe:

CFA = CFrame.lookIn(PA, DA)
F(CFrame.lookIn(PB, DB))
T = { CF = CFrame.lookIn(PC, DC) }

Which won’t require me to make new variables to construct a CFrame when I already know the position and direction I want to represent.

4 Likes

You can kinda do something like that already by using a function, like so

local function LookIn(Position, Forward, Up)
   return CFrame.lookAt(Position, Position + Forward, Up)
end
1 Like