Rotate an object towards another in increments of 45 degrees

hi I have a turret that I want to rotate towards the players position but only in 45 degree increments starting at 0 to 45 to 90 degrees ect?

You may try some maths… or do it the easy way

In the first event, you rotate the turret directly to the player, but then you take the angle of the turrent and divide it over 45 degrees. You take the rounded integer result of it, and then multiply it by 45 degrees.

If the angle is 60, then 60/45=1.3, rounded to 1. 145 = 45 degrees. 125/45= 2.7 rounded 3, 345 = 135.

I hope it helps.