The Sims 2EditIn The Sims 2, Sims can have nightmares if players haven't been taking care of them. They will have nightmares if they go to sleep with very low motives. They also have a much higher chance of having a nightmare if they passed out from exhaustion and the player made them wake up and go to bed. They can also have nightmares if they are in an aspiration desperation or are in the red. For example, if your Sim just witnessed a death or just lost their job, they will more than likely to have a nightmare.
The Sims 3Edit
In The Sims 3, if Generations is installed, it is also possible for child and teen Sims to have nightmares. If the player clicks on the sleeping child or teen, it will pop up an option of dreaming about a certain topic. Occasionally, when the player does this, a message will be given, informing that the dream has turned into a nightmare. When the Sim wakes up, they will gain a negative moodlet from the experience.
The Sims 4 Edit
Only toddlers have nightmares in The Sims 4. When this happens, the toddler gains a sad moodlet and will wake his/hers caregivers awake. Children can also wake up with an uncomfortable moodlet due to a monster under a bed, which only they can see. The player may wait this out, although if the player wants it to become less likely for a child to do this again in the future, alternatively, the player can make an adult "Spray the Monster Under The Bed". Unlike toddlers's nightmares, all sleeping children on the lot will wake up as well as the child who discovered the monster.