Top Down Shooter Aim Variance

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By jelly

For a topdown shooter I have the direction a bullet should go and the amount of variance there should be. Assuming I have everything I need, what is the math to adjust the direction of the bullet according to the variance?

You might want to be more specific regarding the form of the information you have.

  • direction of bullet: I assume that’s either a Vector2 or Vector3?
  • amount of variance: Is that a distance at the impact point, an angle from the shoot point (in degrees or radians?), or something else?

jgodfrey | 2020-11-24 16:20

Sure. So I have a direction Vector2 made from the position of the player to the position of the mouse. I then have a variance that is randomly picked from a range. It would be best for it to be from the position of the player. It is neither degrees or radians as of yet.

jelly | 2020-11-25 02:14

Maybe I’m not understanding something, but it seems like you could simply add the random variance to the position of the player, and then create a new Vector2 between the mouse and that new position, rather than your current Vector2 (which you say is between the mouse position and the player’s position).

jgodfrey | 2020-11-25 16:17