# Finding nearest multiple of 90

Can you please elaborate on a question a bit? In practical terms, what are you trying to achieve? “nearest multiple of 90 degrees in the Z direction relative to the parent actor” is a bit confusing

So basically you have 4 numbers (Parent rotation(PR), PR+90, PR+180, PR+270) and you wan to select the one thats closest to your child’s rotation? Whats the logic of selecting them or do you always want PR+90? Can you please give this more sense by providing a gameplay example.

I’m trying to attach together two actor, I want to get the nearest multiple of 90 degrees in the Z direction relative to the parent actor and then update the child actors rotation with the new number. My approach for this was to just find the nearest 90 degrees (which would be in the world) then add the parent objects rotation, which I thought would give me the result I was looking for. My problem is I can’t seem to find the nearest 90 degrees consistently, is there a way to find this simply? This code id what I’ve been trying so far, it doesn’t seem quite right. When I print the number it spits out it isn’t even a multiple of 90. I figured this wouldn’t be that hard to do? Thanks

Ya, the child actor can only be placed in four positions, each rotated 90 degrees differently on the Z axis, So i want to find this but it has to but relative to the parent, so if the parent has a Z rotation of 10 then the child needs to snap to 10, 100, 190, 280. I think I may have solved it

I think I may have solved my problem, below is the new math i’m using. I then add this new number to the rotation of the parent object and it seems to be giving me the correct rotation.

Actually never mind, seems to be off still… hmm
It looks good most of the time but when the closest degrees should be 180 or -180 it seems to think it should be 90 instead?

When the original rotation was 118.489, it thought the nearest 90 degrees was -180… Looking at some print statements I found that when walking through the math It should 118.489/90 = 1.316 which it should round to 1, but apparently it rounded to -2, weird

Thank you.