I am using the code below to have the character's directional movement match its movement animations but when the player model has a non-zero y-axis rotation, the animations become mismatched.
moveVector = new Vector3 (movX, 0, movZ).normalized * (movementSpeed * (1 - pInv.totalMass/20)) * (1 + bonusSpeed); animBector = pBody.transform.rotation * moveVector; moveVector = gameObject.transform.rotation * moveVector; pAnim.SetFloat ("moveSpeed", movementSpeed/2); pAnim.SetFloat ("Vertical", animBector.normalized.z); pAnim.SetFloat ("Horizontal", animBector.normalized.x);
Note that pBody is the mesh body of the playerObject and is a child of gameObject. The gameObject does not rotate since this is a top-down project & the
moveVector = gameObject.transform.rotation * moveVector; part ensures the player moves towards its respective parts of the screen on pressing a directional button.
e.g. forward input while facing North will display a forward animation; forward+right input while facing North East will display a sideways (or strafe) animation, the correct one should be a forward animation.