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

Is there a way to create a directional value relative to the player?

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.

1 answer

✓ Accepted answer

eLunate taught me this :3

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)
It might be positive, I'm unsure.

He's the link to eLuante's answer.

Good Luck!

If I helped, please don't forget to accept my answer.

4 comments

0

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?

0

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

0

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

0

I assumed as much. Multiplying CFrames makes everything relative to each other was my mind process.

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