July 6, 2021, 5:18am
local camDirection = hrp.CFrame:ToObjectSpace(cam.CFrame).LookVector
I understand except for .LookVector. I know the LookVector is indicating a forward direction(0, 0, -1)
CFrame of cam(CurrentCamera) measured hrp(HumanoidRootPart) to center of world + LookVector
It doesn’t make any sense to me. Can you explain this code?
Also What is Lookvector for? cam or hrp
July 6, 2021, 5:35am
Well… it’s lookvector, where the CFrame is facing. You can use this to calculate directions (for velocity and stuff). I’ve prepared a video that shows this:
(the side with the random decal is the front, you don’t need to watch the whole video)
the command that I ran in the video is:
workspace.Part.Velocity = workspace.Part.CFrame.lookVector * 10
July 6, 2021, 5:55am
You made video for me Thanks a lot
I understand what your video is about.
But still confused about
July 6, 2021, 5:58am
No problem bud!
Anyways, I believe this would give the direction from the camera to the humanoidRootPart (or the other way around). Here’s a link about worldspace if you need it
:ToObjectSpace() converts a CFrame relative to the world relative to a specific part.
For example let’s say object A is at 0, 10, 0 and object B is at 0, 20, 0. If we ran: print(objectA.CFrame:ToObjectSpace(objectB.CFrame) it would print 0,10,0 as object A is 10 studs above object B. It’s treating object B’s CFrame as the center of the world.
:ToWorldSpace() does exactly the opposite and returns a CFrame relative to the center of the world (0, 0, 0). So if object C’s CFrame is 0, 10, 0 away fr…
Hope this helped just a little
For future reference, you can use the Developer Hub before asking a question.