projectiles and wind

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
trying
Posts: 6
Joined: Fri Jul 08, 2011 10:39 pm

projectiles and wind

Post 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....
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: projectiles and wind

Post 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 :)
trying
Posts: 6
Joined: Fri Jul 08, 2011 10:39 pm

Re: projectiles and wind

Post by trying »

Thank you for lending me your brain! Sometimes I'm just amazed....
trying
Posts: 6
Joined: Fri Jul 08, 2011 10:39 pm

Re: projectiles and wind

Post by trying »

Okay I lied, I'm always amazed...lol
Post Reply