[Closed] Is there a way to simulate axial drag on a Rigidbody?

If I made a model which is a flat surface, like a wing. How can I make it behave so the drag only affects it when you push it with the flat surface facing the direction it’s going?

I have made a sketch in hope of having you understand it better.

You don’t have any code specifics here, but let me make an untested suggestion for an approximation. First you have a wind direction. If this is an airplane part, it may just be the negated value of the direction of the plane. However you get it, you will have a vector representing the speed and direction of the wind that could influence this control structure. The control structure will have a normal to the surface. Depending on how you modeled this structure, it will be something like transform.up or transform.forward for the world version of this normal. To vary the amount of force that is applied you can do:

forceToApply = Mathf.Abs(Vector3.Dot(windVector, surfaceNormal)) * someFactor;

When control structure is parallel to the wind (i.e. the normal and the wind direction is perpendicular), no force will be applied. When the control structure is perpendicular to the wind (i.e. the normal aligns either positively or negatively with the wind), then the amount of force will be the velocity of the wind times some factor. And you will see fractional values between no force and full force as the control structure is rotated…

For a given rotation, this equation produces a linear increase in force as the velocity of the wind increases. Real drag goes up as the square of the velocity. I’m not sure of your goal here (or if it is even achievable with Unity’s physics engine), but you might get a somewhat better approximation by:

forceToApply = Mathf.Abs(Vector3.Dot(windVector.normalized, surfaceNormal));
forceToApply = forceToApply * windVector.normalized * windVector.sqrMagnitude * someFactor;

Again this is game-type approximation without knowing your goal or studying equations for drag.

Perhaps I’m not understanding your problem correctly but the answer seems fairly straightforward . . .

  1. Set the drag (coefficient) on your objects rigidbody to 0 to eliminate it from the problem

  2. Create a Script called Drag that looks something like the below & attach it to your object. Every frame it will apply a force in opposition to & in proportion to the velocity the object is moving in. To eliminate an axis, set it to 0 in the AxisDrag, to reduce the drag on an axis, reduce it’s axis value in . . . yeah you get the idea.

    class Drag : MonoBehaviour
    {
    public Vector3 AxisDrag;

    public Update()
    {
    ApplyForce(rigidbody.velocity.x * AxisDrag.x * -1 * Time.deltaTime);
    ApplyForce(rigidbody.velocity.y * AxisDrag.y * -1 * Time.deltaTime);
    ApplyForce(rigidbody.velocity.z * AxisDrag.z * -1 * Time.deltaTime);
    }
    }

You’ll likely need to bring the mass of the object into the equation if it’s mass is not equal to 1, and you’ll need to tweak the Axes somewhat, you may also need a general coefficient of drag to adjust your values depending on how Force affects velocity/acceleration in unity (in the real world it’s force = mass * acceleration)

Oh yeah I haven’t given it the necessary brain cycles but it might also work as the simple product of teh two vectors * -1 * Time.deltaTime. Which reminds me the syntax isn’t tested but armed with the general principle the rest should be able to be figured out from here.

In fact now that I see you need this for a flight / win simulator you probably want to connect AxisDrag to some kind of Wind Direction vector. Or create a wind object / script that adjusts it’s direction in time for variable / gusts / blusters, and then simply connect the AxisDrag in this script to the wind direction and apply those normalised forces (times a coefficient) to your object.