I’d suggest reading up on parasomnia. It’s a class of disorders including sleep terrors, sleepwalking, nightmare disorder, sleep-related eating disorder, sleep paralysis and others. For my own issues (Night Terrors) I have found that I can largely manage them through lifestyle choices: get enough sleep regularly, don’t stay up too late, don’t drink caffeine in the afternoon/evening, manage stress, keep the sleeping room cool. Finding your own triggers can be useful for managing further episode.