public void AttachPilot(MyCharacter pilot, bool storeOriginalPilotWorld = true, bool calledFromInit = false) { System.Diagnostics.Debug.Assert(pilot != null); System.Diagnostics.Debug.Assert(m_pilot == null); m_pilot = pilot; m_pilot.OnMarkForClose += m_pilotClosedHandler; m_pilot.IsUsing = this; //m_soundEmitter.OwnedBy = m_pilot; if (MyFakes.ENABLE_NEW_SOUNDS) { StartLoopSound(); } if (storeOriginalPilotWorld) { m_pilotRelativeWorld = (Matrix)MatrixD.Multiply(pilot.WorldMatrix, this.PositionComp.GetWorldMatrixNormalizedInv()); if (Sync.IsServer) { var relativeEntry = new MyPositionAndOrientation(m_pilotRelativeWorld.Value); SyncObject.SendPilotRelativeEntryUpdate(ref relativeEntry); } } if (pilot.InScene) { MyEntities.Remove(pilot); } m_pilot.Physics.Enabled = false; m_pilot.PositionComp.SetWorldMatrix(WorldMatrix); m_pilot.Physics.Clear(); //m_pilot.SetPosition(GetPosition() - WorldMatrix.Forward * 0.5f); Hierarchy.AddChild(m_pilot, true, true); var gunEntity = m_pilot.CurrentWeapon as MyEntity; if (gunEntity != null) { var ob = gunEntity.GetObjectBuilder(); m_pilotGunDefinition = ob.GetId(); } else { m_pilotGunDefinition = null; } MyAnimationDefinition animationDefinition; MyDefinitionId id = new MyDefinitionId(typeof(MyObjectBuilder_AnimationDefinition), BlockDefinition.CharacterAnimation); if (!MyDefinitionManager.Static.TryGetDefinition(id, out animationDefinition) && !MyFileSystem.FileExists(BlockDefinition.CharacterAnimation)) { BlockDefinition.CharacterAnimation = null; } PlacePilotInSeat(pilot); m_rechargeSocket.PlugIn(m_pilot.SuitBattery); // Control should be handled elsewhere if we initialize the grid in the Init(...) if (!calledFromInit) { GiveControlToPilot(); } m_pilot.SwitchToWeapon(null); }