How to Make Dummy Bots Aim Arcing Projectiles

I have a JQ dummy bot and I want her to be able to aim her knife and be able to compensate for the arc of the projectile as well. Any idea of how to go about that?

Are you trying to predict a potential targets position you want JQ to aim at and throw her knive or just want to visualize the arching projectiles path? Cause we would need to clarify some factors and cases regarding to ballistic problems depending on your goal.

The trajectory calculation of a 40 m/s object launched at roughly 2m (Junker Queen is 7 feet tall) would only require a 3.3 degree angle adjustment to reach the same position on a target at the maximum 60m knife range. I don’t know if it would really be worth it. It would probably be easier to create a set rule that when Ability 1 is not on cooldown, to temporarily set your existing method for bot aim (ray cast(eye position… etc ) to the same position + World Vector (0, 0.2, 0) … about 7 inches higher

Well when you can obtain the constant gravity acceleration of the dagger first, you can calculate where to aim ahead in time, you would need to find the travel time when the target and the projectile (the dagger) intersect, if the OP’s goal is to predict the targets position. The OP needs to clarify what he wants to do first.

1 Like

Hi, if you’re still looking for a solution for this check out these codes.

[QKQ8G] This one calculates the arc for a stationary target and is perfectly accurate. It also adjusts for the delta vector that some projectiles have.

[2G6XE] This one I made based off a code from a person named Yurrod (KJRR5P). His code only worked for a few heroes so I tried to generalize it. It calculates for the target’s velocity but the Y prediction becomes inaccurate at ranges >20m or so. The XZ portion is always accurate though.
You’ll want to copy over the rules “solve_ballistic_arc”, “loop solve_ballistic_arc”, “set player facing impact point (aimbot)”, “set projectile type (change here for different abilities)”, and “set projectile speed - secondary”
In “set projectile type” you’ll want to change eventPlayer.proj_type to the string “secondary”.
In “set projectile speed - secondary” There’s also a lot of extra data for other heroes that you can remove to save space if you just want JQ knife.

If you wanna get into the math of it, google “solving ballistic trajectories”. There should be a blog post by a person named ForrestTheWoods. I tried to recreate his solver in my code at one point, but it ended up not working out.


Edit: Turns out I forgot to update my workshop code after attempting to solve for projectile gravity and delta vector. mb. The old code still has a solution for linear projectiles, but what I said about it solving for arcs was a lie. The code below actually attempts to solve for projectile arcs.


[9Z1VN0] Correctly calculates for the XZ position of a target with velocity. For linear projectiles Y is accurate always. For arcing projectiles the Y prediction becomes inaccurate at ranges >20m or so.

You’ll want to copy:
Subroutines: “set_curr_hero_index”, “update_projectile_data”, “set_proj_facing”, “calc_proj_lead”, and “calc_arc_proj_lead”
Rules: “Initialize: Static Global Variables”, “Set player projectile data”, and “Calculate Player Projectile Trajectory”

In “Set player projectile data”, there’s a player variable called proj_type. It’s basically an index for primary, secondary, ability 1,2, and 3 since the projectile data is stored in an array. In the demo it’s set to primary and never touched again, but you can set it dynamically just before firing the ability you want to aimbot. If you do that just update proj_type, call “set_proj_facing” to update the projectile data, and wait a few ticks for the aimbot target to update before pressing your ability button.

Also in the demo all the subroutines are only called once so you can squash them into the rules they’re called.

1 Like

Saw your work around it, and know the blog post few months ago and was referring to that here with “the time of travel” due of it was unclear what the OP actually wants to do, appreciate your impact very much :sparkling_heart:.

There is also a GDC video on youtube where ballistic problems are a topic, i can’t post a direct url in here unfortunate but can format it in here:

[Math for Game Programmers: Predictable Projectiles - YouTube](https://www.youtube.com/watch?v=6OkhjWUIUf0)

When you do a google search you’ll also find that somewhere at the first page, i guess you already saw it. The speaker’s name is Chris Stark, he references also some code for his case on github if i remember.

And about the topic alone here, there was a question made about linear projectile problem, also a few months ago, and was answered by Teawy and Jalier somewhat here:

Maybe you want to have a look and give your insights there as well.

And that thread was a reason to look into ballistics further again. Stumbled around, and found some informations like the blog and GDC video, used CAS on CoCalc, Symbolab and Wolffram Alpha with AI support. And all say about arching projectiles even the AI (ofc) and the original author of the problem which the blog post is derived from, how hard it is to solve it due if you form the equation it turns out to be a quartic and may return not real roots, and to work around it using some approximations that feeds on real time processing and that is very expansive, looking at the situation how loops are handled in workshop.

Thats why i am also glad Overwatch seems not to consider in the factors of air force drag, surface and volumetric friction and density. Imagine we would need that too :open_mouth: .

1 Like

There is also a GDC video on youtube where ballistic problems are a topic

Hey thanks! I have not seen that video before but I wish I had, I learned a ton. Like you mentioned it’s really hard to get a perfect solution. The one in the updated code I shared eventually turned out to be good enough for my use case, so I gave up on finding a perfect solution.

I’m also glad OW physics isn’t too complex. Some projectiles get additional height at launch, and figuring out how to account for that was already pretty annoying.

1 Like

No problem, i’m glad i could help with the video. Yes the delta vector is a really unpleasant factor to deal with, but they implementate it to accomedate i belive for some weapons that have like Soldier’s or Sorjourn’s Rifle recoil for the sake of immersion, one example is Junkrat’s Frag Launcher. Or case of varying projectile speeds, looking at Hanzo’s charging of Storm Bow Arrows, i attempted to create a mapping table of charge and their corresponding speed value and triage it together with a possible max distance, to tell a Hanzo bot at what distance should Hanzo charge to a respective value and fire at a speed so the arrow will hit a target at the predicted position. It turned out to be a creepy pasta code, and paused my attempt of creating a generalized Aimbot. Oh man, it still bugs me :smiley: until today, and i am eagger to retry, but well the effort is huge and really questions the worth out of it :frowning: .