Shoot Projectile Towards Target With Determined Accuracy Setting

Hi, in my Asteroids clone, I have a BoxCollider2D which is the spawning field for an asteroid. I would like to have a accuracy level which determines the amount of degrees away from the player an asteroid will set its initial velocity to. For example, The asteroid will spawn and I will get the vector for a direct path between it and the player. I would then like to take the accuracy, get a random amount between the negative accuracy and positive accuracy, then add that random to the asteroid so that it doesn’t always go directly for the player. I have looked around the forums and seen some things similar to this, but I would really appreciate a thorough explanation as math is definitely not my strong side in game development. Thanks a bunch!

P.S. a whole spoon fed code snippet is not what i’m looking for, if somebody could just explain to me how I would achieve this mathematically, that would be great, thanks!

Trigonometry, always trigonometry :slight_smile:

Here’s something that could help you : What's the most efficient way to rotate a Vector2 of a certain angle around the axis orthogonal to the plane they describe? - Questions & Answers - Unity Discussions

1 Like

@Kasper_OmsK Works beautifully, thank you so much!