Parabolic Aiming Calculation Help Needed.
by Jason Gossiaux · in Torque Game Engine · 05/05/2008 (10:22 pm) · 21 replies
Howdy all, so I've added a spell system and several spells to my game. I have buildings shooting volleys of arrows and peppering the area with catapault stones. Unfortunately, I'm at a loss as to how to do parabolic aiming calculations. I was hoping to use these with projectiles that have ballistic mode turned on.
When aiming in a straight line with a fairly fast projectile iand no ballistic mode t isn't too hard to calculate the exact spot to shoot at, and I can think of a few ways to lead the target for slower moving projectiles. I can also think of ways I might add randomness to the shot in order to simulate a poorly aiming AI.
The first problem with parabolic aiming, is detecting if the target is in my parabola line of sight. With traditional shooting I just do a raycast. With a parabolic shot I'd have to like...raycast maybe up at the angle of shot for so long, then over, then down? Can anyone think of an easier method?
The second problem is knowing what angle to shoot at for a given drag, gravity and muzzle velocity. I guess I could maybe come up with some formulas experimentally. In real life I could do the trig and come up with something - but I don't know if in game physics is modeled accurately enough for gravity and drag. Has anyone worked with this before?
Then I'd have to add in all the random variables like before. Parabolic shooting is quite a challenge, but it is advisable to straight shooting catapaults and arrows in my game. Thanks in advance for any ideas people can provide me with!
When aiming in a straight line with a fairly fast projectile iand no ballistic mode t isn't too hard to calculate the exact spot to shoot at, and I can think of a few ways to lead the target for slower moving projectiles. I can also think of ways I might add randomness to the shot in order to simulate a poorly aiming AI.
The first problem with parabolic aiming, is detecting if the target is in my parabola line of sight. With traditional shooting I just do a raycast. With a parabolic shot I'd have to like...raycast maybe up at the angle of shot for so long, then over, then down? Can anyone think of an easier method?
The second problem is knowing what angle to shoot at for a given drag, gravity and muzzle velocity. I guess I could maybe come up with some formulas experimentally. In real life I could do the trig and come up with something - but I don't know if in game physics is modeled accurately enough for gravity and drag. Has anyone worked with this before?
Then I'd have to add in all the random variables like before. Parabolic shooting is quite a challenge, but it is advisable to straight shooting catapaults and arrows in my game. Thanks in advance for any ideas people can provide me with!
About the author
Torque Owner Jason Gossiaux
Indie Dev
Editing just the globals in the C source does not up the packet size. It is really set inside the pref.cs file. Once I upped it to 450 packet size and 32 rate for client packets I was able to handle 100 projectiles created instantly without any problems.
Just for kicks I upped it to 1000 packet size, and was able to handle 250 projectiles created instantly. Granted my fps started dipping a bit as a result of the increased packet size. Using timers I've determined my calculations have an unmeasurably small impact on performance.
What this tells me is that the overhead from client/server packet transmissions is the real bottleneck. I can give the user some control over the settings and if I keep the number of projectiles reasonable I shouldn't have any problems.
Eventually I might have to rewrite the engine so objects beyond a certain distance get a lower priority for packet updates. Heh, that should be a fun exercise :P
Can I leave the packet size at 1000? I've not seen any forum posts lately indicating this may be a problem.
Thanks again for the help and ideas!