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?

+2 votes

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?

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.

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).

- All categories
- Engine 18,313
- Projects 2,433
- Gossip 326