Why Is My Mesh Moving or Rotating after Being Rigged?
There are two things you should always make sure of before rigging a mesh:
- The mesh and the rig must have the same origin
- The mesh and the rig must have All Transforms applied
If either of these aren't done, the result will most likely be a rig moving somewhere you don't want when you Parent with Automatic Weights.
Give the Mesh and the Rig the same origin
Generally speaking, it's a good idea to have the rig with an origin at the world center- some game engines prefer this, and it makes it easier to move the whole rig. Select the rig, Press Shift+S, and select Cursor to World Origin. Now press F3 and type "origin to 3d cursor". Select this operator. You'll want to follow the same steps for the mesh.
Apply All Transforms
Again, you'll need to follow these steps with both the Mesh and the Armature. Press Ctrl+A (in Object Mode), and choose All Tranforms.
Once you've done both of these steps, you can reparent your Mesh to your Armature with Automatic Weights. (Or however you're doing it.) I would recommend removing the Armature Modifier from the Mesh before doing this- it's not strictly necessary, but it can sometimes cause problems with automatic weights if you don't start from scratch.
Either way, your mesh won't move around or rotate in strange ways anymore.