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

What's the best way to CFrame the bending of a bow?

I'd like the "limbs" of the bow I'm making to bend, but I'm absolute poop with CFraming and I'm not sure how to do this. Right now my bow is comprised of three parts, the handle, top limb, bottom limb. They are currently just stacked on one another, but when I rotate the limbs with CFraming magic, they, of course, rotate on a center axis, thus not keeping their one end connected to the handle of the bow. How would I go about rotating the limbs while keeping one of their tips from moving?

If this doesn't make sense, please let me know and I'll try to specify.

1 answer

✓ Accepted answer

Multiply by the CFrame which is half their width and height (to move the origin to the desired point of rotation), multiply by the angle then multiply by the inverse of the first CFrame to return the origin to the desired location.

Example:

bowLimb.CFrame =
	bowLimb.CFrame *
	CFrame.new(-bowLimb.Size.X/2, -bowLimb.Size.Y/2, 0) *
	CFrame.Angles(0, 0, angle) *
	CFrame.new(bowLimb.Size.X/2, bowLimb.Size.Y/2, 0)

Edit: Also, if you build the bow with Motors you can set C0 to CFrame.new(-Part0.Size.X/2, -Part0.Size.Y/2, 0) and C1 to CFrame.new(-Part1.Size.X/2, -Part1.Size.Y/2, 0) and set the Motor's CurrentAngle

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