Page 1 of 1
projectiles and wind
Posted: Tue Aug 09, 2011 12:42 am
by trying
What would be the best way to simulate wind within bepu physics...im using a standard projectile equation (actually found on these forums) and can't seem to get it right... I have a wind speed variable, but am looking for something that effects the projectile after its release....any thoughts/suggestions? Still loving the physics engine! Thanks in advance....
Re: projectiles and wind
Posted: Tue Aug 09, 2011 12:54 am
by Norbo
One simple wind-like behavior is to accelerate the object in the wind direction some amount each frame. This can be done by adding a little to the object's LinearVelocity every frame in the wind's direction.
If you don't want the wind to accelerate a projectile beyond a certain speed, you can first take the dot product of the object's linear velocity with the normalized wind direction. This gives you the velocity of the object in the wind direction. The maximum velocity change you can apply along the wind direction is then Min(windSpeed - currentSpeedInWindDirection, acceleration * dt) where dt is the frame time.
Or, together:
Code: Select all
projectile.LinearVelocity += windDirection * Math.Min(windSpeed - Vector3.Dot(windDirection, projectile.LinearVelocity), acceleration * dt);
I didn't test that, so beware typos

Re: projectiles and wind
Posted: Tue Aug 09, 2011 1:04 am
by trying
Thank you for lending me your brain! Sometimes I'm just amazed....
Re: projectiles and wind
Posted: Tue Aug 09, 2011 1:07 am
by trying
Okay I lied, I'm always amazed...lol