python-airmash icon indicating copy to clipboard operation
python-airmash copied to clipboard

wrongness needs to be restricted to minus pi and plus pi

Open ricklindstrom opened this issue 7 years ago • 0 comments

Because the angle_to is between minus pi and plus pi and Because the rotation is between minus pi and plus pi The wrongness is between minus 2 pi and plus 2 pi wrongness = client.player.angle_to(player) - client.player.rotation

The problem with this is, for example, if it calculates -1.5 pi it will make a big left turn left when it should actually do a small right turn of 0.5 pi.

My kill rate had a nice improvement after I added this:

    if (wrongness < -math.pi): wrongness = wrongness + (2.0 * math.pi)
    if (wrongness > math.pi):  wrongness = wrongness - (2.0 * math.pi)

p.s. - Thanks for this project. I am enjoying it.

ricklindstrom avatar Feb 06 '18 23:02 ricklindstrom