I made this hacking UI for a mechanic in my game and one of the features is that panel labeled ‘stabilize’.
This panel moves around SOMETIMES in-game and I cannot figure out why. I have been keeping it in place with an animation but I ran into a roadblock which eliminated the option to keep using that workaround. The image below is how it is supposed to appear.
I have no idea why it’s doing this. I have checked that it is anchored correctly, and as I said I tried animating it to stay in place. Any suggestions are greatly appreciated!!
For code, if you have a someOtherThingTransform. reference that you intend to use to move something else, and that script happens to be ON a UI item, but you inadvertently use transform. instead, then you might get weird things happening.
Finally, here’s some reading on UI Anchoring, Scaling, CanvasScaler, etc:
Thank you for your reply!! I still have no idea why it is moving. I know it has something to do with the rigidbody connected to it. The mechanic relies on the rigidbody though so I cannot take it off. I Tried messing around with some settings but the only way that seems to be working is by animating it to return it to its x position. I did figure out a way that animating it works without conflicting with the mechanic, so I will keep using that workaround unless I find the root of the problem or discover a more efficient way to solve it.