Hopefully this should be a quick question, just need some help with CFrame math.
I want to spawn a throwable object in front of the player's head, depending on where the player's camera is looking.
Click for an Epic Paint Drawing of what I'm talking about
After Googling I've tried:
local throwOffset = CFrame.new(0,0,-5) part.CFrame = head.CFrame * throwOffset
but obviously this only works horizontally, because the player's head isn't rotating up and down.
How do I add the player's camera's look rotation onto this?
Thank you in advance!
Just found a solution!
local throwOffset = 5 --studs in front of head for part to spawn local newPos = head.Position + camera.CFrame.lookVector*throwOffset part.CFrame = CFrame.new(newPos,newPos+camera.CFrame.lookVector)