Finding velocity in specific directions according to a surface

I’m trying to make a wing that has drag. I only want it in a specific direction depending on the velocity in said direction. I also want this to be according to the part rather than globally.


What I mean by according to the part is that rather than measuring the velocity based off of XYZ, it would be measuring according to the surface or something like that, I hope you know what I mean.

If someone could help me I would appreciate it.

– Luke

I would use AssemblyLinearVelcity to establish your drag in the wing, and then use that variable to multiply it against your assembly mass in getting the VectorForce.

If you do not want to use AssemblyLinearVelocity, this post shows how someone achieved it as well:

Thanks, I’m trying to get the velocity in a direction relative to the part, basically its always measuring the velocity in that direction according to the part, rather than the global axis.

In the vectorforce link i posted, in the section called Direction of Force, is this what you are referring to?

Do you want the global axis or the relative part?

the relative part, preferably.

Yes then read that section, it applies the vector force relative to the attachment u specify… then you can create drag by applying an assembly linear force in the opposing direction.

Ofcourse this is in theory, scripting it will take some trial and error.

I assume you are asking to find what the velocity would be if it were localized to the surface/part’s orientation?
The most intuitive way I would go about doing it would just be

local globalVelocity = part.AssemblyLinearVelocity -- however you are getting it
local localVelocity = part.CFrame:VectorToObjectSpace(globalVelocity)

The localVelocity vector would be localized so you could imagine the X component giving the velocity the part is moving in its forward direction , the Y being the velocity the part is moving in its own up direction, etc. So, If you for instance wanted to apply drag only for the velocity aligned vertically with the object you would do something like

local drag = localVelocity.Y * DRAG_COEFFICIENT -- however you want to scale drag

and then if you wanted to convert that back into a global force

local dragForce = part.CFrame:VectorToWorldSpace(, -drag, 0))

FYI: I’m not sure if this is the most efficient way to calculate this. There may be some linear algebra magic that might be less computationally expensive.