public void UpdateMount() { if (m_MountNode == null) { return; } //Matrix4x4 world = m_MountTargetObject.transform.localToWorldMatrix; Matrix4x4 localParent = Matrix4x4.identity; if (gameObject.transform.parent) { localParent = gameObject.transform.parent.worldToLocalMatrix; } Matrix4x4 localTransform = localParent * m_ActorGameObject.transform.localToWorldMatrix; // m_MountNode Mat2D world = m_MountNode.WorldTransform; Mat2D m2d = new Mat2D(); m2d[0] = localTransform[0, 0]; m2d[1] = localTransform[1, 0]; m2d[2] = localTransform[0, 1]; m2d[3] = localTransform[1, 1]; m2d[4] = localTransform[0, 3] + world[4] * ActorAsset.NimaToUnityScale * localTransform[0, 0]; m2d[5] = localTransform[1, 3] + world[5] * ActorAsset.NimaToUnityScale * localTransform[1, 1]; if (m_InheritRotation && m_InheritScale) { Vec2D scale = new Vec2D(); float angle = Mat2D.Decompose(world, scale); transform.localEulerAngles = new Vector3(0.0f, 0.0f, angle * Mathf.Rad2Deg); transform.localScale = new Vector3(scale[0] * m_ScaleModifier, scale[1] * m_ScaleModifier, 1.0f); } else if (m_InheritRotation) { float angle = (float)Math.Atan2(world[1], world[0]); transform.localEulerAngles = new Vector3(0.0f, 0.0f, angle * Mathf.Rad2Deg); } else if (m_InheritScale) { Vec2D scale = new Vec2D(); Mat2D.GetScale(world, scale); transform.localScale = new Vector3(scale[0] * m_ScaleModifier, scale[1] * m_ScaleModifier, 1.0f); } transform.localPosition = new Vector3(m2d[4], m2d[5], transform.localPosition.z); }