[Repost] So I'm making a First Person Shooter game, and I'm having troubles with the maths aspect of it. What I'm really struggling on is making the player's 2 arms point towards where my mouse is.
I'm not here asking for scripts, I just need someone to explain to me the concepts behind it. There's dozens of free models out there that does it, I could easily use it, so I would rather use that then ask for scripts here. But the problem is, I do not understand it.
I know it involves rotation behind it, and it'll require me to rotate the joints or something in a player. I'll like you to please state which joints to rotate, or if I have to make joints my self. One or two example lines would be helpful too.
Thank you.
CFrame. CFrame stores both a position and a rotation.
You can make a parts 'Front' face, point towards another part by doing
PartA.CFrame = CFrame.new(PartA.CFrame.p,PartB.CFrame.p)
If you dont want the front face to be pointing towards the part, you use CFrame.Angles
to offset the rotation like this
PartA.CFrame = CFrame.new(PartA.CFrame.p,PartB.CFrame.p) * CFrame.Angles(0,math.rad(90),0)
If you are using degrees with CFrame.Angles
then always remember to use math.rad
to convert the degrees to radians, because CFrame.Angles takes in radians.
Can you show us the script you've made. That would be really helpful. ^-^ We can help you from that point. (I will edit this post once he puts it in)