I have an aiming assist system I use at the moment which snaps any angle to dead-on-target, if it’s within x degrees of that target.
What I would like to have instead, is a system which assist the angle, but only as much as it neds to to just “wing” the target. IE. an auto aim system that will give you a hit if you’re off target, but still rewards accuracy within the autoaim threshold.
Threshold of angles to assist is 6 degrees either side, an angle of 3 degree either side would cause a hit.
- angleDifference is -8 degrees, no
- angleDifference is +5 degrees,
assist changes angle to +3 degrees.
- angleDifference is +1 degrees, no
assist needed, shot is more accurate
than previous example.
Since the player needs to be able to control the aiming in order to get a more accurate shot, it’s tough to make an auto-aiming system work on top of manual control. The only thing I can think of in that regard is to accelerate the player’s input in the appropriate direction to achieve the desired angle, as if their mouse speed was increasing. Although possibly a better alternative, or one that could work in tandem, is to change the trajectory of the shot itself rather than changing the aim. That way you have total control over where the shots go and the player still feels in control as well.
Not sure what is the problem? I shuld be some thing like this:
var absAngleDifference = Mathf.Abs(angleDifference); // either side plus or minus
if (absAngleDifference < 6 && absAngleDifference > 3) // if absAngleDifference is between 6 and 3
angle = targetAngle + (Mathf.Sign(angleDifference) * 3); // snaps to -+ 3 degrees