How do i make a rotation round up to 90 or 180? like 90 degree snap?

So far i got no idea how to start, and i really need help on this

if i spawn it here, it will face this side beacuse of no changes

but if it is on the other side and no changes, it won’t look at the block

i know i could use look at, but it won’t snap like 90 degrees, i want to detect the face the is the closest

You still can use LookAt in this case! If you get the LookAt CFrame, then:

  1. Split it into the X, Y, Z orientations.
  2. Divide the X Y Z values by 90
  3. Use math.round() on the X Y Z values
  4. Multiply the new values by 90 and set the orientation to them.

It should snap the orientation to the 90 degrees.

What about if it is not only at the 90 degree?

edit: forgot that you said divide by 90 and 180 divided by 90 its 2 and 2 times 90 is 180 so if it was supposed to be 180 it will round to 2

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.