fausto1124, on 19 Oct 2015 - 6:11 PM, said:![snapback.png](http://public.gamedev5.net//public/style_images/master/snapback.png)
Quote
Unless you have Jesus towers dispatching wisdom in the form of short exemplary tales, you probably want to use the word "parabola".
Sorry man! I speak spanish so my translate isnt so good.
I completely understand. I speak Spanish too! (not surprising with a name like Álvaro).
Mine is Fausto! Haha
Quote
The problem is that my objective is moving, as i said, ive got the x and y components of the enemys speed.
Hmmm... Try to read what I said again.
There are infinitely many ways of drawing a parabola that joins your tower and your target, if you are willing to change the angle and the initial speed of the projectile. That means you can in principle hit the moving target at any of its future positions. If your projectile's initial speed is fixed, there are only two solutions. But I don't know exactly what constraints you have.
Here is what ive got:
- A method that giving it a position to fire to, it will give me a parabola, from the tower to that position. So i can follow that parable in order to make the parabola effect.
- The enemy x and y speed and actual position.
- The speed that the x component of the parable moves. I dont know if i make myself clear at this point.
Ive got an xPos variable that starts at the origin x position of the tower, so in every tick, i make xPos = xPos + Time.deltaTime * speed;
and then i make the arrow be at the position xPos, Parable(xPos).
So, giving this things i dont know how to do it.
you already have parabolic arc of fire to a give point right?
Yes!
and that point is where the target is, right?
I want to have a predictive aim, so that point should be the point where the target will get together with the arrow, thats what i want to calculate.
plug in target location, everything works great, right?
ok, now, all you do is plug in where the target will be when the shot lands, not where the target is when you fire.
to figure out where it will be:
take the range, and divide by the speed of the bullet to get the approximate travel time in turns to the target, which we will call T.
when you fire, first move the target forward for T turns to determine approximately where it will be when the shot lands, and shoot at that spot, not where the target is now. this is what's known as "leading the target".
Thats my problem, because i use a parabola and i move the x variable of the parabola, i dont really have the two components of the speed, i only got the x speed component and i dont know how to calculate the y speed for this. I think thats the only thing that i dont have for this to work
Thanks guys!