#CFrame Logic Problem

3 messages · Page 1 of 1 (latest)

hybrid glade
#

Here is the important bits of code below:

local GlobalVelocity = Vector3.new(0,0,40) -- For simulation
local LocalVelocityCF = Part.CFrame:ToObjectSpace(CFrame.new(Part.Position + GlobalVelocity)) -- Convert to a local velocity
local RobloxLocalVelocity = LocalVelocityCF.Position -- Get the Vector3 position value instead of the whole CFrame.

local Lift = 100 -- For simplicity sake
local Drag = 30 -- For simplicity sake

local LiftDirection = LocalVelocity:Cross(Part.CFrame.RightVector).Unit -- I suspect this is the error, something with the .RightVector being incorrectly set up (?)

LiftVector = Lift*LiftDirection -- The local force vector of lift
local LiftArrowPosition = CFrame.new(LiftDirection * Lift)

local DragDirection = -(LocalVelocity.Unit) -- Opposite of movement
DragVector = Drag*DragDirection -- The local force vector of drag
local DragArrowPosition = CFrame.new(DragDirection * Drag)


LiftArrow.CFrame = Part.CFrame:ToWorldSpace(LiftArrowPosition) -- Move the lift visualization arrow
DragArrow.CFrame = Part.CFrame:ToWorldSpace(DragArrowPosition) -- Move the drag visualization arrow

#

In summary, get the velocity relative to the part (it it moving forward, backwards, up or down, etc. relative to itself) from it's actual velocity relative to the origin. Then, with the cross product of the RightVector of the airfoil and the relative air, get the unit vector for the lift's direction. Finally, apply the lift and bring it back to world space

#

All-in-all, not really sure how to use RightVector anymore