How would I lock Part orientation on X and Y axis?

Hello,

So, I was trying to lock the X and Y axis and let the Z axis freely rotate (Basically like a 2d effect)but completely failed to. This feature can also be seen in a popular sandbox game called “people playground” and many other 2d games.

https://gyazo.com/1079f368a2a1017267c8d99bc96824d7

Any help is appreciated!

2 Likes

There is a significant different between 2d games and Roblox, for starters, Roblox is 3d. What this practically means is that the rotation effects on those games work fundamentally different from 3d games.

However, this does not mean that you can’t do it in Roblox. There are different ways to achieve this, however I’m not sure which would be the best solution.

First alternative:
Reset the orientation on the X & Y axis as soon as it’s rotation changes. I think this will be fairly resource intensive.

Second alternative:
Figure out a way to use AlignOrientation (roblox.com) to your advantage. It’s the new BodyGyro if you are familiar with that.

Third alternative:
Anchor all parts and let your own scripts decide when they should rotate, and only allow them to rotate on the Z axis.

Another guy was doing something somewhat similar, he created a “spinner” which could only be rotated in one axis.
Interactive push spinner - Help and Feedback / Scripting Support - DevForum | Roblox

He gave some hints on how he made it work, you might be able to message him and ask him how he made that spinner.

1 Like

Thank you for your reply!
Tho, what would be the best AlignOrientation settings if you don’t mind me asking?

I have not yet tried using AlignOrientation, I would recommend that you play around with a singular part which uses it and then tweak them until you find what you are looking for.

There is no guarantee this would work though, but one can always hope.

1 Like

Alright! I found out how to make a script for the first alternative.
Thank you so much dude.

No problem!

You might want to keep an eye out for performance changes, I have a feeling it might get slow if you have many parts.

1 Like