For some reason this experience you are describing reminds me of a passage in "One hundred years of solitude" where a character is said to fall in love with a woman that only exists when she is needed.