wingdnosring
New Member
- Reaction score
- 16
Okay guys, prepare to put your thinking caps on, because this is tough.
I have a computer player that shoots at a user controlled player. The weapon has a fixed arc set. Here is the formula for the arc.
Vz = Bullet Speed * (sin(pitch)/0.7)
Then every 0.06 seconds, this happens:
Vz = Vz - (Vz * (0.06 * ArcSlope))
Change missile's height to Missile's Height - Vz
This works fine when a user-controlled unit is shooting, because its target is simply the gorund and the user controls his own camera. For computer players however, I need to somehow find out what the initial pitch must be for the arc to land squarely on the unit's target.
How do I solve for pitch?
Keep in mind I know the following: Bullet Speed, Arc Slope, Distance between Target and Aattacker, XY angle from Target to Attacker, Z angle from Target to Attacker, all three angles in a triangle that links Target and Attacker on the Z axis, Number of times the missile will have its height changed, and the height difference between Target and Attacker.
I can use any of those. Keep in mind that the missile could hit the Target halfway through its arc or at the very end, it's impossible to say.
If it helps, pitch is equal to this: ((initial Vz) * 0.7) / Bullet Speed
The problem is finding the initial Vz when it's increase/decrease is a percentage of itself. It's an unknown that builds upon the unknown .
[Edit]: I think I need to solve for Vz in its initial stage. So I have to take the height and number of runs and plug them into a geometric series function? Does that make any sense?
I have a computer player that shoots at a user controlled player. The weapon has a fixed arc set. Here is the formula for the arc.
Vz = Bullet Speed * (sin(pitch)/0.7)
Then every 0.06 seconds, this happens:
Vz = Vz - (Vz * (0.06 * ArcSlope))
Change missile's height to Missile's Height - Vz
This works fine when a user-controlled unit is shooting, because its target is simply the gorund and the user controls his own camera. For computer players however, I need to somehow find out what the initial pitch must be for the arc to land squarely on the unit's target.
How do I solve for pitch?
Keep in mind I know the following: Bullet Speed, Arc Slope, Distance between Target and Aattacker, XY angle from Target to Attacker, Z angle from Target to Attacker, all three angles in a triangle that links Target and Attacker on the Z axis, Number of times the missile will have its height changed, and the height difference between Target and Attacker.
I can use any of those. Keep in mind that the missile could hit the Target halfway through its arc or at the very end, it's impossible to say.
If it helps, pitch is equal to this: ((initial Vz) * 0.7) / Bullet Speed
The problem is finding the initial Vz when it's increase/decrease is a percentage of itself. It's an unknown that builds upon the unknown .
[Edit]: I think I need to solve for Vz in its initial stage. So I have to take the height and number of runs and plug them into a geometric series function? Does that make any sense?