Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you make the player's arm's rotate towards mouse?

Asked by 8 years ago

[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.

2 answers

Log in to vote
0
Answered by 8 years ago

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.Anglesto 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.Anglesthen always remember to use math.rad to convert the degrees to radians, because CFrame.Angles takes in radians.

0
Yes, that's helpful. But how would I rotate the players arms towards mouse without breaking the joints and killing the player? What do I rotate? OMEGA27304 8 — 8y
Ad
Log in to vote
-1
Answered by 8 years ago

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)

0
I haven't made any scripts.. that's why I'm asking. I want to know the concepts. OMEGA27304 8 — 8y
0
Then go to the wikia. Entepha 0 — 8y

Answer this question