Scale a Vector3 Force depending to alignment of a Drag Vector3


I like to simulate wind on a helicopter. The helicopter has different drag values and is flying in the air (CGM rc Heli Simulator). The goWind object is a seperate object where the wind is calculated and stored in it’s transform coordinates. 0,0,0 means no wind. 0,0,0.5 means wind from left. What I try to do is, to add the wind force in the correct strength, depending to the orientation of the helicopter. The force direction is working, but the strength of the wind force is not scaled as wanted.

// This script is attached to the helicopter with rigidbody and other physic calculations
private var drag:Vector3 = Vector3 (0.2,5.0,0.2); // Helicopter Drag: sideways, up-down, forward
function FixedUpdate () {
    var windDrag:Vector3 = Vector3.Scale(goWind.transform.position, drag);
    rigidbody.AddForce (windDrag, ForceMode.Impulse);

Best regards and thanks in advance for help, Klaus

I see one problem that may account for the “force not scaled as wanted.” I’m assuming the helicopter is allowed to turn and that ‘drag’ is defined in terms of the helicopter (and therefore it is a local coordinate). windDrag is calculate as a world vector. You need to convert drag into world coordinates before you do you calculation. See Transform.TransformPoint() to make the conversion.

I’m only seeing a very small piece of the code, but it seems to me that what you really want is the relative wind direction. That is you add the negated velocity vector of the helicopter with the velocity of the wind and apply the drag to the result.