2D Accuracy
So I want a better way to handle bullet spray in 2D games. It needs to work with distance so that the farther away an object is the less accurate a shot will be.
var Mos = Camera.main.ScreenToWorldPoint (Input.mousePosition);
Mos = Mathk.RandomizePoint2D (Mos, Vector3.Distance (Mos, transform.position));
var dirPos = transform.position - Mos;
public static Vector2 RandomizePoint2D(Vector2 Point,float MaxMinOff) {
return new Vector2(Point.x + (Random.Range(-MaxMinOff,MaxMinOff)),Point.y + (Random.Range(-MaxMinOff,MaxMinOff)));
}
My problem is I seem to be getting the reverse effect, the closer I am the less accurate I am. I am using raycasting so any direction I get I travel along with my raycast. I understand that by being closer to the player with the mouse I will affect my direction less but over time it will have a bigger impact. I've tried several configurations of this and I'm about to give up and stop using accuracy as much as I want it.
I just want something that will affect the accuracy very little when the cursor is close to the player but alot when it's farther away. Any help would be greatly appreciated, thanks.Your answer
Follow this Question
Related Questions
Arkanoid-like bounce troubles 1 Answer
Player Not Moving With Platform 2D 1 Answer
Problem with my dash ability, 1 Answer
Can you improve my animation/movement code? *Bugs in details 1 Answer