- Home /
Object move according to wind flow?
Hello i m stuck in problem can u help? i m falling two umbrella from tower , and at that time wind is flow from x dirct ,now i m trying in umbrella there are twotype force post and it move randomly just like real effect .can u suggest.
With something like this, you'll have to play to get the motion you want. A couple of random suggestions. Take a look at $$anonymous$$athf.PerlinNoise(). There is a 1D example at the bottom of the page. You can use this to vary the wind direction smoothly over time. As for applying the force, you might want to Raycast or use Collider.ClosestPointOnBounds() to find a position and then use Rigidbody.AddForceAtPosition() to apply the force. All this is just a guess at a starting point.
Another thought. I remember a helicopter script awhile back that had different coefficients for each side, so wind would have a different impact depending on the orientation of the helicopter. You could do the same for the umbrella.
Answer by HappyMoo · Jan 02, 2014 at 04:53 PM
you can try simulating wind with PerlinNoise. I'm writing some example code down, but you really need to play with the numbers, so the wind looks good on your scale:
void FixedUpdate()
{
Vector3 windDirection = Vector3.left;
float windMin = 10f;
float windMax = 30f;
float windFrequency = 0.1f;
float currentWindForce = windMin + (windMax-windMin)*Mathf.PerlinNoise(Time.time*windFrequency,0);
rigidBody.AddForce(currentWindForce * windDirection );
}
Also add some drag on your rigidBody, so the objects don't increase speed indefinitely