bool MoveMotherShipForward(MyEntity entity, float speed, Vector3 destination) { Vector3 velocity = speed * entity.WorldMatrix.Forward; // Speed in direction if (Vector3.DistanceSquared(destination, entity.GetPosition()) > 10 * 10) { entity.SetPosition(entity.GetPosition() + velocity * MyConstants.PHYSICS_STEP_SIZE_IN_SECONDS); // recalculate position return false; } return true; }
private static void MoveEntityToHangar(MyEntity entity, float offset) { MyEntity hangarEntity; MyEntities.TryGetEntityByName(MyMissionLocation.MADELYN_HANGAR, out hangarEntity); MyPrefabHangar madelynHangar = hangarEntity as MyPrefabHangar; if (madelynHangar != null) { entity.SetPosition(madelynHangar.WorldVolume.Center - offset * madelynHangar.WorldMatrix.Forward); } }
MyEntity addEntity(MyEntity entity, ref Vector3 currentPosition, Vector3 forward) { float offset = (entity.WorldAABB.Max - entity.WorldAABB.Min).Length() / 2.0f + 15; currentPosition += forward * offset; Matrix mat = Matrix.CreateTranslation(entity.LocalVolumeOffset) * entity.WorldMatrix; entity.SetPosition(currentPosition - mat.Translation); currentPosition += forward * offset; return entity; }