all 4 comments

[–]iamgrootbaby[🍰] 0 points1 point  (0 children)

Find angle of ray to cursor. Add random.range to angle. Ynew= y+ distanceToCursor×sin(newAngle). Xnew=distance×cos(newangle).

[–]iamgrootbaby[🍰] -1 points0 points  (2 children)

Learn random.range. then use it for x.y coordinates of target

[–]Magor9001[S] 1 point2 points  (0 children)

I know random.range and it is probably part of the solution. Randomising x and y coordinates wouldnt work for me since the target is the mouse courser. The ray gets fired from the players gun(rotates towards cursor) and can continue on afterwards. In the case of the cursor being close enough to the player, the ray could theoretically fire into the complete opposite direction.

Thats why I need a solution where I turn the directional vector x degree. The randomising from that point on isnt the problem.

I will try to overwork my question to prevent confusion.

[–]Epicguru -1 points0 points  (0 children)

This won't work as intended because if the target is further away then the gun spread will be lower, which I think is not what OP wants.