I haven no code snipits for this. Is there a way to find a direction relative to the player.
As in: If I would like to have something happen directly LEFT of the player, relative to their facing direction.
I haven no code snipits for this. Is there a way to find a direction relative to the player.
As in: If I would like to have something happen directly LEFT of the player, relative to their facing direction.
If you want to get a CFrame value say... directly left of the chatacter's torso, you would multiply the CFrame by a negative x value. Example,
local Left = Torso.CFrame * CFrame.new(-20,0,0)
He's the link to eLuante's answer.
Good Luck!
This discussion is preserved as it was. New answers, comments, and votes are closed.
4 comments
Thanks. I tried CFrame before but I was using + rather than multiplication. I'd like to ask though, why does multiplying it affect it in a relative manner?
Well, first of all you can't add CFrames. And I'm not really sure. I asked eLuante and she didn't have an answer neither. Just something you have to remember I guess. Might be a good follow up question, but I'm not sure if anyone knows. I'm sure there's a reason though :3
The (extremely short and unhelpful) reason is that every CFrame corresponds to a spatial transformation. For instance, the CFrame(-20,0,0) corresponds to a translation 20 units in the direction -x, which relative to the player torso, is left. That is, the CFrame multiplication A * B gives the CFrame A transformed by B. My linear algebra is a little rusty, though, so I would look into it some more
I assumed as much. Multiplying CFrames makes everything relative to each other was my mind process.