I'm trying to make a parachute, and in order for it to be realistic I want the bottom of the chute to constantly face a point no matter the position of the chute itself.
I know that CFrames
can be initialized with a lookVector
so the CFrame faces a certain position, but the problem is I don't want the front of the parachute to face the point, but rather the bottom of it.
I've tried multiplying the lookVector
by a bunch of Vector3s
but I wasn't really sure what I was doing and it didn't help at all. I've also tried doing cross products to get a perpendicular vector, but I don't know what to multiply. (point.Position - chute.Position).Unit
and what?
EDIT: Ok, people want code. It's not going to help, but here you go:
local runService = game:GetService("RunService")
local parachute = script.Parent local base = parachute:WaitForChild("Base").Value local dragBF = base:WaitForChild("Drag") local resistanceCoefficient = 10 local parachuteDistance = 10 runService.Heartbeat:Connect(function(step) -- Compute the parachute's drag force local drag = -base.Velocity * resistanceCoefficient -- Compute position and direction of parachute local chutePos = base.Position + base.Velocity.Unit * parachuteDistance local chuteLV = ???? parachute.CFrame = CFrame.new(chutePos, chuteLV) dragBF.Force = drag end)
I don't know what to do for chuteLV
OMGOMGOMG I FOUND A SOLUTION FINALLY
Ok this is dead, but in case anyone else encounters this problem, what you have to do is basically construct a CFrame
from scratch, using the Rotation matrix to correctly orient the part.
I was actually pretty close to start with, I just didn't realize that what you cross product-ed the Vector3s
with didn't matter.
Basically, if you want the upVector
to point AWAY from a spot, you set the upVector
of the CFrame
to be the (beingAligned.Position - beingAlignedTo.Position).Unit
.
Then, you cross product that upVector
with basically any other unit vector at all, as long as the two are unique. That would yield another perpendicular vector (the thing I was missing). You can use this one as either the frontVector
or the rightVector
- it doesn't really matter.
For the final, missing vector just cross the first two.
Use the last CFrame.new
constructor ... and VIOLA! Problem solved.