public void MoveHead() { try { MyEntitySubpart subpartAstronaut; MyEntitySubpart subpart; npcCrewBlock.TryGetSubpart("NPC_Astronaut_Standing_BlankLCD_Test", out subpartAstronaut); subpartAstronaut.TryGetSubpart("NPC_Astronaut_Standing_Head_BlankLCD", out subpart); if (subpart == null) { return; } var rotation = 0.001f; var initialMatrix = subpart.PositionComp.LocalMatrix; if (AnimationLoopHead == 400) { AnimationLoopHead = 0; initHeadMovement = false; } if (AnimationLoopHead == 0) { TranslationTimeHead = -1; } if (initHeadMovement) { if (AnimationLoopHead == 160) { TranslationTimeHead = 1; } } if (!initHeadMovement && AnimationLoopHead == 200) { TranslationTimeHead = 1; } var rotationMatrix = MatrixD.CreateRotationY(rotation * TranslationTimeHead); //subpart.Value.PositionComp.LocalMatrix = rotationMatrix; var matrix = rotationMatrix * initialMatrix; subpart.PositionComp.LocalMatrix = matrix; AnimationLoopHead++; } catch (Exception e) { MyVisualScriptLogicProvider.ShowNotificationToAll("Update Error" + e, 2500, "Red"); } }