Jump to content
  • Advertisement
Sign in to follow this  
TiagoKo

How to find initial velocity with fixed angle of projectile

This topic is 2693 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello guys im new here.

Im making a game like gunbound or worms, and i need help to make computer hit the target with wind force.

My plan is to use a fixed angle, and to find initial velocity to launch the projectile.

I found this equation but it works without wind: Image3.gif

'L' = distance X from the target and 'h'=distance Y

Anyone know similar equation that works with wind force?

Sry my english.

Share this post


Link to post
Share on other sites
Advertisement

I implemented wind like acceleration X and Y every frame i increment on velocity X and Y.


That just has the same effect as gravity, then. You can just add the two together, define "down" to be the direction in which that vector points and use the same formula you would have used without wind.

Let me point out that your wind will probably feel wrong, because that's not at all what wind does to things. A better model would have drag, and the wind is used at the point where you compute the velocity of your object with respect to the air. If the drag is linear, you can still solve the resulting differential equations analytically and get a closed formula. But perhaps you should start thinking about numerical methods that are much more flexible.

Share this post


Link to post
Share on other sites
Here's something along the lines of what alvaro is suggesting (in terms of a better model)...

Your projective has state (x,v), where x is its position vector and v is its velocity vector. Letting m be its mass, c a drag coefficient, and u(x) the wind velocity at position x, a reasonable model is,

dx/dt = v
dv/dt = (1/m)*(m g + c ||u(x)-v||(u(x) - v)) .

which I will write compactly as,

dx/dt = v
dv/dt = f(x,v) .

A simple and effective way to integrate this is to choose a fixed timestep dt and run,

x[sub]k+1[/sub] = x[sub]k[/sub] + v[sub]k[/sub] dt
v[sub]k+1[/sub] = v[sub]k[/sub] + f(v[sub]k[/sub], x[sub]k+1[/sub]) dt

which is the Symplectic Euler method.

Share this post


Link to post
Share on other sites

[quote name='Zrymer' timestamp='1305048516' post='4809039']
I implemented wind like acceleration X and Y every frame i increment on velocity X and Y.


That just has the same effect as gravity, then. You can just add the two together, define "down" to be the direction in which that vector points and use the same formula you would have used without wind.

Let me point out that your wind will probably feel wrong, because that's not at all what wind does to things. A better model would have drag, and the wind is used at the point where you compute the velocity of your object with respect to the air. If the drag is linear, you can still solve the resulting differential equations analytically and get a closed formula. But perhaps you should start thinking about numerical methods that are much more flexible.
[/quote]

Ok with wind accelaration Y i can sum with gravity acceleration, but about acceleration X i dont know what to do.


Share this post


Link to post
Share on other sites
Acceleration is a vector. Add gravity and wind to find the total acceleration. Now you can change coordinates so the acceleration's direction is "down" and you can use whatever formula worked before you had wind.

Share this post


Link to post
Share on other sites
Change the acceleration direction to "down"..... it dont make sense. its only make gravity acceleration bigger.

Share this post


Link to post
Share on other sites
Or just use an iterative solver: guess the result then check if it's valid (the distance of the desired point and the calculated point is smaller than a small value), if not: refine the guess.

It would be easier for us to help if you showed how you calculate the position from the angle and the velocity (which is a fishy term anyway. Velocity is a vector, so the angle is redundant here. I guess you meant speed, which is the length of the velocity vector.)

Share this post


Link to post
Share on other sites

Or just use an iterative solver: guess the result then check if it's valid (the distance of the desired point and the calculated point is smaller than a small value), if not: refine the guess.

It would be easier for us to help if you showed how you calculate the position from the angle and the velocity (which is a fishy term anyway. Velocity is a vector, so the angle is redundant here. I guess you meant speed, which is the length of the velocity vector.)


Exactly, the equation that i got is to find speed, and i use cos and sin to get vector from speed.
I will try to find any formula that work directly with vectors, i guess it will be easier than work with angles.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!